Commit 4aba409f authored by maitre's avatar maitre

merge test

parent ff7c803e
......@@ -72,7 +72,7 @@ Centre de Math
bool bWaitingForSemiColon,bFinishNB_GEN,bFinishMINIMISE,bFinishMINIMIZE,bGenerationFunction;
bool bCatchNextSemiColon,bWaitingToClosePopulation, bMethodsInGenome, bFinalizationFunction;
bool bWithinCUDA_Initializer, bWithinMAKEFILEOPTION, bWithinCUDA_Evaluator, bBoundCheckingFunction;
bool bIsParentReduce, bIsOffspringReduce;
bool bIsParentReduce, bIsOffspringReduce, bEndGeneration, bBeginGeneration;
CSymbol *pASymbol;
public:
......@@ -89,6 +89,7 @@ Centre de Math
bCatchNextSemiColon,bWaitingToClosePopulation=bMethodsInGenome=0;
bBoundCheckingFunction = bWithinCUDA_Initializer=bWithinMAKEFILEOPTION =bWithinCUDA_Evaluator=0;
bIsParentReduce = bIsOffspringReduce = false;
bEndGeneration = bBeginGeneration = false;
}
// macros
......@@ -156,6 +157,26 @@ exponent ([Ee][+-]?[0-9]+)
BEGIN COPY_GENERATION_FUNCTION;
}
<TEMPLATE_ANALYSIS>"\\INSERT_BEGIN_GENERATION_FUNCTION" {
if (bVERBOSE) printf ("Inserting at the begining of each generation function.\n");
yyreset();
yyin = fpGenomeFile;
BEGIN COPY_GENERATION_FUNCTION;
}
<TEMPLATE_ANALYSIS>"\\INSERT_END_GENERATION_FUNCTION" {
if (bVERBOSE) printf ("Inserting at the end of each generation function.\n");
yyreset();
yyin = fpGenomeFile;
bEndGeneration = true;
bBeginGeneration = false;
BEGIN COPY_GENERATION_FUNCTION;
}
<TEMPLATE_ANALYSIS>"\\INSERT_BOUND_CHECKING" {
if (bVERBOSE) printf ("Inserting Bound Checking function.\n");
yyreset();
......@@ -1097,7 +1118,7 @@ exponent ([Ee][+-]?[0-9]+)
fprintf (fpOutputFile,"// Finalization function\nvoid EASEAFinalization(Population* population){");
break;
default:
fprintf (stderr," Warning this template doesn't support finalization function ");
fprintf (stderr," Error this template doesn't support finalization function ");
return -1;
}
bFunction=1; bFinalizationFunction=1;
......@@ -1115,18 +1136,30 @@ exponent ([Ee][+-]?[0-9]+)
<COPY_FINALIZATION_FUNCTION>.|\n {}
<COPY_GENERATION_FUNCTION>"\\At"[ \t\n]+"the"[ \t\n]+"end"[ \t\n]+"of"[ \t\n]+"each"[ \t\n]+"generation"[ \t\n]+"function"[ \t\n]*":" {
if( (TARGET==CUDA || TARGET==STD)&& bEndGeneration ){
fprintf (fpOutputFile,"// Function called at each new generation\nvoid EASEAEndGenerationFunction(EvolutionaryAlgorithm* evolutionaryAlgorithm){\n");
bFunction=1; bGenerationFunction=1;
bEndGeneration = 0;
BEGIN COPY_USER_GENERATION;
}
}
<COPY_GENERATION_FUNCTION>"\\At"[ \t\n]+"each"[ \t\n]+"new"[ \t\n]+"generation"[ \t\n]*":" {
if( TARGET==GALIB){
fprintf (fpOutputFile,"// Function called at each new generation\n\nvoid EASEAGenerationFunction(GAGeneticAlgorithm & g){\n");
fprintf(fpOutputFile," const GAPopulation *pPopulation;\n",sPROJECT_NAME);
fprintf(fpOutputFile," pPopulation=&(g.population()); // to circumvent a bug in GALib\n",sPROJECT_NAME);
bFunction=1; bGenerationFunction=1;
BEGIN COPY_USER_GENERATION;
}
else if(TARGET==CUDA || TARGET==STD){
fprintf (fpOutputFile,"// Function called at each new generation\nvoid EASEAGenerationFunction(EvolutionaryAlgorithm* evolutionaryAlgorithm){\n");
bFunction=1; bGenerationFunction=1;
if( !bEndGeneration && !bBeginGeneration )
BEGIN COPY_USER_GENERATION;
}
bFunction=1; bGenerationFunction=1;
BEGIN COPY_USER_GENERATION;
}
<COPY_GENERATION_FUNCTION><<EOF>> {
bGenerationFunction=0; // No Generation function was found in the .ez file
......
......@@ -227,6 +227,22 @@ return NbMut;
CPPFLAGS+=
\end
\At the beginning of each generation function:
if (NB_GEN-currentGeneration==10) pMutPerGene=0.1;
\end
\At the end of each generation function:
if (NB_GEN-currentGeneration==10) pMutPerGene=0.1;
\end
\At each new generation :
cout << "A new generation is born" << endl;
\end
\Default run parameters : // Please let the parameters appear in this order
Number of generations : 100 // NB_GEN
Mutation probability : 1 // MUT_PROB
......
......@@ -85,6 +85,10 @@ extern RandomGenerator* globalRandomGenerator;
\INSERT_INITIALISATION_FUNCTION
\INSERT_FINALIZATION_FUNCTION
\INSERT_GENERATION_FUNCTION
\INSERT_BEGIN_GENERATION_FUNCTION
\INSERT_END_GENERATION_FUNCTION
\INSERT_BOUND_CHECKING
void EASEAFinal(Population* pop){
......@@ -275,6 +279,8 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
population->evaluateOffspringPopulation();
\INSERT_GEN_FCT_CALL
#if \IS_PARENT_REDUCTION
population->reduceParentPopulation(\SURV_PAR_SIZE);
......@@ -287,7 +293,6 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
population->reduceTotalPopulation();
\INSERT_GEN_FCT_CALL
showPopulationStats(begin);
currentGeneration += 1;
......
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