Commit d74e0ce0 authored by kruger's avatar kruger

Modele en ilot final ?

parent b7cdcc01
...@@ -20,16 +20,14 @@ Centre de Math ...@@ -20,16 +20,14 @@ Centre de Math
#define CUDA 4 #define CUDA 4
#define STD 5 #define STD 5
#define CMAES 6
#define MEMETIC 7
#define STD_FLAVOR_SO 0 #define STD_FLAVOR_SO 0
#define STD_FLAVOR_MO 1 #define STD_FLAVOR_MO 1
#define STD_FLAVOR_CMAES 2
#define STD_FLAVOR_MEMETIC 3
#define CUDA_FLAVOR_SO 0 #define CUDA_FLAVOR_SO 0
#define CUDA_FLAVOR_MO 1 #define CUDA_FLAVOR_MO 1
#define CUDA_FLAVOR_CMAES 2 #define CUDA_FLAVOR_GP 2
#define CUDA_FLAVOR_GP 3
#define CUDA_FLAVOR_MEMETIC 4
#define UNIX 1 #define UNIX 1
...@@ -44,22 +42,23 @@ extern int nClasses_nb; ...@@ -44,22 +42,23 @@ extern int nClasses_nb;
extern FILE *fpOutputFile, *fpTemplateFile, *fpGenomeFile, *fpExplodedGenomeFile; extern FILE *fpOutputFile, *fpTemplateFile, *fpGenomeFile, *fpExplodedGenomeFile;
extern char sRAW_PROJECT_NAME[], sPROJECT_NAME[], sEO_DIR[], sEZ_PATH[1000], sTPL_DIR[1000], sEZ_FILE_NAME[]; extern char sRAW_PROJECT_NAME[], sPROJECT_NAME[], sEO_DIR[], sEZ_PATH[1000], sTPL_DIR[1000], sEZ_FILE_NAME[];
extern char sLOWER_CASE_PROJECT_NAME[]; extern char sLOWER_CASE_PROJECT_NAME[];
extern float fSELECT_PRM, fRED_PAR_PRM, fRED_FINAL_PRM, fRED_OFF_PRM;
extern char sSELECTOR[], sSELECTOR_OPERATOR[], sRED_PAR[], sRED_PAR_OPERATOR[], sRED_FINAL[], sRED_FINAL_OPERATOR[], sRED_OFF[], sRED_OFF_OPERATOR[]; extern char sSELECTOR[], sSELECTOR_OPERATOR[], sRED_PAR[], sRED_PAR_OPERATOR[], sRED_FINAL[], sRED_FINAL_OPERATOR[], sRED_OFF[], sRED_OFF_OPERATOR[];
extern int nMINIMISE,nELITE; extern char sIP_FILE[];
extern bool bELITISM, bVERBOSE; extern bool bELITISM, bVERBOSE;
extern bool bBALDWINISM; extern bool bBALDWINISM;
extern bool bPRINT_STATS, bPLOT_STATS, bGENERATE_CSV_FILE, bGENERATE_GNUPLOT_SCRIPT, bGENERATE_R_SCRIPT; extern bool bPRINT_STATS, bPLOT_STATS, bGENERATE_CSV_FILE, bGENERATE_GNUPLOT_SCRIPT, bGENERATE_R_SCRIPT;
extern bool bSAVE_POPULATION, bSTART_FROM_FILE; extern bool bSAVE_POPULATION, bSTART_FROM_FILE;
extern bool bREMOTE_ISLAND_MODEL;
extern bool bLINE_NUM_EZ_FILE;
extern char* nGENOME_NAME; extern char* nGENOME_NAME;
extern int nPOP_SIZE, nNB_GEN, nNB_OPT_IT, nOFF_SIZE, nPROBLEM_DIM, nTIME_LIMIT; extern int nPOP_SIZE, nNB_GEN, nNB_OPT_IT, nOFF_SIZE, nPROBLEM_DIM, nTIME_LIMIT;
extern float fMUT_PROB, fXOVER_PROB, fSURV_PAR_SIZE, fSURV_OFF_SIZE;
extern bool bREMOTE_ISLAND_MODEL;
extern int nWARNINGS, nERRORS; extern int nWARNINGS, nERRORS;
extern int TARGET, OPERATING_SYSTEM; extern int TARGET, OPERATING_SYSTEM;
extern int TARGET_FLAVOR; extern int TARGET_FLAVOR;
extern bool bLINE_NUM_EZ_FILE; extern int nMINIMISE,nELITE;
extern float fMUT_PROB, fXOVER_PROB, fSURV_PAR_SIZE, fSURV_OFF_SIZE;
extern float fSELECT_PRM, fRED_PAR_PRM, fRED_FINAL_PRM, fRED_OFF_PRM;
extern unsigned iMAX_INIT_TREE_D,iMIN_INIT_TREE_D,iMAX_TREE_D,iNB_GPU,iPRG_BUF_SIZE,iMAX_TREE_DEPTH,iNO_FITNESS_CASES; extern unsigned iMAX_INIT_TREE_D,iMIN_INIT_TREE_D,iMAX_TREE_D,iNB_GPU,iPRG_BUF_SIZE,iMAX_TREE_DEPTH,iNO_FITNESS_CASES;
// Prototypes // Prototypes
......
This diff is collapsed.
...@@ -1115,6 +1115,7 @@ if(OPERATING_SYSTEM=WINDOWS) ...@@ -1115,6 +1115,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<TEMPLATE_ANALYSIS>"\\BALDWINISM" {fprintf(fpOutputFile,"%d",bBALDWINISM);} <TEMPLATE_ANALYSIS>"\\BALDWINISM" {fprintf(fpOutputFile,"%d",bBALDWINISM);}
<TEMPLATE_ANALYSIS>"\\REMOTE_ISLAND_MODEL" {fprintf(fpOutputFile,"%d",bREMOTE_ISLAND_MODEL);} <TEMPLATE_ANALYSIS>"\\REMOTE_ISLAND_MODEL" {fprintf(fpOutputFile,"%d",bREMOTE_ISLAND_MODEL);}
<TEMPLATE_ANALYSIS>"\\IP_FILE" {if(strlen(sIP_FILE)>0)fprintf(fpOutputFile,"%s",sIP_FILE); else fprintf(fpOutputFile,"NULL");}
<TEMPLATE_ANALYSIS>"\\PRINT_STATS" {fprintf(fpOutputFile,"%d",bPRINT_STATS);} <TEMPLATE_ANALYSIS>"\\PRINT_STATS" {fprintf(fpOutputFile,"%d",bPRINT_STATS);}
<TEMPLATE_ANALYSIS>"\\PLOT_STATS" {fprintf(fpOutputFile,"%d",bPLOT_STATS);} <TEMPLATE_ANALYSIS>"\\PLOT_STATS" {fprintf(fpOutputFile,"%d",bPLOT_STATS);}
...@@ -2121,6 +2122,7 @@ if(OPERATING_SYSTEM=WINDOWS) ...@@ -2121,6 +2122,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<GET_PARAMETERS>"Baldwinism"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tBaldwinism...\n");return BALDWINISM;} <GET_PARAMETERS>"Baldwinism"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tBaldwinism...\n");return BALDWINISM;}
<GET_PARAMETERS>"Remote"[ \t\n]+"island"[ \t\n]+"model"[ \t\n]*":"[ \t\n]* {if(bVERBOSE) printf ("\tRemote Island Model...\n"); return REMOTE_ISLAND_MODEL;} <GET_PARAMETERS>"Remote"[ \t\n]+"island"[ \t\n]+"model"[ \t\n]*":"[ \t\n]* {if(bVERBOSE) printf ("\tRemote Island Model...\n"); return REMOTE_ISLAND_MODEL;}
<GET_PARAMETERS>"IP"[ \t\n]+"file"[ \t\n]*":"[ \t\n]* {if(bVERBOSE) printf("\tIP File...\n"); return IP_FILE;}
// number // number
...@@ -2274,11 +2276,11 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable) ...@@ -2274,11 +2276,11 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
if (TARGET==CUDA){ if (TARGET==CUDA){
if(TARGET_FLAVOR == CUDA_FLAVOR_SO ) if(TARGET_FLAVOR == CUDA_FLAVOR_SO )
strcat(sTemp,"CUDA.tpl"); strcat(sTemp,"CUDA.tpl");
else if(TARGET_FLAVOR == CUDA_FLAVOR_CMAES ) else if(TARGET_FLAVOR == CMAES )
strcat(sTemp,"CMAES_CUDA.tpl"); strcat(sTemp,"CMAES_CUDA.tpl");
else if( TARGET_FLAVOR == CUDA_FLAVOR_GP ) else if( TARGET_FLAVOR == CUDA_FLAVOR_GP )
strcat(sTemp,"CUDA_GP.tpl"); strcat(sTemp,"CUDA_GP.tpl");
else if(TARGET_FLAVOR == CUDA_FLAVOR_MEMETIC ) else if(TARGET_FLAVOR == MEMETIC )
strcat(sTemp,"CUDA_MEM.tpl"); strcat(sTemp,"CUDA_MEM.tpl");
else else
strcat(sTemp,"CUDA_MO.tpl"); strcat(sTemp,"CUDA_MO.tpl");
...@@ -2292,9 +2294,9 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable) ...@@ -2292,9 +2294,9 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
if (TARGET==STD){ if (TARGET==STD){
if(TARGET_FLAVOR == STD_FLAVOR_SO) if(TARGET_FLAVOR == STD_FLAVOR_SO)
strcat(sTemp,"STD.tpl"); strcat(sTemp,"STD.tpl");
else if (TARGET_FLAVOR == STD_FLAVOR_CMAES) else if (TARGET_FLAVOR == CMAES)
strcat(sTemp,"CMAES.tpl"); strcat(sTemp,"CMAES.tpl");
else if (TARGET_FLAVOR == STD_FLAVOR_MEMETIC ) else if (TARGET_FLAVOR == MEMETIC )
strcat(sTemp,"STD_MEM.tpl"); strcat(sTemp,"STD_MEM.tpl");
else else
strcat(sTemp,"STD_MO.tpl"); strcat(sTemp,"STD_MO.tpl");
......
This diff is collapsed.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <cyacc.h> #include <cyacc.h>
#line 67 "EaseaParse.y" #line 68 "EaseaParse.y"
// forward references // forward references
class CSymbol; class CSymbol;
...@@ -11,7 +11,7 @@ class CSymbol; ...@@ -11,7 +11,7 @@ class CSymbol;
#line 12 "EaseaParse.h" #line 12 "EaseaParse.h"
#ifndef YYSTYPE #ifndef YYSTYPE
union tagYYSTYPE { union tagYYSTYPE {
#line 73 "EaseaParse.y" #line 74 "EaseaParse.y"
CSymbol* pSymbol; CSymbol* pSymbol;
double dValue; double dValue;
...@@ -66,28 +66,29 @@ union tagYYSTYPE { ...@@ -66,28 +66,29 @@ union tagYYSTYPE {
#define ELITISM 295 #define ELITISM 295
#define ELITE 296 #define ELITE 296
#define REMOTE_ISLAND_MODEL 297 #define REMOTE_ISLAND_MODEL 297
#define PRINT_STATS 298 #define IP_FILE 298
#define PLOT_STATS 299 #define PRINT_STATS 299
#define GENERATE_CSV_FILE 300 #define PLOT_STATS 300
#define GENERATE_GNUPLOT_SCRIPT 301 #define GENERATE_CSV_FILE 301
#define GENERATE_R_SCRIPT 302 #define GENERATE_GNUPLOT_SCRIPT 302
#define SAVE_POPULATION 303 #define GENERATE_R_SCRIPT 303
#define START_FROM_FILE 304 #define SAVE_POPULATION 304
#define TIME_LIMIT 305 #define START_FROM_FILE 305
#define MAX_INIT_TREE_D 306 #define TIME_LIMIT 306
#define MIN_INIT_TREE_D 307 #define MAX_INIT_TREE_D 307
#define MAX_XOVER_DEPTH 308 #define MIN_INIT_TREE_D 308
#define MAX_MUTAT_DEPTH 309 #define MAX_XOVER_DEPTH 309
#define MAX_TREE_D 310 #define MAX_MUTAT_DEPTH 310
#define NB_GPU 311 #define MAX_TREE_D 311
#define PRG_BUF_SIZE 312 #define NB_GPU 312
#define NO_FITNESS_CASES 313 #define PRG_BUF_SIZE 313
#line 155 "EaseaParse.y" #define NO_FITNESS_CASES 314
#line 157 "EaseaParse.y"
#include "EaseaSym.h" #include "EaseaSym.h"
#include "EaseaLex.h" #include "EaseaLex.h"
#line 91 "EaseaParse.h" #line 92 "EaseaParse.h"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// CEASEAParser // CEASEAParser
...@@ -108,7 +109,7 @@ protected: ...@@ -108,7 +109,7 @@ protected:
#endif #endif
public: public:
#line 162 "EaseaParse.y" #line 164 "EaseaParse.y"
protected: protected:
CEASEALexer EASEALexer; // the lexical analyser CEASEALexer EASEALexer; // the lexical analyser
...@@ -122,7 +123,7 @@ public: ...@@ -122,7 +123,7 @@ public:
double divide(double dDividend, double dDivisor); double divide(double dDividend, double dDivisor);
CSymbol* insert() const; CSymbol* insert() const;
#line 126 "EaseaParse.h" #line 127 "EaseaParse.h"
}; };
#ifndef YYPARSENAME #ifndef YYPARSENAME
......
...@@ -47,8 +47,9 @@ bool bPRINT_STATS=1; ...@@ -47,8 +47,9 @@ bool bPRINT_STATS=1;
bool bPLOT_STATS=0; bool bPLOT_STATS=0;
bool bGENERATE_CSV_FILE=0, bGENERATE_R_SCRIPT=0, bGENERATE_GNUPLOT_SCRIPT=0; bool bGENERATE_CSV_FILE=0, bGENERATE_R_SCRIPT=0, bGENERATE_GNUPLOT_SCRIPT=0;
bool bSAVE_POPULATION=0, bSTART_FROM_FILE=0; bool bSAVE_POPULATION=0, bSTART_FROM_FILE=0;
bool bBALDWINISM=0; bool bBALDWINISM=0; //memetic
bool bREMOTE_ISLAND_MODEL=0; bool bREMOTE_ISLAND_MODEL=0; //remote island model
char sIP_FILE[128]; //remote island model
int nPOP_SIZE, nOFF_SIZE; int nPOP_SIZE, nOFF_SIZE;
float fSURV_PAR_SIZE=-1.0, fSURV_OFF_SIZE=-1.0; float fSURV_PAR_SIZE=-1.0, fSURV_OFF_SIZE=-1.0;
char *nGENOME_NAME; char *nGENOME_NAME;
...@@ -135,6 +136,7 @@ class CSymbol; ...@@ -135,6 +136,7 @@ class CSymbol;
%token ELITISM %token ELITISM
%token ELITE %token ELITE
%token REMOTE_ISLAND_MODEL //island model %token REMOTE_ISLAND_MODEL //island model
%token IP_FILE //island model
%token PRINT_STATS %token PRINT_STATS
%token PLOT_STATS %token PLOT_STATS
%token GENERATE_CSV_FILE %token GENERATE_CSV_FILE
...@@ -146,7 +148,7 @@ class CSymbol; ...@@ -146,7 +148,7 @@ class CSymbol;
%token MAX_INIT_TREE_D %token MAX_INIT_TREE_D
%token MIN_INIT_TREE_D %token MIN_INIT_TREE_D
%token MAX_XOVER_DEPTH %token MAX_XOVER_DEPTH
%token MAX_MUTAT_DEPTH %token MAX_MUTAT_DEPTH
%token MAX_TREE_D %token MAX_TREE_D
%token NB_GPU %token NB_GPU
%token PRG_BUF_SIZE %token PRG_BUF_SIZE
...@@ -366,7 +368,7 @@ Object ...@@ -366,7 +368,7 @@ Object
} }
| Symbol '[' Expr ']' { | Symbol '[' Expr ']' {
if((TARGET_FLAVOR==STD_FLAVOR_CMAES || TARGET_FLAVOR==CUDA_FLAVOR_CMAES) && nPROBLEM_DIM==0 && strcmp(pCURRENT_CLASS->sName,"Genome")==0) { nGENOME_NAME=$1->sName; nPROBLEM_DIM=(int)$3;} if((TARGET_FLAVOR==CMAES) && nPROBLEM_DIM==0 && strcmp(pCURRENT_CLASS->sName,"Genome")==0) { nGENOME_NAME=$1->sName; nPROBLEM_DIM=(int)$3;}
printf("DEBUG : size of $3 %d nSize %d\n",(int)$3,pCURRENT_TYPE->nSize); printf("DEBUG : size of $3 %d nSize %d\n",(int)$3,pCURRENT_TYPE->nSize);
...@@ -382,7 +384,7 @@ Object ...@@ -382,7 +384,7 @@ Object
| '*' Symbol '[' Expr ']' { | '*' Symbol '[' Expr ']' {
// this is for support of pointer array. This should be done in a more generic way in a later version // this is for support of pointer array. This should be done in a more generic way in a later version
if((TARGET_FLAVOR==STD_FLAVOR_CMAES || TARGET_FLAVOR==CUDA_FLAVOR_CMAES) && nPROBLEM_DIM==0 && strcmp(pCURRENT_CLASS->sName,"Genome")==0) { if((TARGET_FLAVOR==CMAES) && nPROBLEM_DIM==0 && strcmp(pCURRENT_CLASS->sName,"Genome")==0) {
nGENOME_NAME=$2->sName; nPROBLEM_DIM=(int)$4; nGENOME_NAME=$2->sName; nPROBLEM_DIM=(int)$4;
} }
...@@ -623,6 +625,11 @@ Parameter ...@@ -623,6 +625,11 @@ Parameter
fprintf(stderr,"\n%s - Warning line %d: remote island model must be \"True\" or \"False\".\nDefault value \"False\" inserted.\n",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++; fprintf(stderr,"\n%s - Warning line %d: remote island model must be \"True\" or \"False\".\nDefault value \"False\" inserted.\n",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
bREMOTE_ISLAND_MODEL=0; bREMOTE_ISLAND_MODEL=0;
}} }}
| IP_FILE IDENTIFIER2'.'IDENTIFIER2{
sprintf(sIP_FILE, $2->sName);
strcat(sIP_FILE,".");
strcat(sIP_FILE,$4->sName);
}
| PRINT_STATS NUMBER2{ | PRINT_STATS NUMBER2{
if((int)$2>=1) if((int)$2>=1)
...@@ -713,7 +720,8 @@ int main(int argc, char *argv[]){ ...@@ -713,7 +720,8 @@ int main(int argc, char *argv[]){
char *sTemp; char *sTemp;
int i=0; int i=0;
TARGET=bVERBOSE=0; TARGET=STD;
bVERBOSE=0;
sRAW_PROJECT_NAME[0]=0; // used to ask for a filename if no filename is found on the command line. sRAW_PROJECT_NAME[0]=0; // used to ask for a filename if no filename is found on the command line.
while ((++nParamNb) < argc) { while ((++nParamNb) < argc) {
...@@ -741,20 +749,10 @@ int main(int argc, char *argv[]){ ...@@ -741,20 +749,10 @@ int main(int argc, char *argv[]){
TARGET_FLAVOR = STD_FLAVOR_MO; TARGET_FLAVOR = STD_FLAVOR_MO;
} }
else if (!mystricmp(sTemp,"cmaes")) { else if (!mystricmp(sTemp,"cmaes")) {
TARGET=STD; TARGET_FLAVOR = CMAES;
TARGET_FLAVOR = STD_FLAVOR_CMAES;
}
else if (!mystricmp(sTemp,"cmaes_cuda")) {
TARGET=CUDA;
TARGET_FLAVOR = CUDA_FLAVOR_CMAES;
} }
else if (!mystricmp(sTemp,"memetic")) { else if (!mystricmp(sTemp,"memetic")) {
TARGET=STD; TARGET_FLAVOR = MEMETIC;
TARGET_FLAVOR = STD_FLAVOR_MEMETIC;
}
else if (!mystricmp(sTemp,"memetic_cuda")) {
TARGET=CUDA;
TARGET_FLAVOR = CUDA_FLAVOR_MEMETIC;
} }
else if (!mystricmp(sTemp,"v")) bVERBOSE=true; else if (!mystricmp(sTemp,"v")) bVERBOSE=true;
......
...@@ -12,7 +12,7 @@ libboost: to install it on ubuntu: ...@@ -12,7 +12,7 @@ libboost: to install it on ubuntu:
2. EASEA source code: 2. EASEA source code:
The source code can be obtained either from sourceforge or, for The source code can be obtained either from sourceforge or, for
programmers invoved in the EASEA development, from its GIT repository. programmers involved in the EASEA development, from its GIT repository.
2.1 Downloading it from sourceforge: 2.1 Downloading it from sourceforge:
......
/*_________________________________________________________
Test functions
log normal adaptive mutation
Selection operator: Tournament
__________________________________________________________*/
\User declarations :
#define SIZE 100
#define X_MIN -1.
#define X_MAX 1.
#define ITER 120
#define Abs(x) ((x) < 0 ? -(x) : (x))
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define SIGMA 1. /* mutation parameter */
#define PI 3.141592654
float pMutPerGene=0.1;
\end
\User functions:
//fitness function
#include <math.h>
__device__ __host__ inline static float SQR(float d)
{
return (d*d);
}
__host__ __device__ inline float Rastrigin(float x[SIZE], int n) {
float res = 0.;
float Scale = 5.12; //pour matcher avec les limites [-1;1]
for (int i = 0;i<n; i++) res += ((Scale*Scale*x[i]*x[i])-10*cos( 2*PI*Scale*x[i]));
return (10.*SIZE + res);
}
float gauss()
/* Generates a normally distributed random value with variance 1 and 0 mean.
Algorithm based on "gasdev" from Numerical recipes' pg. 203. */
{
int iset = 0;
float gset = 0.0;
float v1 = 0.0, v2 = 0.0, r = 0.0;
float factor = 0.0;
if (iset) {
iset = 0;
return gset;
}
else {
do {
v1 = (float)random(0.,1.) * 2.0 - 1.0;
v2 = (float)random(0.,1.) * 2.0 - 1.0;
r = v1 * v1 + v2 * v2;
}
while (r > 1.0);
factor = sqrt (-2.0 * log (r) / r);
gset = v1 * factor;
iset = 1;
return (v2 * factor);
}
}
\end
\Before everything else function:
//cout<<"Before everything else function called "<<endl;
\end
\After everything else function:
//cout << "After everything else function called" << endl;
\end
\At the beginning of each generation function:
//cout << "At the beginning of each generation function called" << endl;
\end
\At the end of each generation function:
//cout << "At the end of each generation function called" << endl;
\end
\At each generation before reduce function:
//cout << "At each generation before replacement function called" << endl;
\end
\User classes :
GenomeClass {
float x[SIZE];
float sigma[SIZE]; // auto-adaptative mutation parameter
}
\end
\GenomeClass::display:
/* for( size_t i=0 ; i<SIZE ; i++){ */
/* // cout << Genome.x[i] << ":" << Genome.sigma[i] << "|"; */
/* printf("%.02f:%.02f|",Genome.x[i],Genome.sigma[i]); */
/* } */
\end
\GenomeClass::initialiser : // "initializer" is also accepted
for(int i=0; i<SIZE; i++ ) {
Genome.x[i] = (float)random(X_MIN,X_MAX);
Genome.sigma[i]=(float)random(0.,0.5);
}
\end
\GenomeClass::crossover :
for (int i=0; i<SIZE; i++)
{
float alpha = (float)random(0.,1.); // barycentric crossover
child.x[i] = alpha*parent1.x[i] + (1.-alpha)*parent2.x[i];
}
\end
\GenomeClass::mutator : // Must return the number of mutations
int NbMut=0;
float pond = 1./sqrt((float)SIZE);
for (int i=0; i<SIZE; i++)
if (tossCoin(pMutPerGene)){
NbMut++;
Genome.sigma[i] = Genome.sigma[i] * exp(SIGMA*pond*(float)gauss());
Genome.sigma[i] = MIN(0.5,Genome.sigma[0]);
Genome.sigma[i] = MAX(0.,Genome.sigma[0]);
Genome.x[i] += Genome.sigma[i]*(float)gauss();
Genome.x[i] = MIN(X_MAX,Genome.x[i]); // pour eviter les depassements
Genome.x[i] = MAX(X_MIN,Genome.x[i]);
}
return NbMut;
\end
\GenomeClass::evaluator : // Returns the score
float Score= 0.0;
Score= Rastrigin(Genome.x, SIZE);
return Score;
\end
\User Makefile options:
CPPFLAGS+=
\end
\Default run parameters : // Please let the parameters appear in this order
Number of generations : 100 // NB_GEN
Time limit: 0 // In seconds, 0 to deactivate
Population size : 2000 //POP_SIZE
Offspring size : 1600 // 40%
Mutation probability : 1 // MUT_PROB
Crossover probability : 1 // XOVER_PROB
Evaluator goal : minimise // Maximise
Selection operator: Tournament 2.0
Surviving parents: 100%//percentage or absolute
Surviving offspring: 100%
Reduce parents operator: Tournament 2
Reduce offspring operator: Tournament 2
Final reduce operator: Tournament 2
Elitism: Strong //Weak or Strong
Elite: 1
Print stats:1 //Default: 1
Generate csv stats file:0
Generate gnuplot script:0
Generate R script:0
Plot stats:0 //Default: 0
Remote island model: true
IP file: ip.txt //File containing all the remote island's IP
Save population: true
Start from file:false
\end
...@@ -158,8 +158,8 @@ return NbMut; ...@@ -158,8 +158,8 @@ return NbMut;
\GenomeClass::evaluator : // Returns the score \GenomeClass::evaluator : // Returns the score
float Score= 0.0; float Score= 0.0;
//Score= Weierstrass(Genome.x, SIZE); Score= Weierstrass(Genome.x, SIZE);
Score= rosenbrock(Genome.x); //Score= rosenbrock(Genome.x);
return Score; return Score;
\end \end
...@@ -170,8 +170,8 @@ CPPFLAGS+= ...@@ -170,8 +170,8 @@ CPPFLAGS+=
\Default run parameters : // Please let the parameters appear in this order \Default run parameters : // Please let the parameters appear in this order
Number of generations : 100 // NB_GEN Number of generations : 100 // NB_GEN
Time limit: 0 // In seconds, 0 to deactivate Time limit: 0 // In seconds, 0 to deactivate
Population size : 10 //POP_SIZE Population size : 100 //POP_SIZE
Offspring size : 10 // 40% Offspring size : 100 // 40%
Mutation probability : 1 // MUT_PROB Mutation probability : 1 // MUT_PROB
Crossover probability : 1 // XOVER_PROB Crossover probability : 1 // XOVER_PROB
Evaluator goal : minimise // Maximise Evaluator goal : minimise // Maximise
...@@ -183,11 +183,17 @@ CPPFLAGS+= ...@@ -183,11 +183,17 @@ CPPFLAGS+=
Final reduce operator: Tournament 2 Final reduce operator: Tournament 2
Elitism: Strong //Weak or Strong Elitism: Strong //Weak or Strong
Elite: 0 Elite: 1
Print stats:1 //Default: 1 Print stats:1 //Default: 1
Generate csv stats file:0 Generate csv stats file:0
Generate gnuplot script:0 Generate gnuplot script:0
Generate R script:0 Generate R script:0
Plot stats:0 //Default: 0 Plot stats:0 //Default: 0
Remote island model: true
IP file: ip.txt //File containing all the remote island's IP
Save population: true
Start from file:false
\end \end
...@@ -125,7 +125,7 @@ CEvolutionaryAlgorithm::CEvolutionaryAlgorithm(Parameters* params){ ...@@ -125,7 +125,7 @@ CEvolutionaryAlgorithm::CEvolutionaryAlgorithm(Parameters* params){
server = new CComUDPServer(2909,0); //1 if debug server = new CComUDPServer(2909,0); //1 if debug
this->treatedIndividuals = 0; this->treatedIndividuals = 0;
this->numberOfClients = 0; this->numberOfClients = 0;
this->myClientNumber=0;
this->initializeClients(); this->initializeClients();
} }
} }
...@@ -371,33 +371,34 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){ ...@@ -371,33 +371,34 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
//REMOTE ISLAND MODEL FUNCTIONS //REMOTE ISLAND MODEL FUNCTIONS
void CEvolutionaryAlgorithm::initializeClients(){ void CEvolutionaryAlgorithm::initializeClients(){
int clientNumber=0;
char (*clients)[16] = (char(*)[16])calloc(1,sizeof(char)*16); char (*clients)[16] = (char(*)[16])calloc(1,sizeof(char)*16);
// string clients[256];
cout << "Reading IP address file" << endl; cout << "Reading IP address file" << endl;
ifstream IP_File("ip.txt"); ifstream IP_File(this->params->ipFile);
string line; string line;
while(getline(IP_File, line)){ while(getline(IP_File, line)){
if(!isLocalMachine(line.c_str())){ if(!isLocalMachine(line.c_str())){
memmove(clients[this->numberOfClients],line.c_str(),sizeof(char)*16); memmove(clients[this->numberOfClients],line.c_str(),sizeof(char)*16);
//clients[this->numberOfClients] = line; this->numberOfClients++;
this->numberOfClients++; clients = (char(*)[16])realloc(clients,sizeof(char)*16*(this->numberOfClients*16));
clients = (char(*)[16])realloc(clients,sizeof(char)*16*(this->numberOfClients*16)); clientNumber++;
} }
else{
this->myClientNumber = clientNumber;
}
} }
this->Clients = (CComUDPClient**)malloc(this->numberOfClients*sizeof(CComUDPClient*)); this->Clients = (CComUDPClient**)malloc(this->numberOfClients*sizeof(CComUDPClient*));
for(int i=0; i<(signed)this->numberOfClients; i++){ for(int i=0; i<(signed)this->numberOfClients; i++){