Commit 3185e50a authored by Frederic's avatar Frederic

NB_GEN

parent 430143be
......@@ -1289,7 +1289,7 @@ exponent ([Ee][+-]?[0-9]+)
}} // local genome name
<COPY>"NB_GEN" |
<COPY>"NB_GEN"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"NB_GEN");
else fprintf(fpOutputFile,"EZ_NB_GEN");} // local genome name
else fprintf(fpOutputFile,"(*EZ_NB_GEN)");} // local genome name
<COPY>"POP_SIZE" |
<COPY>"POP_SIZE"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"POP_SIZE");
else fprintf(fpOutputFile,"EZ_POP_SIZE");} // local genome name
......@@ -1589,6 +1589,10 @@ exponent ([Ee][+-]?[0-9]+)
else switch (TARGET) {
case GALIB : fprintf(fpOutputFile,"g.nGenerations()"); break;
case EO : fprintf(fpOutputFile,"ptEZ_NbGen.value()");
case STD :
case CUDA :
fprintf(fpOutputFile,"(*EZ_NB_GEN)");
break;
}} // local genome name
<COPY_USER_GENERATION>"POP_SIZE" |
<COPY_USER_GENERATION>"POP_SIZE"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"POP_SIZE");
......@@ -1653,6 +1657,10 @@ exponent ([Ee][+-]?[0-9]+)
bWaitingForSemiColon=bFinishNB_GEN=1; break;
case EO : fprintf(fpOutputFile,"ptEZ_NbGen.value((EZ_NB_GEN=)");
bWaitingForSemiColon=1;
case CUDA :
case STD :
fprintf(fpOutputFile,"(*EZ_NB_GEN)=");
break;
}} // local genome name
<COPY_USER_GENERATION>"POP_SIZE"[ \t\n]*"=" {if (bDoubleQuotes) fprintf(fpOutputFile,"%s",yytext);
else switch (TARGET) {
......@@ -1730,7 +1738,7 @@ exponent ([Ee][+-]?[0-9]+)
if (bFinishMINIMISE) {fprintf(fpOutputFile,");\n if (MINIMISE) g.minimize() else g.maximize();\n"); bFinishMINIMISE=0;}
if (bFinishMINIMIZE) {fprintf(fpOutputFile,");\n if (MINIMIZE) g.minimize() else g.maximize();\n"); bFinishMINIMISE=0;}
if ((bFinishNB_GEN)&&(OPERATING_SYSTEM==UNIX))
{fprintf(fpOutputFile,"));\n if ( (EZ_daFITNESS = (double *) realloc(EZ_daFITNESS, (EZ_NB_GEN +1)* sizeof (double) )) == NULL){\n");
{fprintf(fpOutputFile,"));\n if ( (EZ_daFITNESS = (double *) realloc(EZ_daFITNESS, ((*EZ_NB_GEN) +1)* sizeof (double) )) == NULL){\n");
fprintf(fpOutputFile," fprintf(stderr,\"Not enough memory... bailing out.\");\n exit(1);");}
else if (bFinishNB_GEN) {fprintf(fpOutputFile,"));"); bFinishNB_GEN=0;}
else fprintf(fpOutputFile,"));");
......@@ -1814,7 +1822,7 @@ exponent ([Ee][+-]?[0-9]+)
}} // local genome name
<COPY_USER_FUNCTION>"NB_GEN" |
<COPY_USER_FUNCTION>"NB_GEN"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"NB_GEN");
else fprintf(fpOutputFile,"EZ_NB_GEN");} // local genome name
else fprintf(fpOutputFile,"(*EZ_NB_GEN)");} // local genome name
<COPY_USER_FUNCTION>"POP_SIZE" |
<COPY_USER_FUNCTION>"POP_SIZE"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"POP_SIZE");
else fprintf(fpOutputFile,"EZ_POP_SIZE");} // local genome name
......
......@@ -10,7 +10,7 @@ using namespace std;
#include <time.h>
RandomGenerator* globalRandomGenerator;
size_t *EZ_NB_GEN;
int main(int argc, char** argv){
......@@ -48,6 +48,7 @@ int main(int argc, char** argv){
StoppingCriterion* sc = new GenerationalCriterion(&ea,setVariable("nbGen",\NB_GEN));
ea.addStoppingCriterion(sc);
EZ_NB_GEN=((GenerationalCriterion*)ea.stoppingCriteria[0])->getGenerationalLimit();
Population* pop = ea.getPopulation();
......@@ -726,6 +727,8 @@ void cmaes_exit(CMA *t)
\INSERT_INITIALISATION_FUNCTION
\INSERT_FINALIZATION_FUNCTION
\INSERT_GENERATION_FUNCTION
\INSERT_BEGIN_GENERATION_FUNCTION
\INSERT_END_GENERATION_FUNCTION
\INSERT_BOUND_CHECKING
void EASEAFinal(Population* pop){
......@@ -932,13 +935,13 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
while( this->allCriteria() == false ){
cmaes_UpdateEigensystem(&cma, 0);
TestMinStdDevs(&cma);
\INSERT_BEGINNING_GEN_FCT_CALL
population->produceOffspringPopulation();
\INSERT_BOUND_CHECKING_FCT_CALL
population->evaluateOffspringPopulation();
\INSERT_END_GEN_FCT_CALL
#if \IS_PARENT_REDUCTION
population->reduceParentPopulation(\SURV_PAR_SIZE);
......@@ -1380,6 +1383,10 @@ bool GenerationalCriterion::reached(){
else return false;
}
size_t* GenerationalCriterion::getGenerationalLimit(){
return &this->generationalLimit;
}
/* ****************************************
Population class
......@@ -1971,6 +1978,8 @@ class EvolutionaryAlgorithm;
class Individual;
class Population;
extern size_t *EZ_NB_GEN;
#define EZ_MINIMIZE \MINIMAXI
#define EZ_MINIMISE \MINIMAXI
#define EZ_MAXIMIZE !\MINIMAXI
......@@ -2008,7 +2017,7 @@ class GenerationalCriterion : public StoppingCriterion {
public:
virtual bool reached();
GenerationalCriterion(EvolutionaryAlgorithm* ea, size_t generationalLimit);
size_t* getGenerationalLimit();
};
......
......@@ -10,7 +10,7 @@ using namespace std;
#include <time.h>
RandomGenerator* globalRandomGenerator;
size_t *EZ_NB_GEN;
int main(int argc, char** argv){
......@@ -39,7 +39,7 @@ int main(int argc, char** argv){
string outputfile = setVariable("outputfile","");
string inputfile = setVariable("inputfile","");
EASEAInit(argc,argv);
EvolutionaryAlgorithm ea(parentPopulationSize,offspringPopulationSize,selectionPressure,replacementPressure,parentReductionPressure,offspringReductionPressure,
......@@ -48,6 +48,9 @@ int main(int argc, char** argv){
StoppingCriterion* sc = new GenerationalCriterion(&ea,setVariable("nbGen",\NB_GEN));
ea.addStoppingCriterion(sc);
EZ_NB_GEN=((GenerationalCriterion*)ea.stoppingCriteria[0])->getGenerationalLimit();
Population* pop = ea.getPopulation();
......@@ -668,6 +671,9 @@ bool GenerationalCriterion::reached(){
else return false;
}
size_t* GenerationalCriterion::getGenerationalLimit(){
return &(this->generationalLimit);
}
/* ****************************************
Population class
......@@ -1259,10 +1265,12 @@ class EvolutionaryAlgorithm;
class Individual;
class Population;
extern size_t *EZ_NB_GEN;
#define EZ_MINIMIZE \MINIMAXI
#define EZ_MINIMISE \MINIMAXI
#define EZ_MAXIMIZE !\MINIMAXI
#define EZ_MAXIMIZE !\MINIMAXI
#define EZ_MAXIMISE !\MINIMAXI
#ifdef DEBUG
#define DEBUG_PRT(format, args...) fprintf (stdout,"***DBG*** %s-%d: "format"\n",__FILE__,__LINE__,##args)
......@@ -1296,7 +1304,7 @@ class GenerationalCriterion : public StoppingCriterion {
public:
virtual bool reached();
GenerationalCriterion(EvolutionaryAlgorithm* ea, size_t generationalLimit);
size_t *getGenerationalLimit();
};
......
......@@ -79,6 +79,8 @@ extern RandomGenerator* globalRandomGenerator;
\INSERT_INITIALISATION_FUNCTION
\INSERT_FINALIZATION_FUNCTION
\INSERT_GENERATION_FUNCTION
\INSERT_BEGIN_GENERATION_FUNCTION
\INSERT_END_GENERATION_FUNCTION
void EASEAFinal(Population* pop){
\INSERT_FINALIZATION_FCT_CALL
......@@ -263,12 +265,15 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
gettimeofday(&begin,NULL);
while( this->allCriteria() == false ){
\INSERT_BEGINNING_GEN_FCT_CALL
population->produceOffspringPopulation();
population->evaluateOffspringPopulation();
population->evaluateMoPopulation();
\INSERT_END_GEN_FCT_CALL
if(reduceParents)
population->reduceParentPopulation(reduceParents);
......
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