Commit cdb0b93f authored by Julien Gamba's avatar Julien Gamba

Add back the globals variables OFFSPRING_SIZE, POP_SIZE to non CUDA templates

parent 2b373016
...@@ -24,6 +24,9 @@ float* pEZ_MUT_PROB = NULL; ...@@ -24,6 +24,9 @@ float* pEZ_MUT_PROB = NULL;
float* pEZ_XOVER_PROB = NULL; float* pEZ_XOVER_PROB = NULL;
unsigned *EZ_NB_GEN; unsigned *EZ_NB_GEN;
unsigned *EZ_current_generation; unsigned *EZ_current_generation;
int EZ_POP_SIZE;
int OFFSPRING_SIZE;
CEvolutionaryAlgorithm* EA; CEvolutionaryAlgorithm* EA;
CCmaes *cma; CCmaes *cma;
...@@ -316,6 +319,8 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){ ...@@ -316,6 +319,8 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
pEZ_XOVER_PROB = &pCrossover; pEZ_XOVER_PROB = &pCrossover;
EZ_NB_GEN = (unsigned*)setVariable("nbGen",\NB_GEN); EZ_NB_GEN = (unsigned*)setVariable("nbGen",\NB_GEN);
EZ_current_generation=0; EZ_current_generation=0;
EZ_POP_SIZE = parentPopulationSize;
OFFSPRING_SIZE = offspringPopulationSize;
CEvolutionaryAlgorithm* ea = new EvolutionaryAlgorithmImpl(this); CEvolutionaryAlgorithm* ea = new EvolutionaryAlgorithmImpl(this);
generationalCriterion->setCounterEa(ea->getCurrentGenerationPtr()); generationalCriterion->setCounterEa(ea->getCurrentGenerationPtr());
...@@ -380,6 +385,9 @@ class CPopulation; ...@@ -380,6 +385,9 @@ class CPopulation;
class CCmaes; class CCmaes;
class Parameters; class Parameters;
extern int EZ_POP_SIZE;
extern int OFFSPRING_SIZE;
extern CCmaes *cma; extern CCmaes *cma;
\INSERT_USER_CLASSES_DEFINITIONS \INSERT_USER_CLASSES_DEFINITIONS
......
...@@ -23,6 +23,9 @@ float* pEZ_MUT_PROB = NULL; ...@@ -23,6 +23,9 @@ float* pEZ_MUT_PROB = NULL;
float* pEZ_XOVER_PROB = NULL; float* pEZ_XOVER_PROB = NULL;
unsigned *EZ_NB_GEN; unsigned *EZ_NB_GEN;
unsigned *EZ_current_generation; unsigned *EZ_current_generation;
int EZ_POP_SIZE;
int OFFSPRING_SIZE;
CEvolutionaryAlgorithm* EA; CEvolutionaryAlgorithm* EA;
int main(int argc, char** argv){ int main(int argc, char** argv){
...@@ -480,6 +483,8 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){ ...@@ -480,6 +483,8 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
pEZ_XOVER_PROB = &pCrossover; pEZ_XOVER_PROB = &pCrossover;
EZ_NB_GEN = (unsigned*)setVariable("nbGen",\NB_GEN); EZ_NB_GEN = (unsigned*)setVariable("nbGen",\NB_GEN);
EZ_current_generation=0; EZ_current_generation=0;
EZ_POP_SIZE = parentPopulationSize;
OFFSPRING_SIZE = offspringPopulationSize;
CEvolutionaryAlgorithm* ea = new EvolutionaryAlgorithmImpl(this); CEvolutionaryAlgorithm* ea = new EvolutionaryAlgorithmImpl(this);
generationalCriterion->setCounterEa(ea->getCurrentGenerationPtr()); generationalCriterion->setCounterEa(ea->getCurrentGenerationPtr());
...@@ -545,6 +550,9 @@ class CEvolutionaryAlgorithm; ...@@ -545,6 +550,9 @@ class CEvolutionaryAlgorithm;
class CPopulation; class CPopulation;
class Parameters; class Parameters;
extern int EZ_POP_SIZE;
extern int OFFSPRING_SIZE;
\INSERT_USER_CLASSES_DEFINITIONS \INSERT_USER_CLASSES_DEFINITIONS
class IndividualImpl : public CIndividual { class IndividualImpl : public CIndividual {
......
...@@ -23,6 +23,9 @@ float* pEZ_MUT_PROB = NULL; ...@@ -23,6 +23,9 @@ float* pEZ_MUT_PROB = NULL;
float* pEZ_XOVER_PROB = NULL; float* pEZ_XOVER_PROB = NULL;
unsigned *EZ_NB_GEN; unsigned *EZ_NB_GEN;
unsigned *EZ_current_generation; unsigned *EZ_current_generation;
int EZ_POP_SIZE;
int OFFSPRING_SIZE;
CEvolutionaryAlgorithm* EA; CEvolutionaryAlgorithm* EA;
int main(int argc, char** argv){ int main(int argc, char** argv){
...@@ -336,6 +339,8 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){ ...@@ -336,6 +339,8 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
pEZ_XOVER_PROB = &pCrossover; pEZ_XOVER_PROB = &pCrossover;
EZ_NB_GEN = (unsigned*)setVariable("nbGen",\NB_GEN); EZ_NB_GEN = (unsigned*)setVariable("nbGen",\NB_GEN);
EZ_current_generation=0; EZ_current_generation=0;
EZ_POP_SIZE = parentPopulationSize;
OFFSPRING_SIZE = offspringPopulationSize;
CEvolutionaryAlgorithm* ea = new EvolutionaryAlgorithmImpl(this); CEvolutionaryAlgorithm* ea = new EvolutionaryAlgorithmImpl(this);
generationalCriterion->setCounterEa(ea->getCurrentGenerationPtr()); generationalCriterion->setCounterEa(ea->getCurrentGenerationPtr());
...@@ -406,6 +411,9 @@ class CEvolutionaryAlgorithm; ...@@ -406,6 +411,9 @@ class CEvolutionaryAlgorithm;
class CPopulation; class CPopulation;
class Parameters; class Parameters;
extern int EZ_POP_SIZE;
extern int OFFSPRING_SIZE;
\INSERT_USER_CLASSES_DEFINITIONS \INSERT_USER_CLASSES_DEFINITIONS
class IndividualImpl : public CIndividual { class IndividualImpl : public CIndividual {
......
...@@ -9,6 +9,9 @@ using namespace std; ...@@ -9,6 +9,9 @@ using namespace std;
#include "EASEAIndividual.hpp" #include "EASEAIndividual.hpp"
#include <time.h> #include <time.h>
int EZ_POP_SIZE;
int OFFSPRING_SIZE;
RandomGenerator* globalRandomGenerator; RandomGenerator* globalRandomGenerator;
...@@ -217,6 +220,8 @@ EvolutionaryAlgorithm::EvolutionaryAlgorithm( size_t parentPopulationSize, ...@@ -217,6 +220,8 @@ EvolutionaryAlgorithm::EvolutionaryAlgorithm( size_t parentPopulationSize,
SelectionOperator* selectionOperator, SelectionOperator* replacementOperator, SelectionOperator* selectionOperator, SelectionOperator* replacementOperator,
float pCrossover, float pMutation, float pCrossover, float pMutation,
float pMutationPerGene, string& outputfile, string& inputfile){ float pMutationPerGene, string& outputfile, string& inputfile){
EZ_POP_SIZE = parentPopulationSize;
OFFSPRING_SIZE = offspringPopulationSize;
RandomGenerator* rg = globalRandomGenerator; RandomGenerator* rg = globalRandomGenerator;
...@@ -352,6 +357,10 @@ bool EvolutionaryAlgorithm::allCriteria(){ ...@@ -352,6 +357,10 @@ bool EvolutionaryAlgorithm::allCriteria(){
#include <ostream> #include <ostream>
#include <sstream> #include <sstream>
using namespace std; using namespace std;
extern int EZ_POP_SIZE;
extern int OFFSPRING_SIZE;
\INSERT_USER_CLASSES \INSERT_USER_CLASSES
\START_CUDA_GENOME_H_TPL \START_CUDA_GENOME_H_TPL
......
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