Commit ab1c5298 authored by maitre's avatar maitre

pPopulation

parent 3ca1ba93
......@@ -1580,11 +1580,18 @@ exponent ([Ee][+-]?[0-9]+)
break;
case CUDA:
case STD:
fprintf(fpOutputFile,"(*evolutionaryAlgorithm->getPopulation())");
//fprintf(fpOutputFile,"(*evolutionaryAlgorithm->getPopulation())");
fprintf(fpOutputFile,"pPopulation[");
}
}
<COPY_USER_GENERATION>"]" {if (!bWaitingToClosePopulation) fprintf(fpOutputFile,"]");
else {fprintf(fpOutputFile,")))"); bWaitingToClosePopulation=false;}}
else if( TARGET==CUDA || TARGET==STD)
fprintf(fpOutputFile,"]");
else {
fprintf(fpOutputFile,")))");
bWaitingToClosePopulation=false;
}
}
<COPY_USER_GENERATION>"currentGeneration" |
<COPY_USER_GENERATION>"currentGeneration"/[ \t\n]*"==" {
......@@ -1841,10 +1848,16 @@ exponent ([Ee][+-]?[0-9]+)
<COPY_USER_FUNCTION>"pPopulation"[ \t\n]*"[" {bWaitingToClosePopulation=true;
switch (TARGET) {
case EO: fprintf(fpOutputFile,"pPopulation ["); break;
case GALIB: fprintf(fpOutputFile,"((%sGenome *)&(pPopulation->individual(",sPROJECT_NAME);
case GALIB: fprintf(fpOutputFile,"((%sGenome *)&(pPopulation->individual(",sPROJECT_NAME); break;
case STD:
case CUDA:
fprintf(fpOutputFile,"pPopulation[");
}
}
<COPY_USER_FUNCTION>"]" {if (!bWaitingToClosePopulation) fprintf(fpOutputFile,"]");
<COPY_USER_FUNCTION>"]" {
if (!bWaitingToClosePopulation) fprintf(fpOutputFile,"]");
else if( TARGET==CUDA || TARGET==STD)
fprintf(fpOutputFile,"]");
else {fprintf(fpOutputFile,")))"); bWaitingToClosePopulation=false;}}
<COPY_USER_FUNCTION>"currentGeneration" |
......
......@@ -191,7 +191,7 @@ GenomeClass {
\end
\GenomeClass::crossover :
for (int i=0; i<n; i++)
for (int i=0; i<n; i++)
{
float alpha = (float)globalRandomGenerator->getRandomIntMax(1.); // barycentric crossover
child1.x[i] = alpha*parent1.x[i] + (1.-alpha)*parent2.x[i];
......@@ -202,9 +202,16 @@ GenomeClass {
\At the end of each generation function:
if( currentGeneration==98 ) XOVER_PROB = 0.5;
for( int i=0 ; i<20 ; i++ ){
cout << pPopulation[i]->getFitness() << endl;
}
\end
\At the beginning of each generation function:
\end
\GenomeClass::mutator : // Must return the number of mutations
int NbMut=0;
float pond = 1./sqrt((float)n);
......
......@@ -5,8 +5,12 @@
\ANALYSE_PARAMETERS
using namespace std;
class Individual;
#include <stdlib.h>
/** Global variables for the whole algorithm */
Individual** pPopulation = NULL;
float* pEZ_MUT_PROB = NULL;
float* pEZ_XOVER_PROB = NULL;
......@@ -721,6 +725,7 @@ Population::Population(size_t parentPopulationSize, size_t offspringPopulationSi
pEZ_MUT_PROB = &this->pMutation;
pEZ_XOVER_PROB = &this->pCrossover;
this->pMutationPerGene = pMutationPerGene;
pPopulation = parents;
this->rg = rg;
......@@ -1272,13 +1277,15 @@ 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;
extern float* pEZ_XOVER_PROB;
class EvolutionaryAlgorithm;
class Individual;
class Population;
extern float* pEZ_MUT_PROB;
extern float* pEZ_XOVER_PROB;
extern Individual** pPopulation;
extern size_t *EZ_NB_GEN;
#define EZ_MINIMIZE \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