Commit 83315e19 authored by maitre's avatar maitre

MUT_PROB ok. It doesn't work in the initializer function currently

parent 97534812
......@@ -1161,9 +1161,6 @@ exponent ([Ee][+-]?[0-9]+)
<COPY_FINALIZATION_FUNCTION>.|\n {}
<COPY_END_GENERATION_FUNCTION>"\\At"[ \t\n]+"the"[ \t\n]+"end"[ \t\n]+"of"[ \t\n]+"each"[ \t\n]+"generation"[ \t\n]+"function"[ \t\n]*":" {
DEBUG_PRT("at each end");
if( (TARGET==CUDA || TARGET==STD) ){
......@@ -1292,8 +1289,16 @@ exponent ([Ee][+-]?[0-9]+)
<COPY>"POP_SIZE"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"POP_SIZE");
else fprintf(fpOutputFile,"EZ_POP_SIZE");} // local genome name
<COPY>"MUT_PROB" |
<COPY>"MUT_PROB"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"MUT_PROB");
else fprintf(fpOutputFile,"EZ_MUT_PROB");} // local genome name
<COPY>"MUT_PROB"/[ \t\n]*"==" {
if (bDoubleQuotes)
fprintf(fpOutputFile,"MUT_PROB");
else
if( TARGET==STD || TARGET==CUDA){
fprintf(fpOutputFile,"(*pEZ_MUT_PROB)");
}
else fprintf(fpOutputFile,"EZ_MUT_PROB");
} // local genome name
<COPY>"XOVER_PROB" |
<COPY>"XOVER_PROB"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"XOVER_PROB");
else fprintf(fpOutputFile,"EZ_XOVER_PROB");} // local genome name
......@@ -1317,7 +1322,11 @@ exponent ([Ee][+-]?[0-9]+)
<COPY>"currentGeneration"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The current generation number cannot be changed (not an l-value).\n",sEZ_FILE_NAME,yylineno); exit(1);}
<COPY>"NB_GEN"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The number of generations can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
<COPY>"POP_SIZE"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The size of the population can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
<COPY>"MUT_PROB"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The mutation probability can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
<COPY>"MUT_PROB"[ \t\n]*"=" {
fprintf(stderr,"\n%s - Error line %d: The mutation probability can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno);
exit (1);
}
<COPY>"XOVER_PROB"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The crossover proability can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
<COPY>"REPL_PERC"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The replacement percentage can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
<COPY>"MINIMISE"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The evaluation goal can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
......@@ -1585,11 +1594,16 @@ exponent ([Ee][+-]?[0-9]+)
case EO : fprintf(fpOutputFile,"EZ_POP_SIZE");
}} // local genome name
<COPY_USER_GENERATION>"MUT_PROB" |
<COPY_USER_GENERATION>"MUT_PROB"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"MUT_PROB");
<COPY_USER_GENERATION>"MUT_PROB"/[ \t\n]*"==" {
if (bDoubleQuotes) fprintf(fpOutputFile,"MUT_PROB");
else switch (TARGET) {
case GALIB : fprintf(fpOutputFile,"g.pMutation()"); break;
case EO : fprintf(fpOutputFile,"EZ_MUT_PROB");
}} // local genome name
case EO : fprintf(fpOutputFile,"EZ_MUT_PROB"); break;
case STD:
case CUDA:
fprintf(fpOutputFile,"(*pEZ_MUT_PROB)");
}
} // local genome name
<COPY_USER_GENERATION>"XOVER_PROB" |
<COPY_USER_GENERATION>"XOVER_PROB"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"XOVER_PROB");
else switch (TARGET) {
......@@ -1639,8 +1653,13 @@ exponent ([Ee][+-]?[0-9]+)
else switch (TARGET) {
case GALIB : fprintf(fpOutputFile,"g.pMutation((EZ_MUT_PROB=");
bWaitingForSemiColon=1; break;
case EO : fprintf(fpOutputFile,"EZ_MUT_PROB=");
}} // local genome name
case EO : fprintf(fpOutputFile,"EZ_MUT_PROB="); break;
case CUDA:
case STD:
fprintf(fpOutputFile,"(*pEZ_MUT_PROB)=");
break;
}
} // local genome name
<COPY_USER_GENERATION>"XOVER_PROB"[ \t\n]*"=" {if (bDoubleQuotes) fprintf(fpOutputFile,"%s",yytext);
else switch (TARGET) {
case GALIB :fprintf(fpOutputFile,"g.pCrossover((EZ_XOVER_PROB=");
......@@ -1779,8 +1798,12 @@ exponent ([Ee][+-]?[0-9]+)
<COPY_USER_FUNCTION>"POP_SIZE"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"POP_SIZE");
else fprintf(fpOutputFile,"EZ_POP_SIZE");} // local genome name
<COPY_USER_FUNCTION>"MUT_PROB" |
<COPY_USER_FUNCTION>"MUT_PROB"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"MUT_PROB");
else fprintf(fpOutputFile,"EZ_MUT_PROB");} // local genome name
<COPY_USER_FUNCTION>"MUT_PROB"/[ \t\n]*"==" {
if (bDoubleQuotes) fprintf(fpOutputFile,"MUT_PROB");
else if( TARGET==CUDA || TARGET==STD)
fprintf(fpOutputFile,"(*pEZ_MUT_PROB)");
else fprintf(fpOutputFile,"EZ_MUT_PROB");
} // local genome name
<COPY_USER_FUNCTION>"XOVER_PROB" |
<COPY_USER_FUNCTION>"XOVER_PROB"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"XOVER_PROB");
else fprintf(fpOutputFile,"EZ_XOVER_PROB");} // local genome name
......@@ -1791,7 +1814,11 @@ exponent ([Ee][+-]?[0-9]+)
<COPY_USER_FUNCTION>"currentGeneration"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The current generation number cannot be changed (not an l-value).\n",sEZ_FILE_NAME,yylineno); exit(1);}
<COPY_USER_FUNCTION>"NB_GEN"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The number of generations can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
<COPY_USER_FUNCTION>"POP_SIZE"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The size of the population can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
<COPY_USER_FUNCTION>"MUT_PROB"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The mutation probability can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
<COPY_USER_FUNCTION>"MUT_PROB"[ \t\n]*"=" {
fprintf(stderr,"\n%s - Error line %d: The mutation probability can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno);
exit (1);
}
<COPY_USER_FUNCTION>"XOVER_PROB"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The crossover proability can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
<COPY_USER_FUNCTION>"REPL_PERC"[ \t\n]*"=" {fprintf(stderr,"\n%s - Error line %d: The replacement percentage can only be changed within the generation function.\n",sEZ_FILE_NAME,yylineno); exit (1);}
<COPY_USER_FUNCTION>"false" {if (TARGET==GALIB) fprintf(fpOutputFile,"gaFalse");
......
......@@ -119,6 +119,8 @@ inline float Schwefel(float x[SIZE], int n)
__device__ __host__ inline float Weierstrass(float x[SIZE], int n) // Weierstrass multimidmensionnel h = 0.25
{
cout << MUT_PROB << endl;
float res = 0.;
float val[SIZE];
float b=2.;
......@@ -198,6 +200,11 @@ GenomeClass {
}
\end
\At the end of each generation function:
\end
\GenomeClass::mutator : // Must return the number of mutations
int NbMut=0;
float pond = 1./sqrt((float)n);
......@@ -218,6 +225,7 @@ return NbMut;
\GenomeClass::evaluator : // Returns the score
float Score= 0.0;
float Point[SIZE];
if(0) return 0;
for (int i=0; i<N_LIM; i++) Point[i] = Genome.x[i];
Score= Weierstrass(Point, N_LIM);
return Score;
......
......@@ -4,11 +4,18 @@
*/
\ANALYSE_PARAMETERS
using namespace std;
#include <stdlib.h>
/** Global variables for the whole algorithm */
float* pEZ_MUT_PROB = NULL;
#include <iostream>
#include "EASEATools.hpp"
#include "EASEAIndividual.hpp"
#include <time.h>
RandomGenerator* globalRandomGenerator;
......@@ -74,7 +81,6 @@ int main(int argc, char** argv){
#include <sys/time.h>
#define STD_TPL
extern RandomGenerator* globalRandomGenerator;
\INSERT_USER_DECLARATIONS
......@@ -278,8 +284,7 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
\INSERT_BOUND_CHECKING_FCT_CALL
population->evaluateOffspringPopulation();
\INSERT_END_GEN_FCT_CALL
\INSERT_END_GEN_FCT_CALL
#if \IS_PARENT_REDUCTION
population->reduceParentPopulation(\SURV_PAR_SIZE);
......@@ -703,6 +708,7 @@ Population::Population(size_t parentPopulationSize, size_t offspringPopulationSi
this->pCrossover = pCrossover;
this->pMutation = pMutation;
pEZ_MUT_PROB = &this->pMutation;
this->pMutationPerGene = pMutationPerGene;
this->rg = rg;
......@@ -1255,6 +1261,8 @@ string setVariable(const string optionName, string defaultValue){
#include <boost/archive/text_iarchive.hpp> //for serialization (loading)
#include <boost/serialization/vector.hpp>
extern float* pEZ_MUT_PROB;
class EvolutionaryAlgorithm;
class Individual;
class Population;
......
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