Commit 7baaa751 authored by kruger's avatar kruger

Version Memetic STD

parent 9d46eb94
......@@ -24,6 +24,7 @@ Centre de Math
#define STD_FLAVOR_SO 0
#define STD_FLAVOR_MO 1
#define STD_FLAVOR_CMAES 2
#define STD_FLAVOR_MEMETIC 3
#define CUDA_FLAVOR_SO 0
#define CUDA_FLAVOR_MO 1
#define CUDA_FLAVOR_CMAES 2
......@@ -46,9 +47,10 @@ extern float fSELECT_PRM, fRED_PAR_PRM, fRED_FINAL_PRM, fRED_OFF_PRM;
extern char sSELECTOR[], sSELECTOR_OPERATOR[], sRED_PAR[], sRED_PAR_OPERATOR[], sRED_FINAL[], sRED_FINAL_OPERATOR[], sRED_OFF[], sRED_OFF_OPERATOR[];
extern int nMINIMISE,nELITE;
extern bool bELITISM, bVERBOSE;
extern bool bPRINT_STATS, bPLOT_STATS, bGENERATE_CVS_FILE, bGENERATE_GNUPLOT_SCRIPT, bGENERATE_R_SCRIPT;
extern bool bBALDWINISM;
extern bool bPRINT_STATS, bPLOT_STATS, bGENERATE_CSV_FILE, bGENERATE_GNUPLOT_SCRIPT, bGENERATE_R_SCRIPT;
extern char* nGENOME_NAME;
extern int nPOP_SIZE, nNB_GEN, nOFF_SIZE, nPROBLEM_DIM, nTIME_LIMIT;
extern int nPOP_SIZE, nNB_GEN, nNB_OPT_IT, nOFF_SIZE, nPROBLEM_DIM, nTIME_LIMIT;
extern float fMUT_PROB, fXOVER_PROB, fSURV_PAR_SIZE, fSURV_OFF_SIZE;
extern int nWARNINGS, nERRORS;
......
......@@ -73,7 +73,7 @@ Centre de Math
%start GENOME_ANALYSIS TEMPLATE_ANALYSIS MACRO_IDENTIFIER MACRO_DEFINITION
%start COPY_USER_DECLARATIONS COPY_INITIALISATION_FUNCTION ANALYSE_USER_CLASSES
%start COPY_EO_INITIALISER
%start COPY COPY_INITIALISER COPY_CROSSOVER COPY_MUTATOR COPY_EVALUATOR COPY_FINALIZATION_FUNCTION
%start COPY COPY_INITIALISER COPY_CROSSOVER COPY_MUTATOR COPY_EVALUATOR COPY_FINALIZATION_FUNCTION COPY_OPTIMISER
%start COPY_DISPLAY COPY_USER_FUNCTION COPY_USER_GENERATION PARAMETERS_ANALYSIS GET_PARAMETERS
%start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION_BEFORE_REPLACEMENT GET_METHODS COPY_MAKEFILE_OPTION COPY_BOUND_CHECKING_FUNCTION COPY_BEG_GENERATION_FUNCTION COPY_END_GENERATION_FUNCTION COPY_INSTEAD_EVAL
......@@ -81,7 +81,7 @@ Centre de Math
%name CEASEALexer {
protected:
CSymbolTable *pSymbolTable; // the symbol table
bool bSymbolInserted,bWithinEvaluator; // used to change evalutor type from double to float
bool bSymbolInserted,bWithinEvaluator, bWithinOptimiser; // used to change evalutor type from double to float
bool bInitFunction,bDisplayFunction,bFunction, bNotFinishedYet, bWithinEO_Function;
bool bDoubleQuotes,bWithinDisplayFunction,bWithinInitialiser,bWithinMutator,bWithinXover;
bool bWaitingForSemiColon,bFinishNB_GEN,bFinishMINIMISE,bFinishMINIMIZE,bGenerationReplacementFunction;
......@@ -98,7 +98,7 @@ Centre de Math
// constructor
{
bFunction=bWithinEvaluator=bDisplayFunction=bInitFunction=bNotFinishedYet=0;
bFunction=bWithinEvaluator=bWithinOptimiser=bDisplayFunction=bInitFunction=bNotFinishedYet=0;
bSymbolInserted=bDoubleQuotes=bWithinDisplayFunction=bWithinInitialiser=bWithinMutator=bWithinXover=0;
bWaitingForSemiColon=bFinishNB_GEN=bFinishMINIMISE=bFinishMINIMIZE=bGenerationReplacementFunction=0;
bCatchNextSemiColon,bWaitingToClosePopulation=bMethodsInGenome=0;
......@@ -549,6 +549,11 @@ exponent ([Ee][+-]?[0-9]+)
lineCounter=1;
BEGIN COPY_EVALUATOR;
}
<TEMPLATE_ANALYSIS>"\\INSERT_OPTIMISER" {
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_OPTIMISER;
}
<TEMPLATE_ANALYSIS>"\\INSERT_CUDA_EVALUATOR" {
yyreset();
......@@ -711,10 +716,12 @@ if(OPERATING_SYSTEM=WINDOWS)
case STD:
case CUDA: fprintf(fpOutputFile,"%d",bELITISM);
} }
<TEMPLATE_ANALYSIS>"\\NB_OPT_IT" {fprintf(fpOutputFile,"%d",nNB_OPT_IT);}
<TEMPLATE_ANALYSIS>"\\BALDWINISM" {fprintf(fpOutputFile,"%d",bBALDWINISM);}
<TEMPLATE_ANALYSIS>"\\PRINT_STATS" {fprintf(fpOutputFile,"%d",bPRINT_STATS);}
<TEMPLATE_ANALYSIS>"\\PLOT_STATS" {fprintf(fpOutputFile,"%d",bPLOT_STATS);}
<TEMPLATE_ANALYSIS>"\\GENERATE_CVS_FILE" {fprintf(fpOutputFile,"%d",bGENERATE_CVS_FILE);}
<TEMPLATE_ANALYSIS>"\\GENERATE_CSV_FILE" {fprintf(fpOutputFile,"%d",bGENERATE_CSV_FILE);}
<TEMPLATE_ANALYSIS>"\\GENERATE_GNUPLOT_SCRIPT" {fprintf(fpOutputFile,"%d",bGENERATE_GNUPLOT_SCRIPT);}
<TEMPLATE_ANALYSIS>"\\GENERATE_R_SCRIPT" {fprintf(fpOutputFile,"%d",bGENERATE_R_SCRIPT);}
......@@ -1354,6 +1361,15 @@ if(OPERATING_SYSTEM=WINDOWS)
<COPY_EVALUATOR>. {}
<COPY_EVALUATOR>\n {lineCounter++;}
<COPY_OPTIMISER>"\\GenomeClass::optimiser"[ \t\n]*":" {
BEGIN COPY_USER_FUNCTION;
bWithinOptimiser=1;
if( bLINE_NUM_EZ_FILE )
fprintf(fpOutputFile,"#line %d \"%s.ez\"\n",lineCounter, sRAW_PROJECT_NAME);
return USER_OPTIMISER;
}
<COPY_OPTIMISER>.|\n {lineCounter++;}
//****************************************
// Basic copy to .cpp file with major changes
//****************************************
......@@ -1549,7 +1565,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<COPY_USER_FUNCTION>"Genome" {
if(bWithinEvaluator || bWithinMutator || bWithinDisplayFunction){
if(bWithinOptimiser || bWithinEvaluator || bWithinMutator || bWithinDisplayFunction){
if( bWithinCUDA_Evaluator)
fprintf(fpOutputFile, "(*INDIVIDUAL_ACCESS(devBuffer,id))");
else fprintf(fpOutputFile, "(*this)");
......@@ -1641,7 +1657,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<COPY_USER_FUNCTION>"\\end" {rewind(fpGenomeFile);
yyin = fpTemplateFile;
BEGIN TEMPLATE_ANALYSIS;
bWithinInitialiser=bWithinXover=bWithinMutator=bWithinEvaluator=bWithinCUDA_Evaluator=0;
bWithinInitialiser=bWithinXover=bWithinMutator=bWithinEvaluator=bWithinOptimiser=bWithinCUDA_Evaluator=0;
if (bWithinDisplayFunction){
bWithinDisplayFunction=0; // display function
}
......@@ -1680,7 +1696,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<GET_PARAMETERS>"Print"[ \t\n]+"stats"[ \t\n]*":"[\t\n]* {if (bVERBOSE) printf("\tPrint Stats...\n");return PRINT_STATS;}
<GET_PARAMETERS>"Plot"[ \t\n]+"stats"[ \t\n]*":"[\t\n]* {if (bVERBOSE) printf("\tPlot Stats with gnuplot...\n");return PLOT_STATS;}
<GET_PARAMETERS>"Generate"[ \t\n]+"cvs"[ \t\n]+"stats"[ \t\n]+"file"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf("\tPrint Stats to cvs File...\n");return GENERATE_CVS_FILE;}
<GET_PARAMETERS>"Generate"[ \t\n]+"csv"[ \t\n]+"stats"[ \t\n]+"file"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf("\tPrint Stats to csv File...\n");return GENERATE_CSV_FILE;}
<GET_PARAMETERS>"Generate"[ \t\n]+"gnuplot"[ \t\n]+"script"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf("\tGenerate Gnuplot Script...\n");return GENERATE_GNUPLOT_SCRIPT;}
<GET_PARAMETERS>"Generate"[ \t\n]+"R"[ \t\n]+"script"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf("\tGenerate R Script...\n");return GENERATE_R_SCRIPT;}
......@@ -1702,6 +1718,8 @@ if(OPERATING_SYSTEM=WINDOWS)
<GET_PARAMETERS>"Final"[ \t\n]+"reduce"[ \t\n]+"operator"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tFinal Reduce Operator...\n");return RED_FINAL;}// DISCARD;}
<GET_PARAMETERS>"Elitism"[ \t\n]*":" {if (bVERBOSE) printf ("\tElitism...\n");return ELITISM;}
<GET_PARAMETERS>"Evaluator"[ \t\n]+"goal"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tMinMax...\n");return MINIMAXI;}
<GET_PARAMETERS>"Number"[ \t\n]+"of"[ \t\n]+"optimisation"[ \t\n]+"iterations"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tNb of Optimisation It...\n");return NB_OPT_IT;}
<GET_PARAMETERS>"Baldwinism"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tBaldwinism...\n");return BALDWINISM;}
// number
<GET_PARAMETERS>[0-9]+"."[0-9]*{exponent}? |
......@@ -1840,6 +1858,8 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
strcat(sTemp,"STD.tpl");
else if (TARGET_FLAVOR == STD_FLAVOR_CMAES)
strcat(sTemp,"CMAES.tpl");
else if (TARGET_FLAVOR == STD_FLAVOR_MEMETIC )
strcat(sTemp,"STD_MEM.tpl");
else
strcat(sTemp,"STD_MO.tpl");
if (!(yyin = fpTemplateFile = fopen(sTemp, "r"))){
......
......@@ -39,18 +39,20 @@ float fRED_OFF_PRM;//[50] = {0};
char sRED_FINAL[50], sRED_FINAL_OPERATOR[50];
float fRED_FINAL_PRM=0.0;//[50];
int nMINIMISE=2;
int nELITE;
int nELITE=0;
bool bELITISM=0;
bool bVERBOSE=0;
bool bLINE_NUM_EZ_FILE=1;
bool bPRINT_STATS=1;
bool bPLOT_STATS=0;
bool bGENERATE_CVS_FILE=0, bGENERATE_R_SCRIPT=0, bGENERATE_GNUPLOT_SCRIPT=0;
bool bGENERATE_CSV_FILE=0, bGENERATE_R_SCRIPT=0, bGENERATE_GNUPLOT_SCRIPT=0;
bool bBALDWINISM=0;
int nPOP_SIZE, nOFF_SIZE;
float fSURV_PAR_SIZE=-1.0, fSURV_OFF_SIZE=-1.0;
char *nGENOME_NAME;
int nPROBLEM_DIM;
int nNB_GEN;
int nNB_GEN=0;
int nNB_OPT_IT=0;
int nTIME_LIMIT=0;
float fMUT_PROB;
float fXOVER_PROB;
......@@ -94,6 +96,7 @@ class CSymbol;
%token USER_XOVER
%token USER_MUTATOR
%token USER_EVALUATOR
%token USER_OPTIMISER
%token MAKEFILE_OPTION
%token END_OF_FUNCTION
//%token DELETE
......@@ -111,6 +114,8 @@ class CSymbol;
%token METHODS
%token STATIC
%token NB_GEN
%token NB_OPT_IT //Memetic
%token BALDWINISM //Memetic
%token MUT_PROB
%token XOVER_PROB
%token POP_SIZE
......@@ -126,7 +131,7 @@ class CSymbol;
%token ELITE
%token PRINT_STATS
%token PLOT_STATS
%token GENERATE_CVS_FILE
%token GENERATE_CSV_FILE
%token GENERATE_GNUPLOT_SCRIPT
%token GENERATE_R_SCRIPT
%token TIME_LIMIT
......@@ -446,6 +451,12 @@ StandardFunctionAnalysis
END_OF_FUNCTION {
if (TARGET!=CUDA && TARGET!=STD) fprintf(fpOutputFile,"}\n");
}
| USER_OPTIMISER {
if (bVERBOSE) printf("Inserting user genome optimiser (taken from .ez file).\n");
}
END_OF_FUNCTION {
if (TARGET!=CUDA && TARGET!=STD) fprintf(fpOutputFile,"}\n");
}
| MAKEFILE_OPTION END_OF_FUNCTION {
//DEBUG_PRT("User makefile options have been reduced");
}
......@@ -460,6 +471,8 @@ RunParameters
Parameter
: NB_GEN NUMBER2
{nNB_GEN=(int)$2;}
| NB_OPT_IT NUMBER2
{nNB_OPT_IT=(int)$2;}
| TIME_LIMIT NUMBER2
{nTIME_LIMIT=(int)$2;}
| MUT_PROB NUMBER2
......@@ -576,6 +589,14 @@ Parameter
fprintf(stderr,"\n%s - Warning line %d: Elitism must be \"Strong\" or \"Weak\".\nDefault value \"Strong\" inserted.\n.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
bELITISM=1;
}}
| BALDWINISM IDENTIFIER2{
if (!mystricmp($2->sName,"False")) bELITISM=0;
else if (!mystricmp($2->sName,"True")) bELITISM=1;
else {
fprintf(stderr,"\n%s - Warning line %d: Lamarckism must be \"True\" or \"False\".\nDefault value \"True\" inserted.\n.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
bELITISM=1;
}}
| PRINT_STATS NUMBER2{
if((int)$2>=1)
bPRINT_STATS=1;
......@@ -588,11 +609,11 @@ Parameter
else
bPLOT_STATS=0;
}
| GENERATE_CVS_FILE NUMBER2{
| GENERATE_CSV_FILE NUMBER2{
if((int)$2>=1)
bGENERATE_CVS_FILE=1;
bGENERATE_CSV_FILE=1;
else
bGENERATE_CVS_FILE=0;
bGENERATE_CSV_FILE=0;
}
| GENERATE_GNUPLOT_SCRIPT NUMBER2{
if((int)$2>=1)
......@@ -678,11 +699,14 @@ int main(int argc, char *argv[]){
TARGET=CUDA;
TARGET_FLAVOR = CUDA_FLAVOR_CMAES;
}
else if (!mystricmp(sTemp,"memetic")) {
TARGET=STD;
TARGET_FLAVOR = STD_FLAVOR_MEMETIC;
}
else if (!mystricmp(sTemp,"v")) bVERBOSE=true;
else if (!mystricmp(sTemp,"tl")){
printf("yopyop true line\n");
bLINE_NUM_EZ_FILE=false;
}
else if (!mystricmp(sTemp,"path")) {
......
......@@ -152,8 +152,8 @@ CPPFLAGS+=
\Default run parameters : // Please let the parameters appear in this order
Number of generations : 100 // NB_GEN
Time limit: 0 // In seconds, 0 to deactivate
Population size : 3840 //POP_SIZE
Offspring size : 3840 // 40%
Population size : 10 //POP_SIZE
Offspring size : 10 // 40%
Mutation probability : 1 // MUT_PROB
Crossover probability : 1 // XOVER_PROB
Evaluator goal : minimise // Maximise
......
......@@ -87,9 +87,9 @@ CEvolutionaryAlgorithm::CEvolutionaryAlgorithm(Parameters* params){
fichier.append(".plot");
remove(fichier.c_str());
}
if(params->generateRScript || params->generateCVSFile){
if(params->generateRScript || params->generateCSVFile){
string fichier = params->outputFilename;
fichier.append(".cvs");
fichier.append(".csv");
remove(fichier.c_str());
}
if(params->generateRScript){
......@@ -113,6 +113,13 @@ void CEvolutionaryAlgorithm::addStoppingCriterion(CStoppingCriterion* sc){
void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
CIndividual** elitistPopulation;
#ifdef WIN32
clock_t begin(clock());
#else
struct timeval begin;
gettimeofday(&begin,NULL);
#endif
std::cout << "Parent's population initializing "<< std::endl;
this->initializeParentPopulation();
if(!INSTEAD_EVAL_STEP)
......@@ -120,14 +127,17 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
else
evale_pop_chunk(population->parents, population->parentPopulationSize);
if(this->params->optimise){
population->optimiseParentPopulation();
}
this->population->currentEvaluationNb += this->params->parentPopulationSize;
if(this->params->printInitialPopulation){
std::cout << *population << std::endl;
}
struct timeval begin;
gettimeofday(&begin,NULL);
showPopulationStats(begin);
currentGeneration += 1;
//Initialize elitPopulation
if(params->elitSize)
......@@ -144,6 +154,10 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
evale_pop_chunk(population->offsprings, population->offspringPopulationSize);
population->currentEvaluationNb += this->params->offspringPopulationSize;
if(this->params->optimise){
population->optimiseOffspringPopulation();
}
EASEAGenerationFunctionBeforeReplacement(this);
/* ELITISM */
......@@ -169,7 +183,7 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
population->reduceTotalPopulation(elitistPopulation);
population->sortParentPopulation();
if( this->params->printStats || this->params->generateCVSFile )
if( this->params->printStats || this->params->generateCSVFile )
showPopulationStats(begin);
bBest = population->Best;
EASEAEndGenerationFunction(this);
......@@ -246,11 +260,11 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
fclose(f);
}
}
if(params->generateCVSFile || params->generateRScript){ //Generation du fichier CVS;
if(params->generateCSVFile || params->generateRScript){ //Generation du fichier CSV;
FILE *f;
string fichier = params->outputFilename;
fichier.append(".cvs");
f = fopen(fichier.c_str(),"a"); //ajouter .cvs
fichier.append(".csv");
f = fopen(fichier.c_str(),"a"); //ajouter .csv
if(f!=NULL){
if(currentGeneration==0)
fprintf(f,"GEN,TIME,EVAL,BEST,AVG,STDEV\n");
......@@ -304,7 +318,7 @@ void CEvolutionaryAlgorithm::generateRScript(){
f=fopen(fichier.c_str(),"a");
fprintf(f,"#Plotting for R\n"),
fprintf(f,"png(\"%s\")\n",params->plotOutputFilename);
fprintf(f,"data <- read.table(\"./%s.cvs\",sep=\",\")\n",params->outputFilename);
fprintf(f,"data <- read.table(\"./%s.csv\",sep=\",\")\n",params->outputFilename);
fprintf(f,"plot(0, type = \"n\", main = \"Plot Title\", xlab = \"Number of Evaluations\", ylab = \"Fitness\", xlim = c(0,%d) )\n",population->currentEvaluationNb);
fprintf(f,"grid() # add grid\n");
fprintf(f,"lines(data[,3], data[,4], lty = 1) #draw first dataset\n");
......
......@@ -132,6 +132,8 @@ void parseArguments(const char* parametersFileName, int ac, char** av,
("reduceOffspringPressure",po::value<float>(),"Set the Offspring Reducing Pressure (default : 2.0)")
("reduceFinalOperator",po::value<string>(),"Set the Final Reducing Operator (default : Tournament)")
("reduceFinalPressure",po::value<float>(),"Set the Final Reducing Pressure (default : 2.0)")
("optimiseIterations",po::value<int>(),"Set the number of optimisation iterations (default : 100)")
("baldwinism",po::value<int>(),"Only keep fitness (default : 0)")
("outputfile",po::value<string>(),"Set an output file for the final population (default : none)")
("inputfile",po::value<string>(),"Set an input file for the initial population (default : none)")
("printStats",po::value<int>(),"Print the Stats (default : 1)")
......
......@@ -106,19 +106,27 @@ void CPopulation::initPopulation(CSelectionOperator* selectionOperator,
void CPopulation::evaluatePopulation(CIndividual** population, size_t populationSize){
for( size_t i=0 ; i < populationSize ; i++ )
population[i]->evaluate();
//currentEvaluationNb += populationSize;
}
void CPopulation::optimisePopulation(CIndividual** population, size_t populationSize){
}
void CPopulation::evaluateParentPopulation(){
evaluatePopulation(parents,parentPopulationSize);
}
void CPopulation::optimiseParentPopulation(){
optimisePopulation(parents,parentPopulationSize);
}
void CPopulation::evaluateOffspringPopulation(){
evaluatePopulation(offsprings,offspringPopulationSize);
}
void CPopulation::optimiseOffspringPopulation(){
optimisePopulation(offsprings,offspringPopulationSize);
}
/**
Reduit la population population de taille populationSize
......
......@@ -65,12 +65,15 @@ public:
//virtual void initializeParentPopulation() = 0;
void addIndividualParentPopulation(CIndividual* indiv);
void evaluatePopulation(CIndividual** population, size_t populationSize);
virtual void optimisePopulation(CIndividual** population, size_t populationSize);
virtual void evaluateParentPopulation();
void optimiseParentPopulation();
void strongElitism(size_t elitismSize, CIndividual** population, size_t populationSize, CIndividual** outPopulation, size_t outPopulationSize);
void weakElitism(size_t elitismSize, CIndividual** parentsPopulation, CIndividual** offspringPopulation, size_t* parentPopSize, size_t* offPopSize, CIndividual** outPopulation, size_t outPopulationSize);
virtual void evaluateOffspringPopulation();
void optimiseOffspringPopulation();
CIndividual** reducePopulations(CIndividual** population, size_t populationSize,
CIndividual** reducedPopulation, size_t obSize);
CIndividual** reduceParentPopulation(size_t obSize);
......
......@@ -50,8 +50,12 @@ public:
bool strongElitism;
unsigned int elitSize;
bool optimise;
int optimiseIterations;
bool baldwinism;
int printStats;
int generateCVSFile;
int generateCSVFile;
int generateGnuplotScript;
int generateRScript;
int plotStats;
......
......@@ -84,7 +84,7 @@ int main(int argc, char** argv){
using namespace std;
#include "EASEAIndividual.hpp"
bool INSTEAD_EVAL_STEP = false;
CRandomGenerator* globalRandomGenerator;
extern CEvolutionaryAlgorithm* EA;
......@@ -102,6 +102,9 @@ extern CEvolutionaryAlgorithm* EA;
\INSERT_BOUND_CHECKING
void evale_pop_chunk(CIndividual** population, int popSize){
\INSTEAD_EVAL_FUNCTION
}
void EASEAInit(int argc, char** argv){
\INSERT_INIT_FCT_CALL
......@@ -276,20 +279,21 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
controlCStopingCriterion = new CControlCStopingCriterion();
timeCriterion = new CTimeCriterion(setVariable("timeLimit",\TIME_LIMIT));
this->optimise = 0;
seed = setVariable("seed",(int)time(0));
globalRandomGenerator = new CRandomGenerator(seed);
this->randomGenerator = globalRandomGenerator;
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCVSFile = setVariable("generateCSVFile",\GENERATE_CVS_FILE);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
this->printFinalPopulation = setVariable("printFinalPopulation",0);
this->outputFilename = (char*)"EASEA.dat";
this->outputFilename = (char*)"EASEA";
this->plotOutputFilename = (char*)"EASEA.png";
}
......@@ -593,7 +597,7 @@ easeaclean:
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--printInitialPopulation=0 #Print initial population
--printFinalPopulation=0 #Print final population
--generateCSVFile=\GENERATE_CVS_FILE
--generateCSVFile=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
......
......@@ -87,7 +87,7 @@ using namespace std;
#include "EASEAIndividual.hpp"
bool INSTEAD_EVAL_STEP = false;
CRandomGenerator* globalRandomGenerator;
extern CEvolutionaryAlgorithm* EA;
......@@ -134,6 +134,10 @@ void cudaPreliminaryProcess(size_t populationSize, dim3* dimBlock, dim3* dimGrid
\INSERT_BOUND_CHECKING
void evale_pop_chunk(CIndividual** population, int popSize){
\INSTEAD_EVAL_FUNCTION
}
void EASEAInit(int argc, char** argv){
\INSERT_INIT_FCT_CALL
cma = new CCmaesCuda(setVariable("nbOffspring",\OFF_SIZE), setVariable("popSize",\POP_SIZE), \PROBLEM_DIM);
......@@ -145,7 +149,7 @@ void EASEAFinal(CPopulation* pop){
}
void AESAEBeginningGenerationFunction(CEvolutionaryAlgorithm* evolutionaryAlgorithm){
if(*EZ_current_generation==0){
if(*EZ_current_generation==1){
cudaPreliminaryProcess(((PopulationImpl*)evolutionaryAlgorithm->population)->offspringPopulationSize,&dimBlockcuda, &dimGridcuda, &d_offspringPopulationcuda,&d_fitnessescuda);
}
cma->cmaes_UpdateEigensystem(0);
......@@ -232,7 +236,7 @@ CIndividual* IndividualImpl::crossover(CIndividual** ps){
IndividualImpl** tmp = (IndividualImpl**)ps;
IndividualImpl parent1(*this);
IndividualImpl parent2(*tmp[0]);
IndividualImpl child1(*this);
IndividualImpl child(*this);
////DEBUG_PRT("Xover");
/* cout << "p1 : " << parent1 << endl; */
......@@ -243,9 +247,9 @@ CIndividual* IndividualImpl::crossover(CIndividual** ps){
for(int i=0; i<\PROBLEM_DIM; ++i)
cma->rgdTmp[i] = (float)(cma->rgD[i] * cma->alea.alea_Gauss());
child1.valid = false;
/* cout << "child1 : " << child1 << endl; */
return new IndividualImpl(child1);
child.valid = false;
/* cout << "child : " << child << endl; */
return new IndividualImpl(child);
}
......@@ -419,20 +423,21 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
controlCStopingCriterion = new CControlCStopingCriterion();
timeCriterion = new CTimeCriterion(setVariable("timeLimit",\TIME_LIMIT));
this->optimise = 0;
seed = setVariable("seed",(int)time(0));
globalRandomGenerator = new CRandomGenerator(seed);
this->randomGenerator = globalRandomGenerator;
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCVSFile = setVariable("generateCSVFile",\GENERATE_CVS_FILE);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
this->printFinalPopulation = setVariable("printFinalPopulation",0);
this->outputFilename = (char*)"EASEA.dat";
this->outputFilename = (char*)"EASEA";
this->plotOutputFilename = (char*)"EASEA.png";
}
......@@ -621,7 +626,7 @@ $(BIN):$(OBJ)
$(NVCC) $(NVCCFLAGS) -o $@ $< -c -DTIMING $(CPPFLAGS) -g -Xcompiler -Wall
easeaclean: clean
rm -f Makefile EASEA.prm $(SRC) $(HDR) EASEA.mak $(CUDA_SRC) *.linkinfo EASEA.png EASEA.dat EASEA.vcproj
rm -f Makefile EASEA.prm $(SRC) $(HDR) EASEA.mak $(CUDA_SRC) *.linkinfo EASEA.png EASEA.dat EASEA.vcproj EASEA.plot EASEA.r EASEA.csv
clean:
rm -f $(OBJ) $(BIN)
......@@ -796,7 +801,7 @@ clean:
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--printInitialPopulation=0 #Print initial population
--printFinalPopulation=0 #Print final population
--generateCSVFile=\GENERATE_CVS_FILE
--generateCSVFile=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
......
......@@ -80,7 +80,7 @@ int main(int argc, char** argv){
using namespace std;
#include "EASEAIndividual.hpp"
bool INSTEAD_EVAL_STEP = false;
CRandomGenerator* globalRandomGenerator;
......@@ -127,6 +127,10 @@ void cudaPreliminaryProcess(size_t populationSize, dim3* dimBlock, dim3* dimGrid
\INSERT_BOUND_CHECKING
void evale_pop_chunk(CIndividual** population, int popSize){
\INSTEAD_EVAL_FUNCTION
}
void EASEAInit(int argc, char** argv){
\INSERT_INIT_FCT_CALL
}
......@@ -136,7 +140,7 @@ void EASEAFinal(CPopulation* pop){
}
void AESAEBeginningGenerationFunction(CEvolutionaryAlgorithm* evolutionaryAlgorithm){
if(*EZ_current_generation==0){
if(*EZ_current_generation==1){
cudaPreliminaryProcess(((PopulationImpl*)evolutionaryAlgorithm->population)->offspringPopulationSize,&dimBlockcuda, &dimGridcuda, &d_offspringPopulationcuda,&d_fitnessescuda);
}
\INSERT_BEGIN_GENERATION_FUNCTION
......@@ -408,20 +412,21 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
controlCStopingCriterion = new CControlCStopingCriterion();
timeCriterion = new CTimeCriterion(setVariable("timeLimit",\TIME_LIMIT));
this->optimise=0;
seed = setVariable("seed",(int)time(0));
globalRandomGenerator = new CRandomGenerator(seed);
this->randomGenerator = globalRandomGenerator;
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCVSFile = setVariable("generateCSVFile",\GENERATE_CVS_FILE);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
this->printFinalPopulation = setVariable("printFinalPopulation",0);
this->outputFilename = (char*)"EASEA.dat";
this->outputFilename = (char*)"EASEA";
this->plotOutputFilename = (char*)"EASEA.png";
}
......@@ -791,7 +796,7 @@ clean:
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--printInitialPopulation=0 #Print initial population
--printFinalPopulation=0 #Print final population
--generateCSVFile=\GENERATE_CVS_FILE
--generateCSVFile=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
......
......@@ -280,6 +280,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
controlCStopingCriterion = new CControlCStopingCriterion();
timeCriterion = new CTimeCriterion(setVariable("timeLimit",\TIME_LIMIT));
this->optimise = 0;
seed = setVariable("seed",(int)time(0));
globalRandomGenerator = new CRandomGenerator(seed);
......
......@@ -82,7 +82,7 @@ int main(int argc, char** argv){
using namespace std;
#include "EASEAIndividual.hpp"
bool INSTEAD_EVAL_STEP = false;
CRandomGenerator* globalRandomGenerator;
extern CEvolutionaryAlgorithm* EA;
......@@ -100,6 +100,10 @@ extern CEvolutionaryAlgorithm* EA;
\INSERT_BOUND_CHECKING
void evale_pop_chunk(CIndividual** population, int popSize){
\INSTEAD_EVAL_FUNCTION
}
void EASEAInit(int argc, char** argv){
\INSERT_INIT_FCT_CALL
}
......@@ -209,9 +213,6 @@ size_t IndividualImpl::mutate( float pMutationPerGene ){
\INSERT_MUTATOR
}
void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->minimizing = \MINIMAXI;
......@@ -275,14 +276,15 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
generationalCriterion = new CGenerationalCriterion(setVariable("nbGen",(int)\NB_GEN));
controlCStopingCriterion = new CControlCStopingCriterion();
timeCriterion = new CTimeCriterion(setVariable("timeLimit",\TIME_LIMIT));
this->optimise = 0;
seed = setVariable("seed",(int)time(0));
globalRandomGenerator = new CRandomGenerator(seed);
this->randomGenerator = globalRandomGenerator;
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCVSFile = setVariable("generateCSVFile",\GENERATE_CVS_FILE);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
......@@ -593,7 +595,7 @@ easeaclean:
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--printInitialPopulation=0 #Print initial population
--printFinalPopulation=0 #Print final population
--generateCSV=\GENERATE_CVS_FILE