Commit 9de1a87d authored by Waldo Cancino's avatar Waldo Cancino

Delete unnecessary files, correct template

parent 600acd59
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <limits.h>
void MY_OPTIMIZER(double(*fitnessfunction)(double*), unsigned int dim, double ftarget, double maxfunevals)
double * x = (double *)malloc(sizeof(double) * dim);
double f;
double iter;
unsigned int j;
if (maxfunevals > 1000000000. * dim)
maxfunevals = 1000000000. * dim;
for (iter = 0.; iter < maxfunevals; iter++)
/* Generate individual */
for (j = 0; j < dim; j++)
x[j] = 10. * ((double)rand() / RAND_MAX) - 5.;
/* evaluate x on the objective function */
f = fitnessfunction(x);
if (f < ftarget)
\ No newline at end of file
#This is an example Makefile that will create the executables exampletiming and
#exampleexperiment. This Makefile can either be completed with rules to create
#the executables for your own experiment or the rules here can be added to your
#own Makefile.
#Define your compiler/linker if needed.
#Strict options
CFLAGS=-Wextra -Wall -ansi -pedantic
#Lenient: add/remove any compilation or linking flags that you feel are necessary or not.
#Linux/Unix users can try to comment the above and uncomment the following line instead.
# DIROK=dirOK-linux.o
#Lists all executable, used by the "all" and "clean" rules.
EXECS=exampletiming exampleexperiment
all: $(EXECS)
#Add here any rules needed for your own experiments
#Example experiments:
exampletiming: MY_OPTIMIZER.o benchmarksdeclare.o $(DIROK) benchmarkshelper.o benchmarks.o benchmarksnoisy.o fgeneric.o exampletiming.o
$(CC) $(LDFLAGS) -o $@ $^ -lm
exampleexperiment: MY_OPTIMIZER.o benchmarksdeclare.o $(DIROK) benchmarkshelper.o benchmarks.o benchmarksnoisy.o fgeneric.o exampleexperiment.o
$(CC) $(LDFLAGS) -o $@ $^ -lm
#Your own experiment should have bbobStructures.h as a dependency and so should be added here.
exampletiming.o exampleexperiment.o benchmarkshelper.o fgeneric.o benchmarks.o benchmarksnoisy.o benchmarksdeclare.o : bbobStructures.h
#Benchmarks object files are optimized so they are exceptions to the implicit *.o generation rule.
benchmarks.o : benchmarks.c
$(CC) -c $(CFLAGS) -O2 $<
benchmarksnoisy.o : benchmarksnoisy.c
$(CC) -c $(CFLAGS) -O2 $<
.PHONY: clean
#Comment the command starting with rm and uncomment the comment starting with del to make the makefile work under Windows.
rm -f *.o $(EXECS)
# del *.o exampleexperiment.exe exampletiming.exe
This is program entry for STD template for bbob2013
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include "COptionParser.h"
#include "CRandomGenerator.h"
#include "CEvolutionaryAlgorithm.h"
#include "global.h"
#include "bbob2013Individual.hpp"
using namespace std;
/** Global variables for the whole algorithm */
CIndividual** pPopulation = NULL;
CIndividual* bBest = NULL;
float* pEZ_MUT_PROB = NULL;
unsigned *EZ_NB_GEN;
unsigned *EZ_current_generation;
CEvolutionaryAlgorithm* EA;
int main(int argc, char** argv){
ParametersImpl p;
CEvolutionaryAlgorithm* ea = p.newEvolutionaryAlgorithm();
EA = ea;
CPopulation* pop = ea->getPopulation();
delete pop;
return 0;
......@@ -152,7 +152,7 @@ return NbMut;
\User Makefile options:
CXXFLAGS+=-I/usr/local/cuda/common/inc/ -I/usr/local/cuda/include/ -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
LDFLAGS+=-lgfal_pthr -llcg_util
OBJS+= benchmarks.o benchmarksnoisy.o fgeneric.o benchmarkshelper.o
This diff is collapsed.
//#include "CRandomGenerator.h"
#include <stdlib.h>
#include <iostream>
#include <CIndividual.h>
#include <Parameters.h>
#include <string>
using namespace std;
class CRandomGenerator;
class CSelectionOperator;
class CGenerationalCriterion;
class CEvolutionaryAlgorithm;
class CPopulation;
class Parameters;
class IndividualImpl : public CIndividual {
public: // in bbob2013 the genome is public (for user functions,...)
// Class members
// Class members
double *sigma;
double *x;
IndividualImpl(const IndividualImpl& indiv);
virtual ~IndividualImpl();
float evaluate();
static unsigned getCrossoverArrity(){ return 2; }
float getFitness(){ return this->fitness; }
CIndividual* crossover(CIndividual** p2);
void printOn(std::ostream& O) const;
CIndividual* clone();
unsigned mutate(float pMutationPerGene);
void boundChecking();
string serialize();
void deserialize(string EASEA_Line);
friend std::ostream& operator << (std::ostream& O, const IndividualImpl& B) ;
void initRandomGenerator(CRandomGenerator* rg){ IndividualImpl::rg = rg;}
class ParametersImpl : public Parameters {
void setDefaultParameters(int argc, char** argv);
CEvolutionaryAlgorithm* newEvolutionaryAlgorithm();
* @TODO ces functions devraient s'appeler weierstrassInit, weierstrassFinal etc... (en gros bbob2013Final dans le tpl).
void bbob2013Init(int argc, char** argv);
void bbob2013Final(CPopulation* pop);
void bbob2013BeginningGenerationFunction(CEvolutionaryAlgorithm* evolutionaryAlgorithm);
void bbob2013EndGenerationFunction(CEvolutionaryAlgorithm* evolutionaryAlgorithm);
void bbob2013GenerationFunctionBeforeReplacement(CEvolutionaryAlgorithm* evolutionaryAlgorithm);
class EvolutionaryAlgorithmImpl: public CEvolutionaryAlgorithm {
EvolutionaryAlgorithmImpl(Parameters* params);
virtual ~EvolutionaryAlgorithmImpl();
void initializeParentPopulation();
#endif /* PROBLEM_DEP_H */
/*Global definitions*/
int DIM;
int trialid;
double * peaks;
double * Xopt; /*Initialized in benchmarkhelper.c*/
double Fopt;
unsigned int isInitDone;
/* runs an entire experiment for benchmarking MY_OPTIMIZER
* on the noise-free testbed
* or the noisy testbed (change the ifun loop in this case as given below).
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include "bbobStructures.h" /* Include all declarations for BBOB calls */
/* include all declarations for your own optimizer here */
void MY_OPTIMIZER(double(*fitnessfunction)(double*), unsigned int dim, double ftarget,
double maxfunevals);
int main(void)
unsigned int dim[6] = {2, 3, 5, 10, 20, 40};
unsigned int instances[15] = {1, 2, 3, 4, 5, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40};
unsigned int idx_dim, ifun, idx_instances, seed;
int independent_restarts;
double maxfunevals, minfunevals;
clock_t t0 = clock();
time_t Tval;
* BBOB Mandatory initialization *
/* retrieve all default parameters of BBOB calls */
ParamStruct params = fgeneric_getDefaultPARAMS();
/* modify the following parameters, choosing a different setting
* for each new experiment */
strcpy(params.dataPath, "PUT_MY_BBOB_DATA_PATH"); /* different folder for each experiment! */
/* please beforehand run from the command-line 'python PUT_MY_BBOB_DATA_PATH'
* to create the necessary folder structure to run an experiment. */
strcpy(params.algName, "PUT ALGORITHM NAME");
seed = time(NULL);
srand(seed); /* used by MY_OPTIMIZER */
printf("random seed set to %d\n", seed);
/* To make the noise deterministic. */
/* fgeneric_noiseseed(30); printf("seed for the noise set to: 30\n"); */
/* now the main loop */
for (idx_dim = 0; idx_dim < 6; idx_dim++)
/* Function indices are from 1 to 24 (noiseless) or from 101 to 130 (noisy) */
/* for the noisy functions exchange the for loop with */
/* for (ifun = 101; ifun <= 130; ifun++) */
for (ifun = 1; ifun <= 24; ifun++)
for (idx_instances = 0; idx_instances < 15; idx_instances++)
/* set DIM, funcId, instanceId to initialize BBOB fgeneric */
params.DIM = dim[idx_dim];
params.funcId = ifun;
params.instanceId = instances[idx_instances];
/* call the BBOB initialization */
/* now call your optimizer so that it optimizes the function
* fgeneric_evaluate or
* fgeneric_evaluate_vector(double * XX, unsigned int howMany,
* double * result)
/* The fgeneric interface can give some information:
* e.g. fgeneric_ftarget() the target value only for termination
* fgeneric_evaluations() the number of calls to fgeneric_evaluate
* after fgeneric_initialization
* fgeneric_best() the best value reached
maxfunevals = 5. * dim[idx_dim]; /* PUT APPROPRIATE MAX. NUMBER OF FEVALS */
/* 5. * dim should be fine to just check everything */
minfunevals = dim[idx_dim] + 2; /* PUT MINIMAL USEFUL NUMBER OF FEVALS */
independent_restarts = -1;
while (fgeneric_evaluations() + minfunevals <= maxfunevals)
if (++independent_restarts > 0)
fgeneric_restart("independent restart"); /* additional info */
MY_OPTIMIZER(&fgeneric_evaluate, dim[idx_dim], fgeneric_ftarget(),
maxfunevals - fgeneric_evaluations());
if (fgeneric_best() < fgeneric_ftarget())
printf(" f%d in %d-D, instance %d: FEs=%.0f with %d restarts,", ifun, dim[idx_dim],
instances[idx_instances], fgeneric_evaluations(), independent_restarts);
printf(" fbest-ftarget=%.4e, elapsed time [h]: %.2f\n",
fgeneric_best() - fgeneric_ftarget(), (double)(clock()-t0)/CLOCKS_PER_SEC/60./60.);
/* call the BBOB closing function to wrap things up neatly */
Tval = time(NULL);
printf(" date and time: %s", ctime(&Tval));
printf("---- dimension %d-D done ----\n", dim[idx_dim]);
return 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment