Commit 4aba409f authored by maitre's avatar maitre
Browse files

merge test

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