Commit 876ad2d7 authored by kruger's avatar kruger

Derniere modification pour la version en ilot

parent 59f6c622
......@@ -58,6 +58,7 @@ extern int TARGET_FLAVOR;
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 float fMIGRATION_PROBABILITY;
extern unsigned iMAX_INIT_TREE_D,iMIN_INIT_TREE_D,iMAX_TREE_D,iNB_GPU,iPRG_BUF_SIZE,iMAX_TREE_DEPTH,iNO_FITNESS_CASES;
......
This diff is collapsed.
......@@ -1139,6 +1139,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<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>"\\MIGRATION_PROBABILITY" {fprintf(fpOutputFile,"%f",fMIGRATION_PROBABILITY);}
<TEMPLATE_ANALYSIS>"\\PRINT_STATS" {fprintf(fpOutputFile,"%d",bPRINT_STATS);}
<TEMPLATE_ANALYSIS>"\\PLOT_STATS" {fprintf(fpOutputFile,"%d",bPLOT_STATS);}
......@@ -2146,6 +2147,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<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;}
<GET_PARAMETERS>"Migration"[ \t\n]+"probability"[ \t\n]*":"[ \t\n]* {if(bVERBOSE) printf("\tMigration Probability...\n"); return MIGRATION_PROBABILITY;}
// number
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
#include <cyacc.h>
#line 68 "EaseaParse.y"
#line 69 "EaseaParse.y"
// forward references
class CSymbol;
......@@ -11,7 +11,7 @@ class CSymbol;
#line 12 "EaseaParse.h"
#ifndef YYSTYPE
union tagYYSTYPE {
#line 74 "EaseaParse.y"
#line 75 "EaseaParse.y"
CSymbol* pSymbol;
double dValue;
......@@ -67,28 +67,29 @@ union tagYYSTYPE {
#define ELITE 296
#define REMOTE_ISLAND_MODEL 297
#define IP_FILE 298
#define PRINT_STATS 299
#define PLOT_STATS 300
#define GENERATE_CSV_FILE 301
#define GENERATE_GNUPLOT_SCRIPT 302
#define GENERATE_R_SCRIPT 303
#define SAVE_POPULATION 304
#define START_FROM_FILE 305
#define TIME_LIMIT 306
#define MAX_INIT_TREE_D 307
#define MIN_INIT_TREE_D 308
#define MAX_XOVER_DEPTH 309
#define MAX_MUTAT_DEPTH 310
#define MAX_TREE_D 311
#define NB_GPU 312
#define PRG_BUF_SIZE 313
#define NO_FITNESS_CASES 314
#line 157 "EaseaParse.y"
#define MIGRATION_PROBABILITY 299
#define PRINT_STATS 300
#define PLOT_STATS 301
#define GENERATE_CSV_FILE 302
#define GENERATE_GNUPLOT_SCRIPT 303
#define GENERATE_R_SCRIPT 304
#define SAVE_POPULATION 305
#define START_FROM_FILE 306
#define TIME_LIMIT 307
#define MAX_INIT_TREE_D 308
#define MIN_INIT_TREE_D 309
#define MAX_XOVER_DEPTH 310
#define MAX_MUTAT_DEPTH 311
#define MAX_TREE_D 312
#define NB_GPU 313
#define PRG_BUF_SIZE 314
#define NO_FITNESS_CASES 315
#line 159 "EaseaParse.y"
#include "EaseaSym.h"
#include "EaseaLex.h"
#line 92 "EaseaParse.h"
#line 93 "EaseaParse.h"
/////////////////////////////////////////////////////////////////////////////
// CEASEAParser
......@@ -109,7 +110,7 @@ protected:
#endif
public:
#line 164 "EaseaParse.y"
#line 166 "EaseaParse.y"
protected:
CEASEALexer EASEALexer; // the lexical analyser
......@@ -125,7 +126,7 @@ public:
virtual void yysyntaxerror();
#line 129 "EaseaParse.h"
#line 130 "EaseaParse.h"
};
#ifndef YYPARSENAME
......
......@@ -49,6 +49,7 @@ bool bGENERATE_CSV_FILE=0, bGENERATE_R_SCRIPT=0, bGENERATE_GNUPLOT_SCRIPT=0;
bool bSAVE_POPULATION=0, bSTART_FROM_FILE=0;
bool bBALDWINISM=0; //memetic
bool bREMOTE_ISLAND_MODEL=0; //remote island model
float fMIGRATION_PROBABILITY=0.0;
char sIP_FILE[128]; //remote island model
int nPOP_SIZE, nOFF_SIZE;
float fSURV_PAR_SIZE=-1.0, fSURV_OFF_SIZE=-1.0;
......@@ -137,6 +138,7 @@ class CSymbol;
%token ELITE
%token REMOTE_ISLAND_MODEL //island model
%token IP_FILE //island model
%token MIGRATION_PROBABILITY //island model
%token PRINT_STATS
%token PLOT_STATS
%token GENERATE_CSV_FILE
......@@ -632,6 +634,9 @@ Parameter
strcat(sIP_FILE,".");
strcat(sIP_FILE,$4->sName);
}
| MIGRATION_PROBABILITY NUMBER2{
fMIGRATION_PROBABILITY=(float)$2;
}
| PRINT_STATS IDENTIFIER2{
if (!mystricmp($2->sName,"False")) bPRINT_STATS=0;
......
......@@ -192,6 +192,7 @@ CPPFLAGS+=
Remote island model: true
IP file: ip.txt //File containing all the remote island's IP
Migration probability: 0.1
Save population: true
Start from file:false
......
......@@ -192,7 +192,7 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
EASEABeginningGenerationFunction(this);
// Sending individuals if remote island model
if(params->remoteIslandModel && this->numberOfClients>0)
if(params->remoteIslandModel)
this->sendIndividual();
population->produceOffspringPopulation();
......@@ -409,7 +409,7 @@ void CEvolutionaryAlgorithm::initializeClients(){
void CEvolutionaryAlgorithm::sendIndividual(){
//Sending an individual every n generations
if(this->currentGeneration%(10+this->myClientNumber)==0){
if(globalRandomGenerator->random(0.0,1.0)<=params->migrationProbability){
//cout << "I'm going to send an Individual now" << endl;
//this->population->selectionOperator->initialize(this->population->parents, 7, this->population->actualParentPopulationSize);
//size_t index = this->population->selectionOperator->selectNext(this->population->actualParentPopulationSize);
......
......@@ -142,6 +142,7 @@ void parseArguments(const char* parametersFileName, int ac, char** av,
("baldwinism",po::value<int>(),"Only keep fitness (default : 0)")
("remoteIslandModel",po::value<int>(),"Boolean to activate the individual exachange with remote islands (default : 0)")
("ipFile",po::value<string>(),"File containing all the IPs of the remote islands)")
("migrationProbability", po::value<float>(),"Probability to send an individual each generation")
("outputfile",po::value<string>(),"Set an output file for the final population (default : none)")
("inputfile",po::value<string>(),"Set an input file for the initial population (default : none)")
("printStats",po::value<int>(),"Print the Stats (default : 1)")
......
......@@ -72,6 +72,7 @@ public:
//Parameters for the Island Model
bool remoteIslandModel;
char* ipFile;
float migrationProbability;
char* outputFilename;
char* plotOutputFilename;
......
......@@ -318,6 +318,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->remoteIslandModel = setVariable("remoteIslandModel",\REMOTE_ISLAND_MODEL);
this->ipFile = (char*)setVariable("ipFile","\IP_FILE").c_str();
this->migrationProbability = setVariable("migrationProbability",(float)\MIGRATION_PROBABILITY);
}
CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
......@@ -655,4 +656,5 @@ easeaclean:
#### Remote Island Model ####
--remoteIslandModel=\REMOTE_ISLAND_MODEL #To initialize communications with remote AESAE's
--ipFile=\IP_FILE
--migrationProbability=\MIGRATION_PROBABILITY #Probability to send an individual every generation
\TEMPLATE_END
......@@ -487,7 +487,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->remoteIslandModel = setVariable("remoteIslandModel",\REMOTE_ISLAND_MODEL);
this->ipFile = (char*)setVariable("ipFile","\IP_FILE").c_str();
this->migrationProbability = setVariable("migrationProbability",(float)\MIGRATION_PROBABILITY);
}
......@@ -880,4 +880,6 @@ clean:
#### Remote Island Model ####
--remoteIslandModel=\REMOTE_ISLAND_MODEL #To initialize communications with remote AESAE's
--ipFile=\IP_FILE
--migrationProbability=\MIGRATION_PROBABILITY #Probability to send an individual every generation
\TEMPLATE_END
......@@ -797,9 +797,15 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
this->printFinalPopulation = setVariable("printFinalPopulation",0);
this->savePopulation = setVariable("savePopulation",\SAVE_POPULATION);
this->startFromFile = setVariable("startFromFile",\START_FROM_FILE);
this->outputFilename = (char*)"EASEA";
this->plotOutputFilename = (char*)"EASEA.png";
this->remoteIslandModel = setVariable("remoteIslandModel",\REMOTE_ISLAND_MODEL);
this->ipFile = (char*)setVariable("ipFile","\IP_FILE").c_str();
this->migrationProbability = setVariable("migrationProbability",(float)\MIGRATION_PROBABILITY);
}
CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
......@@ -822,9 +828,22 @@ CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
}
void EvolutionaryAlgorithmImpl::initializeParentPopulation(){
for( unsigned int i=0 ; i< this->params->parentPopulationSize ; i++){
this->population->addIndividualParentPopulation(new IndividualImpl());
}
if(this->params->startFromFile){
ifstream AESAE_File("EASEA.pop");
string AESAE_Line;
for( unsigned int i=0 ; i< this->params->parentPopulationSize ; i++){
getline(AESAE_File, AESAE_Line);
this->population->addIndividualParentPopulation(new IndividualImpl(),i);
((IndividualImpl*)this->population->parents[i])->deserialize(AESAE_Line);
}
}
else{
for( unsigned int i=0 ; i< this->params->parentPopulationSize ; i++){
this->population->addIndividualParentPopulation(new IndividualImpl(),i);
}
}
this->population->actualParentPopulationSize = this->params->parentPopulationSize;
}
......@@ -1115,4 +1134,14 @@ easeaclean:
--generateCSV=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
#### Population save ####
--savePopulation=\SAVE_POPULATION #save population to EASEA.pop file
--startFromFile=\START_FROM_FILE #start optimisation from EASEA.pop file
#### Remote Island Model ####
--remoteIslandModel=\REMOTE_ISLAND_MODEL #To initialize communications with remote AESAE's
--ipFile=\IP_FILE
--migrationProbability=\MIGRATION_PROBABILITY #Probability to send an individual every generation
\TEMPLATE_END
......@@ -569,6 +569,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->remoteIslandModel = setVariable("remoteIslandModel",\REMOTE_ISLAND_MODEL);
this->ipFile = (char*)setVariable("ipFile","\IP_FILE").c_str();
this->migrationProbability = setVariable("migrationProbability",(float)\MIGRATION_PROBABILITY);
}
CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
......@@ -979,4 +980,6 @@ clean:
#### Remote Island Model ####
--remoteIslandModel=\REMOTE_ISLAND_MODEL #To initialize communications with remote AESAE's
--ipFile=\IP_FILE
--migrationProbability=\MIGRATION_PROBABILITY #Probability to send an individual every generation
\TEMPLATE_END
......@@ -312,6 +312,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->remoteIslandModel = setVariable("remoteIslandModel",\REMOTE_ISLAND_MODEL);
this->ipFile = (char*)setVariable("ipFile","\IP_FILE").c_str();
this->migrationProbability = setVariable("migrationProbability",(float)\MIGRATION_PROBABILITY);
}
CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
......@@ -651,4 +652,5 @@ easeaclean:
#### Remote Island Model ####
--remoteIslandModel=\REMOTE_ISLAND_MODEL #To initialize communications with remote AESAE's
--ipFile=\IP_FILE
--migrationProbability=\MIGRATION_PROBABILITY #Probability to send an individual every generation
\TEMPLATE_END
......@@ -337,6 +337,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->remoteIslandModel = setVariable("remoteIslandModel",\REMOTE_ISLAND_MODEL);
this->ipFile = (char*)setVariable("ipFile","\IP_FILE").c_str();
this->migrationProbability = setVariable("migrationProbability",(float)\MIGRATION_PROBABILITY);
}
CEvolutionaryAlgorithm* ParametersImpl::newEvolutionaryAlgorithm(){
......@@ -691,6 +692,7 @@ easeaclean:
--startFromFile=\START_FROM_FILE #start optimisation from EASEA.pop file
#### Remote Island Model ####
--remoteIslandModel=\REMOTE_ISLAND_MODEL #To initialize communications with remote AESAE's
a-remoteIslandModel=\REMOTE_ISLAND_MODEL #To initialize communications with remote AESAE's
--ipFile=\IP_FILE
--migrationProbability=\MIGRATION_PROBABILITY #Probability to send an individual every generation
\TEMPLATE_END
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