Commit 46b5cc02 authored by Frederic Kruger's avatar Frederic Kruger

Correction tpl

parent aa2c1b75
......@@ -394,7 +394,7 @@ void CEvolutionaryAlgorithm::initializeClients(){
}
}
if(this->numberOfClients>1){
if(this->numberOfClients>0){
this->Clients = (CComUDPClient**)malloc(this->numberOfClients*sizeof(CComUDPClient*));
for(int i=0; i<(signed)this->numberOfClients; i++){
this->Clients[i] = new CComUDPClient(2909,(const char*)clients[i],0);
......
......@@ -36,7 +36,7 @@ public:
CEvolutionaryAlgorithm( Parameters* params );
virtual void initializeParentPopulation() = 0;
unsigned* getCurrentGenerationPtr(){ return &currentGeneration;}
unsigned int *getCurrentGenerationPtr(){ return &currentGeneration;}
void addStoppingCriterion(CStoppingCriterion* sc);
void runEvolutionaryLoop();
bool allCriteria();
......
......@@ -27,8 +27,8 @@ CIndividual** pPopulation = NULL;
CIndividual *bBest = NULL;
float* pEZ_MUT_PROB = NULL;
float* pEZ_XOVER_PROB = NULL;
size_t *EZ_NB_GEN;
size_t *EZ_current_generation;
unsigned *EZ_NB_GEN;
unsigned *EZ_current_generation;
CEvolutionaryAlgorithm* EA;
CCmaes *cma;
......@@ -254,7 +254,7 @@ std::ostream& operator << (std::ostream& O, const IndividualImpl& B)
}
size_t IndividualImpl::mutate( float pMutationPerGene ){
unsigned IndividualImpl::mutate( float pMutationPerGene ){
this->valid=false;
......@@ -325,7 +325,7 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
pEZ_MUT_PROB = &pMutationPerGene;
pEZ_XOVER_PROB = &pCrossover;
EZ_NB_GEN = (size_t*)setVariable("nbGen",\NB_GEN);
EZ_NB_GEN = (unsigned*)setVariable("nbGen",\NB_GEN);
EZ_current_generation=0;
CEvolutionaryAlgorithm* ea = new EvolutionaryAlgorithmImpl(this);
......@@ -407,13 +407,13 @@ public:
IndividualImpl(const IndividualImpl& indiv);
virtual ~IndividualImpl();
float evaluate();
static size_t getCrossoverArrity(){ return 2; }
static unsigned getCrossoverArrity(){ return 2; }
float getFitness(){ return this->fitness; }
CIndividual* crossover(CIndividual** p2);
void printOn(std::ostream& O) const;
CIndividual* clone();
size_t mutate(float pMutationPerGene);
unsigned mutate(float pMutationPerGene);
string serialize();
void deserialize(string AESAE_Line);
......
......@@ -26,8 +26,8 @@ CIndividual** pPopulation = NULL;
CIndividual* bBest = NULL;
float* pEZ_MUT_PROB = NULL;
float* pEZ_XOVER_PROB = NULL;
size_t *EZ_NB_GEN;
size_t *EZ_current_generation;
unsigned *EZ_NB_GEN;
unsigned *EZ_current_generation;
CEvolutionaryAlgorithm* EA;
int main(int argc, char** argv){
......@@ -110,7 +110,7 @@ PopulationImpl* Pop = NULL;
\INSERT_USER_FUNCTIONS
void cudaPreliminaryProcess(size_t PopulationSize){
void cudaPreliminaryProcess(unsigned PopulationSize){
int capacite_max = 0;
//Recuperation of each device information's.
......@@ -149,18 +149,18 @@ void cudaPreliminaryProcess(size_t PopulationSize){
}
}
__device__ __host__ inline IndividualImpl* INDIVIDUAL_ACCESS(void* buffer,size_t id){
__device__ __host__ inline IndividualImpl* INDIVIDUAL_ACCESS(void* buffer,unsigned id){
return (IndividualImpl*)buffer+id;
}
__device__ float cudaEvaluate(void* devBuffer, size_t id, struct gpuOptions initOpts){
__device__ float cudaEvaluate(void* devBuffer, unsigned id, struct gpuOptions initOpts){
\INSERT_CUDA_EVALUATOR
}
__global__ void cudaEvaluatePopulation(void* d_population, size_t popSize, float* d_fitnesses, struct gpuOptions initOpts){
__global__ void cudaEvaluatePopulation(void* d_population, unsigned popSize, float* d_fitnesses, struct gpuOptions initOpts){
size_t id = (blockDim.x*blockIdx.x)+threadIdx.x; // id of the individual computed by this thread
unsigned id = (blockDim.x*blockIdx.x)+threadIdx.x; // id of the individual computed by this thread
// escaping for the last block
if( id >= popSize ) return;
......@@ -359,7 +359,7 @@ std::ostream& operator << (std::ostream& O, const IndividualImpl& B)
}
size_t IndividualImpl::mutate( float pMutationPerGene ){
unsigned IndividualImpl::mutate( float pMutationPerGene ){
this->valid=false;
......@@ -370,7 +370,7 @@ size_t IndividualImpl::mutate( float pMutationPerGene ){
void PopulationImpl::evaluateParentPopulation(){
size_t actualPopulationSize = this->actualParentPopulationSize;
unsigned actualPopulationSize = this->actualParentPopulationSize;
fitnessTemp = new float[actualPopulationSize];
int index;
cudaPreliminaryProcess(actualPopulationSize);
......@@ -389,7 +389,7 @@ void PopulationImpl::evaluateParentPopulation(){
}
void PopulationImpl::evaluateOffspringPopulation(){
size_t actualPopulationSize = this->actualOffspringPopulationSize;
unsigned actualPopulationSize = this->actualOffspringPopulationSize;
fitnessTemp = new float[actualPopulationSize];
int index;
if(first_generation) cudaPreliminaryProcess(actualPopulationSize);
......@@ -495,7 +495,7 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
pEZ_MUT_PROB = &pMutationPerGene;
pEZ_XOVER_PROB = &pCrossover;
EZ_NB_GEN = (size_t*)setVariable("nbGen",\NB_GEN);
EZ_NB_GEN = (unsigned*)setVariable("nbGen",\NB_GEN);
EZ_current_generation=0;
CEvolutionaryAlgorithm* ea = new EvolutionaryAlgorithmImpl(this);
......@@ -510,7 +510,7 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
return ea;
}
inline void IndividualImpl::copyToCudaBuffer(void* buffer, size_t id){
inline void IndividualImpl::copyToCudaBuffer(void* buffer, unsigned id){
memcpy(((IndividualImpl*)buffer)+id,this,sizeof(IndividualImpl));
......@@ -554,7 +554,7 @@ EvolutionaryAlgorithmImpl::~EvolutionaryAlgorithmImpl(){
}
PopulationImpl::PopulationImpl(size_t parentPopulationSize, size_t offspringPopulationSize, float pCrossover, float pMutation, float pMutationPerGene, CRandomGenerator* rg, Parameters* params) : CPopulation(parentPopulationSize, offspringPopulationSize, pCrossover, pMutation, pMutationPerGene, rg, params){
PopulationImpl::PopulationImpl(unsigned parentPopulationSize, unsigned offspringPopulationSize, float pCrossover, float pMutation, float pMutationPerGene, CRandomGenerator* rg, Parameters* params) : CPopulation(parentPopulationSize, offspringPopulationSize, pCrossover, pMutation, pMutationPerGene, rg, params){
;
}
......@@ -600,16 +600,16 @@ public:
IndividualImpl(const IndividualImpl& indiv);
virtual ~IndividualImpl();
float evaluate();
static size_t getCrossoverArrity(){ return 2; }
static unsigned getCrossoverArrity(){ return 2; }
float getFitness(){ return this->fitness; }
CIndividual* crossover(CIndividual** p2);
void printOn(std::ostream& O) const;
CIndividual* clone();
size_t mutate(float pMutationPerGene);
unsigned mutate(float pMutationPerGene);
string serialize();
void deserialize(string AESAE_Line);
void copyToCudaBuffer(void* buffer, size_t id);
void copyToCudaBuffer(void* buffer, unsigned id);
friend std::ostream& operator << (std::ostream& O, const IndividualImpl& B) ;
void initRandomGenerator(CRandomGenerator* rg){ IndividualImpl::rg = rg;}
......@@ -645,7 +645,7 @@ class PopulationImpl: public CPopulation {
public:
CCuda *cuda;
public:
PopulationImpl(size_t parentPopulationSize, size_t offspringPopulationSize, float pCrossover, float pMutation, float pMutationPerGene, CRandomGenerator* rg, Parameters* params);
PopulationImpl(unsigned parentPopulationSize, unsigned offspringPopulationSize, float pCrossover, float pMutation, float pMutationPerGene, CRandomGenerator* rg, Parameters* params);
virtual ~PopulationImpl();
void evaluateParentPopulation();
void evaluateOffspringPopulation();
......
......@@ -25,8 +25,8 @@ CIndividual** pPopulation = NULL;
CIndividual* bBest = NULL;
float* pEZ_MUT_PROB = NULL;
float* pEZ_XOVER_PROB = NULL;
size_t *EZ_NB_GEN;
size_t *EZ_current_generation;
unsigned *EZ_NB_GEN;
unsigned *EZ_current_generation;
CEvolutionaryAlgorithm* EA;
......@@ -706,7 +706,7 @@ std::ostream& operator << (std::ostream& O, const IndividualImpl& B)
}
size_t IndividualImpl::mutate( float pMutationPerGene ){
unsigned IndividualImpl::mutate( float pMutationPerGene ){
this->valid=false;
......@@ -812,7 +812,7 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
pEZ_MUT_PROB = &pMutationPerGene;
pEZ_XOVER_PROB = &pCrossover;
EZ_NB_GEN = (size_t*)setVariable("nbGen",\NB_GEN);
EZ_NB_GEN = (unsigned*)setVariable("nbGen",\NB_GEN);
EZ_current_generation=0;
CEvolutionaryAlgorithm* ea = new EvolutionaryAlgorithmImpl(this);
......@@ -889,13 +889,13 @@ public:
IndividualImpl(const IndividualImpl& indiv);
virtual ~IndividualImpl();
float evaluate();
static size_t getCrossoverArrity(){ return 2; }
static unsigned getCrossoverArrity(){ return 2; }
float getFitness(){ return this->fitness; }
CIndividual* crossover(CIndividual** p2);
void printOn(std::ostream& O) const;
CIndividual* clone();
size_t mutate(float pMutationPerGene);
unsigned mutate(float pMutationPerGene);
string serialize();
void deserialize(string AESAE_Line);
......
This diff is collapsed.
......@@ -26,8 +26,8 @@ CIndividual** pPopulation = NULL;
CIndividual* bBest = NULL;
float* pEZ_MUT_PROB = NULL;
float* pEZ_XOVER_PROB = NULL;
size_t *EZ_NB_GEN;
size_t *EZ_current_generation;
unsigned *EZ_NB_GEN;
unsigned *EZ_current_generation;
CEvolutionaryAlgorithm* EA;
int main(int argc, char** argv){
......@@ -215,7 +215,7 @@ std::ostream& operator << (std::ostream& O, const IndividualImpl& B)
}
size_t IndividualImpl::mutate( float pMutationPerGene ){
unsigned IndividualImpl::mutate( float pMutationPerGene ){
this->valid=false;
......@@ -228,7 +228,7 @@ void IndividualImpl::optimiser(int currentIteration){
\INSERT_OPTIMISER
}
void PopulationImpl::optimisePopulation(CIndividual** population, size_t populationSize){
void PopulationImpl::optimisePopulation(CIndividual** population, unsigned populationSize){
for(int iter=0; iter<params->optimiseIterations; iter++){
for(int i=0; i<(signed)populationSize; i++){
IndividualImpl* tmp = new IndividualImpl(*(IndividualImpl*)population[i]);
......@@ -344,7 +344,7 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
pEZ_MUT_PROB = &pMutationPerGene;
pEZ_XOVER_PROB = &pCrossover;
EZ_NB_GEN = (size_t*)setVariable("nbGen",\NB_GEN);
EZ_NB_GEN = (unsigned*)setVariable("nbGen",\NB_GEN);
EZ_current_generation=0;
CEvolutionaryAlgorithm* ea = new EvolutionaryAlgorithmImpl(this);
......@@ -388,7 +388,7 @@ EvolutionaryAlgorithmImpl::~EvolutionaryAlgorithmImpl(){
}
PopulationImpl::PopulationImpl(size_t parentPopulationSize, size_t offspringPopulationSize, float pCrossover, float pMutation, float pMutationPerGene, CRandomGenerator* rg, Parameters* params) : CPopulation(parentPopulationSize, offspringPopulationSize, pCrossover, pMutation, pMutationPerGene, rg, params){
PopulationImpl::PopulationImpl(unsigned parentPopulationSize, unsigned offspringPopulationSize, float pCrossover, float pMutation, float pMutationPerGene, CRandomGenerator* rg, Parameters* params) : CPopulation(parentPopulationSize, offspringPopulationSize, pCrossover, pMutation, pMutationPerGene, rg, params){
;
}
......@@ -429,14 +429,14 @@ public:
IndividualImpl(const IndividualImpl& indiv);
virtual ~IndividualImpl();
float evaluate();
static size_t getCrossoverArrity(){ return 2; }
static unsigned getCrossoverArrity(){ return 2; }
float getFitness(){ return this->fitness; }
CIndividual* crossover(CIndividual** p2);
void optimiser(int currentIteration);
void printOn(std::ostream& O) const;
CIndividual* clone();
size_t mutate(float pMutationPerGene);
unsigned mutate(float pMutationPerGene);
string serialize();
void deserialize(string AESAE_Line);
......@@ -473,9 +473,9 @@ public:
class PopulationImpl: public CPopulation {
public:
PopulationImpl(size_t parentPopulationSize, size_t offspringPopulationSize, float pCrossover, float pMutation, float pMutationPerGene, CRandomGenerator* rg, Parameters* params);
PopulationImpl(unsigned parentPopulationSize, unsigned offspringPopulationSize, float pCrossover, float pMutation, float pMutationPerGene, CRandomGenerator* rg, Parameters* params);
virtual ~PopulationImpl();
void optimisePopulation(CIndividual** population, size_t populationSize);
void optimisePopulation(CIndividual** population, unsigned populationSize);
};
#endif /* PROBLEM_DEP_H */
......
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