Commit 645844ef authored by Frederic's avatar Frederic

currentGeneration

parent 3ca1ba93
...@@ -1282,7 +1282,8 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1282,7 +1282,8 @@ exponent ([Ee][+-]?[0-9]+)
<COPY>"currentGeneration"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"currentGeneration"); <COPY>"currentGeneration"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"currentGeneration");
else switch (TARGET) { else switch (TARGET) {
case GALIB : fprintf(fpOutputFile,"EZ_currentGeneration"); break; case GALIB : fprintf(fpOutputFile,"EZ_currentGeneration"); break;
case EO : fprintf(fpOutputFile,"generationCounter.value()"); case EO : fprintf(fpOutputFile,"generationCounter.value()"); break;
case STD : fprintf(fpOutputFile,"(*EZ_current_generation)"); break;
}} // local genome name }} // local genome name
<COPY>"NB_GEN" | <COPY>"NB_GEN" |
<COPY>"NB_GEN"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"NB_GEN"); <COPY>"NB_GEN"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"NB_GEN");
...@@ -1595,7 +1596,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1595,7 +1596,7 @@ exponent ([Ee][+-]?[0-9]+)
fprintf(fpOutputFile,"generationCounter.value()"); break; fprintf(fpOutputFile,"generationCounter.value()"); break;
case CUDA: case CUDA:
case STD: case STD:
fprintf(fpOutputFile,"(evolutionaryAlgorithm->getCurrentGeneration())"); fprintf(fpOutputFile,"(*EZ_current_generation)");
break; break;
}} // local genome name }} // local genome name
<COPY_USER_GENERATION>"NB_GEN" | <COPY_USER_GENERATION>"NB_GEN" |
...@@ -1851,7 +1852,8 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1851,7 +1852,8 @@ exponent ([Ee][+-]?[0-9]+)
<COPY_USER_FUNCTION>"currentGeneration"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"currentGeneration"); <COPY_USER_FUNCTION>"currentGeneration"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"currentGeneration");
else switch (TARGET) { else switch (TARGET) {
case GALIB : fprintf(fpOutputFile,"EZ_currentGeneration"); break; case GALIB : fprintf(fpOutputFile,"EZ_currentGeneration"); break;
case EO : fprintf(fpOutputFile,"generationCounter.value()"); case EO : fprintf(fpOutputFile,"generationCounter.value()"); break;
case STD : fprintf(fpOutputFile,"(*EZ_current_generation)"); break;
}} // local genome name }} // local genome name
<COPY_USER_FUNCTION>"NB_GEN" | <COPY_USER_FUNCTION>"NB_GEN" |
<COPY_USER_FUNCTION>"NB_GEN"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"NB_GEN"); <COPY_USER_FUNCTION>"NB_GEN"/[ \t\n]*"==" {if (bDoubleQuotes) fprintf(fpOutputFile,"NB_GEN");
......
...@@ -11,6 +11,7 @@ using namespace std; ...@@ -11,6 +11,7 @@ using namespace std;
RandomGenerator* globalRandomGenerator; RandomGenerator* globalRandomGenerator;
size_t *EZ_NB_GEN; size_t *EZ_NB_GEN;
size_t *EZ_current_generation;
int main(int argc, char** argv){ int main(int argc, char** argv){
...@@ -22,6 +23,8 @@ int main(int argc, char** argv){ ...@@ -22,6 +23,8 @@ int main(int argc, char** argv){
float pCrossover = \XOVER_PROB; float pCrossover = \XOVER_PROB;
float pMutation = \MUT_PROB; float pMutation = \MUT_PROB;
float pMutationPerGene = 0.05; float pMutationPerGene = 0.05;
EZ_NB_GEN=(size_t*)setVariable("nbGen",\NB_GEN);
EZ_current_generation=0;
time_t seed = setVariable("seed",time(0)); time_t seed = setVariable("seed",time(0));
globalRandomGenerator = new RandomGenerator(seed); globalRandomGenerator = new RandomGenerator(seed);
...@@ -48,6 +51,7 @@ int main(int argc, char** argv){ ...@@ -48,6 +51,7 @@ int main(int argc, char** argv){
StoppingCriterion* sc = new GenerationalCriterion(&ea,setVariable("nbGen",\NB_GEN)); StoppingCriterion* sc = new GenerationalCriterion(&ea,setVariable("nbGen",\NB_GEN));
ea.addStoppingCriterion(sc); ea.addStoppingCriterion(sc);
EZ_current_generation=&(ea.currentGeneration);
EZ_NB_GEN=((GenerationalCriterion*)ea.stoppingCriteria[0])->getGenerationalLimit(); EZ_NB_GEN=((GenerationalCriterion*)ea.stoppingCriteria[0])->getGenerationalLimit();
Population* pop = ea.getPopulation(); Population* pop = ea.getPopulation();
...@@ -1979,6 +1983,7 @@ class Individual; ...@@ -1979,6 +1983,7 @@ class Individual;
class Population; class Population;
extern size_t *EZ_NB_GEN; extern size_t *EZ_NB_GEN;
extern size_t *EZ_current_generation;
#define EZ_MINIMIZE \MINIMAXI #define EZ_MINIMIZE \MINIMAXI
#define EZ_MINIMISE \MINIMAXI #define EZ_MINIMISE \MINIMAXI
......
...@@ -9,6 +9,8 @@ using namespace std; ...@@ -9,6 +9,8 @@ using namespace std;
/** Global variables for the whole algorithm */ /** Global variables for the whole algorithm */
float* pEZ_MUT_PROB = NULL; float* pEZ_MUT_PROB = NULL;
float* pEZ_XOVER_PROB = NULL; float* pEZ_XOVER_PROB = NULL;
size_t *EZ_NB_GEN;
size_t *EZ_current_generation;
#include <iostream> #include <iostream>
#include "EASEATools.hpp" #include "EASEATools.hpp"
...@@ -18,7 +20,6 @@ float* pEZ_XOVER_PROB = NULL; ...@@ -18,7 +20,6 @@ float* pEZ_XOVER_PROB = NULL;
RandomGenerator* globalRandomGenerator; RandomGenerator* globalRandomGenerator;
size_t *EZ_NB_GEN;
int main(int argc, char** argv){ int main(int argc, char** argv){
...@@ -33,6 +34,8 @@ int main(int argc, char** argv){ ...@@ -33,6 +34,8 @@ int main(int argc, char** argv){
pEZ_MUT_PROB = &pMutationPerGene; pEZ_MUT_PROB = &pMutationPerGene;
pEZ_XOVER_PROB = &pCrossover; pEZ_XOVER_PROB = &pCrossover;
EZ_NB_GEN = (size_t*)setVariable("nbGen",\NB_GEN);
EZ_current_generation=0;
time_t seed = setVariable("seed",time(0)); time_t seed = setVariable("seed",time(0));
globalRandomGenerator = new RandomGenerator(seed); globalRandomGenerator = new RandomGenerator(seed);
...@@ -61,7 +64,8 @@ int main(int argc, char** argv){ ...@@ -61,7 +64,8 @@ int main(int argc, char** argv){
ea.addStoppingCriterion(sc); ea.addStoppingCriterion(sc);
EZ_NB_GEN=((GenerationalCriterion*)ea.stoppingCriteria[0])->getGenerationalLimit(); EZ_NB_GEN=((GenerationalCriterion*)ea.stoppingCriteria[0])->getGenerationalLimit();
EZ_current_generation=&(ea.currentGeneration);
Population* pop = ea.getPopulation(); Population* pop = ea.getPopulation();
...@@ -1280,6 +1284,7 @@ class Individual; ...@@ -1280,6 +1284,7 @@ class Individual;
class Population; class Population;
extern size_t *EZ_NB_GEN; extern size_t *EZ_NB_GEN;
extern size_t *EZ_current_generation;
#define EZ_MINIMIZE \MINIMAXI #define EZ_MINIMIZE \MINIMAXI
#define EZ_MINIMISE \MINIMAXI #define EZ_MINIMISE \MINIMAXI
......
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