Commit 1da585d6 authored by kruger's avatar kruger
Browse files

Modifications necessaires pour la version Windows

parent 4660d658
...@@ -26,7 +26,7 @@ Centre de Math ...@@ -26,7 +26,7 @@ Centre de Math
bool genomeSizeValidity=false; bool genomeSizeValidity=false;
int lineCounter = 0; int lineCounter = 0;
// local functions // local functions
char* selectorDetermination(int nMINIMISE, char* sSELECTOR){ char* selectorDetermination(int nMINIMISE, char* sSELECTOR){
char selectorName[50]; char selectorName[50];
...@@ -75,7 +75,7 @@ Centre de Math ...@@ -75,7 +75,7 @@ Centre de Math
%start COPY_EO_INITIALISER %start COPY_EO_INITIALISER
%start COPY COPY_INITIALISER COPY_CROSSOVER COPY_MUTATOR COPY_EVALUATOR COPY_FINALIZATION_FUNCTION %start COPY COPY_INITIALISER COPY_CROSSOVER COPY_MUTATOR COPY_EVALUATOR COPY_FINALIZATION_FUNCTION
%start COPY_DISPLAY COPY_USER_FUNCTION COPY_USER_GENERATION PARAMETERS_ANALYSIS GET_PARAMETERS %start COPY_DISPLAY COPY_USER_FUNCTION COPY_USER_GENERATION PARAMETERS_ANALYSIS GET_PARAMETERS
%start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION_BEFORE_REPLACEMENT GET_METHODS COPY_MAKEFILE_OPTION COPY_BOUND_CHECKING_FUNCTION COPY_BEG_GENERATION_FUNCTION COPY_END_GENERATION_FUNCTION COPY_INSTEAD_EVAL %start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION_BEFORE_REPLACEMENT GET_METHODS COPY_MAKEFILE_OPTION COPY_BOUND_CHECKING_FUNCTION COPY_BEG_GENERATION_FUNCTION COPY_END_GENERATION_FUNCTION
// lexical analyser name and class definition // lexical analyser name and class definition
%name CEASEALexer { %name CEASEALexer {
...@@ -187,15 +187,6 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -187,15 +187,6 @@ exponent ([Ee][+-]?[0-9]+)
} }
<TEMPLATE_ANALYSIS>"\\INSTEAD_EVAL_FUNCTION" {
//DEBUG_PRT_PRT("insert beg");
yyreset();
yyin = fpGenomeFile;
if (bVERBOSE) printf ("Evaluation population in a single function!!.\n");
BEGIN COPY_INSTEAD_EVAL;
}
<TEMPLATE_ANALYSIS>"\\INSERT_END_GENERATION_FUNCTION" { <TEMPLATE_ANALYSIS>"\\INSERT_END_GENERATION_FUNCTION" {
//DEBUG_PRT_PRT("insert end"); //DEBUG_PRT_PRT("insert end");
if (bVERBOSE) printf ("Inserting at the end of each generation function.\n"); if (bVERBOSE) printf ("Inserting at the end of each generation function.\n");
...@@ -506,7 +497,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -506,7 +497,7 @@ exponent ([Ee][+-]?[0-9]+)
if (bVERBOSE) printf ("Inserting user functions.\n"); if (bVERBOSE) printf ("Inserting user functions.\n");
yyreset(); yyreset();
yyin = fpGenomeFile; yyin = fpGenomeFile;
lineCounter=2; // switch to .ez file and analyser lineCounter=1; // switch to .ez file and analyser
BEGIN COPY_USER_FUNCTIONS; BEGIN COPY_USER_FUNCTIONS;
} }
<TEMPLATE_ANALYSIS>"\\INSERT_EO_INITIALISER" { <TEMPLATE_ANALYSIS>"\\INSERT_EO_INITIALISER" {
...@@ -540,13 +531,11 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -540,13 +531,11 @@ exponent ([Ee][+-]?[0-9]+)
<TEMPLATE_ANALYSIS>"\\INSERT_MUTATOR" { <TEMPLATE_ANALYSIS>"\\INSERT_MUTATOR" {
yyreset(); yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser yyin = fpGenomeFile; // switch to .ez file and analyser
lineCounter=1;
BEGIN COPY_MUTATOR; BEGIN COPY_MUTATOR;
} }
<TEMPLATE_ANALYSIS>"\\INSERT_EVALUATOR" { <TEMPLATE_ANALYSIS>"\\INSERT_EVALUATOR" {
yyreset(); yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser yyin = fpGenomeFile; // switch to .ez file and analyser
lineCounter=1;
BEGIN COPY_EVALUATOR; BEGIN COPY_EVALUATOR;
} }
...@@ -554,7 +543,6 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -554,7 +543,6 @@ exponent ([Ee][+-]?[0-9]+)
yyreset(); yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser yyin = fpGenomeFile; // switch to .ez file and analyser
bWithinCUDA_Evaluator = 1; bWithinCUDA_Evaluator = 1;
lineCounter=1;
BEGIN COPY_EVALUATOR; BEGIN COPY_EVALUATOR;
} }
...@@ -972,29 +960,6 @@ if(OPERATING_SYSTEM=WINDOWS) ...@@ -972,29 +960,6 @@ if(OPERATING_SYSTEM=WINDOWS)
} }
} }
<COPY_INSTEAD_EVAL>"\\Instead"[ \t\n]+"evaluation"[ \t\n]+"function:" {
//DEBUG_PRT_PRT("at each beg");
if( (TARGET==CUDA || TARGET==STD)){
fprintf (fpOutputFile,"{\n");
bFunction=1;
BEGIN COPY_USER_GENERATION;
}
}
<COPY_INSTEAD_EVAL>.|\n {}
<COPY_INSTEAD_EVAL><<EOF>> {
bBeginGenerationFunction=0; // No Generation function was found in the .ez file
if (bVERBOSE) printf("*** No Instead evaluation step function was found. ***\n");
fprintf(fpOutputFile,"\n// No Instead evaluation step function.\n");
rewind(fpGenomeFile);
yyin = fpTemplateFile;
BEGIN TEMPLATE_ANALYSIS;
bNotFinishedYet=1;
}
<COPY_BEG_GENERATION_FUNCTION><<EOF>> { <COPY_BEG_GENERATION_FUNCTION><<EOF>> {
bBeginGenerationFunction=0; // No Generation function was found in the .ez file bBeginGenerationFunction=0; // No Generation function was found in the .ez file
if (bVERBOSE) printf("*** No beginning generation function was found. ***\n"); if (bVERBOSE) printf("*** No beginning generation function was found. ***\n");
...@@ -1336,23 +1301,16 @@ if(OPERATING_SYSTEM=WINDOWS) ...@@ -1336,23 +1301,16 @@ if(OPERATING_SYSTEM=WINDOWS)
<COPY_CROSSOVER>\n {lineCounter++;} <COPY_CROSSOVER>\n {lineCounter++;}
<COPY_MUTATOR>"\\GenomeClass::mutator"[ \t\n]*":" { <COPY_MUTATOR>"\\GenomeClass::mutator"[ \t\n]*":" {
bWithinMutator=1; bWithinMutator=1;
if( bLINE_NUM_EZ_FILE )
fprintf(fpOutputFile,"#line %d \"%s.ez\"\n",lineCounter, sRAW_PROJECT_NAME);
BEGIN COPY_USER_FUNCTION; BEGIN COPY_USER_FUNCTION;
return USER_MUTATOR; return USER_MUTATOR;
} }
<COPY_MUTATOR>. {} <COPY_MUTATOR>.|\n {}
<COPY_MUTATOR>\n {lineCounter++;}
<COPY_EVALUATOR>"\\GenomeClass::evaluator"[ \t\n]*":" { <COPY_EVALUATOR>"\\GenomeClass::evaluator"[ \t\n]*":" {
BEGIN COPY_USER_FUNCTION; BEGIN COPY_USER_FUNCTION;
bWithinEvaluator=1; bWithinEvaluator=1;
if( bLINE_NUM_EZ_FILE )
fprintf(fpOutputFile,"#line %d \"%s.ez\"\n",lineCounter, sRAW_PROJECT_NAME);
return USER_EVALUATOR; return USER_EVALUATOR;
} }
<COPY_EVALUATOR>. {} <COPY_EVALUATOR>.|\n {}
<COPY_EVALUATOR>\n {lineCounter++;}
//**************************************** //****************************************
// Basic copy to .cpp file with major changes // Basic copy to .cpp file with major changes
...@@ -1682,7 +1640,7 @@ if(OPERATING_SYSTEM=WINDOWS) ...@@ -1682,7 +1640,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<GET_PARAMETERS>"Print"[ \t\n]+"stats"[ \t\n]*":"[\t\n]* {if (bVERBOSE) printf("\tPrint Stats...\n");return PRINT_STATS;} <GET_PARAMETERS>"Print"[ \t\n]+"stats"[ \t\n]*":"[\t\n]* {if (bVERBOSE) printf("\tPrint Stats...\n");return PRINT_STATS;}
<GET_PARAMETERS>"Plot"[ \t\n]+"stats"[ \t\n]*":"[\t\n]* {if (bVERBOSE) printf("\tPlot Stats with gnuplot...\n");return PLOT_STATS;} <GET_PARAMETERS>"Plot"[ \t\n]+"stats"[ \t\n]*":"[\t\n]* {if (bVERBOSE) printf("\tPlot Stats with gnuplot...\n");return PLOT_STATS;}
<GET_PARAMETERS>"Generate"[ \t\n]+"cvs"[ \t\n]+"stats"[ \t\n]+"file"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf("\tPrint Stats to cvs File...\n");return GENERATE_CVS_FILE;} <GET_PARAMETERS>"Generate"[ \t\n]+"csv"[ \t\n]+"stats"[ \t\n]+"file"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf("\tPrint Stats to cvs File...\n");return GENERATE_CVS_FILE;}
<GET_PARAMETERS>"Generate"[ \t\n]+"gnuplot"[ \t\n]+"script"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf("\tGenerate Gnuplot Script...\n");return GENERATE_GNUPLOT_SCRIPT;} <GET_PARAMETERS>"Generate"[ \t\n]+"gnuplot"[ \t\n]+"script"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf("\tGenerate Gnuplot Script...\n");return GENERATE_GNUPLOT_SCRIPT;}
<GET_PARAMETERS>"Generate"[ \t\n]+"R"[ \t\n]+"script"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf("\tGenerate R Script...\n");return GENERATE_R_SCRIPT;} <GET_PARAMETERS>"Generate"[ \t\n]+"R"[ \t\n]+"script"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf("\tGenerate R Script...\n");return GENERATE_R_SCRIPT;}
......
#ifdef WIN32
#pragma comment(lib, "WinMM.lib")
#endif
/* /*
* CEvolutionaryAlgorithm.cpp * CEvolutionaryAlgorithm.cpp
* *
...@@ -15,8 +13,8 @@ ...@@ -15,8 +13,8 @@
#endif #endif
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <windows.h>
#endif
#include <time.h> #include <time.h>
#endif
#include <math.h> #include <math.h>
#include <string> #include <string>
#include "include/CIndividual.h" #include "include/CIndividual.h"
...@@ -31,9 +29,6 @@ extern CEvolutionaryAlgorithm* EA; ...@@ -31,9 +29,6 @@ extern CEvolutionaryAlgorithm* EA;
void EASEABeginningGenerationFunction(CEvolutionaryAlgorithm* evolutionaryAlgorithm); void EASEABeginningGenerationFunction(CEvolutionaryAlgorithm* evolutionaryAlgorithm);
void EASEAEndGenerationFunction(CEvolutionaryAlgorithm* evolutionaryAlgorithm); void EASEAEndGenerationFunction(CEvolutionaryAlgorithm* evolutionaryAlgorithm);
void EASEAGenerationFunctionBeforeReplacement(CEvolutionaryAlgorithm* evolutionaryAlgorithm); void EASEAGenerationFunctionBeforeReplacement(CEvolutionaryAlgorithm* evolutionaryAlgorithm);
extern void evale_pop_chunk(CIndividual** pop, int popSize);
extern bool INSTEAD_EVAL_STEP;
/** /**
* @DEPRECATED the next contructor has to be used instead of this one. * @DEPRECATED the next contructor has to be used instead of this one.
*/ */
...@@ -115,19 +110,19 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){ ...@@ -115,19 +110,19 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
std::cout << "Parent's population initializing "<< std::endl; std::cout << "Parent's population initializing "<< std::endl;
this->initializeParentPopulation(); this->initializeParentPopulation();
if(!INSTEAD_EVAL_STEP) this->population->evaluateParentPopulation();
this->population->evaluateParentPopulation();
else
evale_pop_chunk(population->parents, population->parentPopulationSize);
this->population->currentEvaluationNb += this->params->parentPopulationSize; this->population->currentEvaluationNb += this->params->parentPopulationSize;
if(this->params->printInitialPopulation){ if(this->params->printInitialPopulation){
std::cout << *population << std::endl; std::cout << *population << std::endl;
} }
#ifdef WIN32
clock_t begin(clock());
#else
struct timeval begin; struct timeval begin;
gettimeofday(&begin,NULL); gettimeofday(&begin,NULL);
#endif
//Initialize elitPopulation //Initialize elitPopulation
if(params->elitSize) if(params->elitSize)
...@@ -138,10 +133,9 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){ ...@@ -138,10 +133,9 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
EASEABeginningGenerationFunction(this); EASEABeginningGenerationFunction(this);
population->produceOffspringPopulation(); population->produceOffspringPopulation();
if(!INSTEAD_EVAL_STEP)
population->evaluateOffspringPopulation(); population->evaluateOffspringPopulation();
else
evale_pop_chunk(population->offsprings, population->offspringPopulationSize);
population->currentEvaluationNb += this->params->offspringPopulationSize; population->currentEvaluationNb += this->params->offspringPopulationSize;
EASEAGenerationFunctionBeforeReplacement(this); EASEAGenerationFunctionBeforeReplacement(this);
...@@ -168,9 +162,8 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){ ...@@ -168,9 +162,8 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
population->reduceTotalPopulation(elitistPopulation); population->reduceTotalPopulation(elitistPopulation);
population->sortParentPopulation();
showPopulationStats(begin); showPopulationStats(begin);
bBest = population->Best;
EASEAEndGenerationFunction(this); EASEAEndGenerationFunction(this);
currentGeneration += 1; currentGeneration += 1;
...@@ -198,7 +191,12 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){ ...@@ -198,7 +191,12 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
} }
#ifdef WIN32
void CEvolutionaryAlgorithm::showPopulationStats(clock_t beginTime){
#else
void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
#endif
float currentAverageFitness=0.0; float currentAverageFitness=0.0;
float currentSTDEV=0.0; float currentSTDEV=0.0;
...@@ -223,27 +221,44 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){ ...@@ -223,27 +221,44 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
currentSTDEV/=population->parentPopulationSize; currentSTDEV/=population->parentPopulationSize;
currentSTDEV=sqrt(currentSTDEV); currentSTDEV=sqrt(currentSTDEV);
#ifdef WIN32
clock_t end(clock());
double duration;
duration = (double)(end-beginTime)/CLOCKS_PER_SEC;
#else
struct timeval end, res; struct timeval end, res;
gettimeofday(&end,0); gettimeofday(&end,0);
timersub(&end,&beginTime,&res); timersub(&end,&beginTime,&res);
#endif
//Affichage //Affichage
if(params->printStats){ if(params->printStats){
if(currentGeneration==0) if(currentGeneration==0)
printf("GEN\tTIME\t\tEVAL\tBEST\t\tAVG\t\tSTDEV\n\n"); printf("GEN\tTIME\t\tEVAL\tBEST\t\tAVG\t\tSTDEV\n\n");
#ifdef WIN32
printf("%lu\t%2.6f\t%lu\t%.15e\t%.15e\t%.15e\n",currentGeneration,duration,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
#else
printf("%lu\t%ld.%06ld\t%lu\t%.15e\t%.15e\t%.15e\n",currentGeneration,res.tv_sec,res.tv_usec,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV); printf("%lu\t%ld.%06ld\t%lu\t%.15e\t%.15e\t%.15e\n",currentGeneration,res.tv_sec,res.tv_usec,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
#endif
//printf("%lu\t%ld.%06ld\t%lu\t%f\t%f\t%f\n",currentGeneration,res.tv_sec,res.tv_usec,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV); //printf("%lu\t%ld.%06ld\t%lu\t%f\t%f\t%f\n",currentGeneration,res.tv_sec,res.tv_usec,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
} }
if((this->params->plotStats && this->gnuplot->valid) || this->params->generateGnuplotScript){ if((this->params->plotStats && this->gnuplot->valid) || this->params->generateGnuplotScript){
FILE *f; FILE *f;
string fichier (params->outputFilename); string fichier (params->outputFilename);
fichier.append(".dat"); f = fopen(params->outputFilename,"a"); //ajouter .dat
f = fopen(fichier.c_str(),"a"); //ajouter .dat
if(f!=NULL){ if(f!=NULL){
if(currentGeneration==0) if(currentGeneration==0)
fprintf(f,"#GEN\tTIME\t\tEVAL\tBEST\t\tAVG\t\tSTDEV\n\n"); fprintf(f,"#GEN\tTIME\t\tEVAL\tBEST\t\tAVG\t\tSTDEV\n\n");
#ifdef WIN32
fprintf(f,"%lu\t%2.6f\t%lu\t%.15e\t%.15e\t%.15e\n",currentGeneration,duration,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
#else
fprintf(f,"%lu\t%ld.%06ld\t%lu\t%.15e\t%.15e\t%.15e\n",currentGeneration,res.tv_sec,res.tv_usec,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV); fprintf(f,"%lu\t%ld.%06ld\t%lu\t%.15e\t%.15e\t%.15e\n",currentGeneration,res.tv_sec,res.tv_usec,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
#endif
fclose(f); fclose(f);
} }
} }
...@@ -255,7 +270,13 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){ ...@@ -255,7 +270,13 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
if(f!=NULL){ if(f!=NULL){
if(currentGeneration==0) if(currentGeneration==0)
fprintf(f,"GEN,TIME,EVAL,BEST,AVG,STDEV\n"); fprintf(f,"GEN,TIME,EVAL,BEST,AVG,STDEV\n");
#ifdef WIN32
fprintf(f,"%lu,%2.6f,%lu,%.15e,%.15e,%.15e\n",currentGeneration,duration,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
#else
fprintf(f,"%lu,%ld.%06ld,%lu,%.15e,%.15e,%.15e\n",currentGeneration,res.tv_sec,res.tv_usec,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV); fprintf(f,"%lu,%ld.%06ld,%lu,%.15e,%.15e,%.15e\n",currentGeneration,res.tv_sec,res.tv_usec,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
#endif
fclose(f); fclose(f);
} }
} }
...@@ -263,7 +284,7 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){ ...@@ -263,7 +284,7 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
#ifdef __linux__ #ifdef __linux__
if(this->params->plotStats && this->gnuplot->valid){ if(this->params->plotStats && this->gnuplot->valid){
if(currentGeneration==0) if(currentGeneration==0)
fprintf(this->gnuplot->fWrit,"plot \'%s.dat\' using 3:4 t \'Best Fitness\' w lines, \'%s.dat\' using 3:5 t \'Average\' w lines, \'%s.dat\' using 3:6 t \'StdDev\' w lines\n", params->outputFilename,params->outputFilename,params->outputFilename); fprintf(this->gnuplot->fWrit,"plot \'%s\' using 3:4 t \'Best Fitness\' w lines, \'%s\' using 3:5 t \'Average\' w lines, \'%s\' using 3:6 t \'StdDev\' w lines\n", params->outputFilename,params->outputFilename,params->outputFilename);
else else
fprintf(this->gnuplot->fWrit,"replot\n"); fprintf(this->gnuplot->fWrit,"replot\n");
fflush(this->gnuplot->fWrit); fflush(this->gnuplot->fWrit);
...@@ -271,7 +292,7 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){ ...@@ -271,7 +292,7 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
#endif #endif
params->timeCriterion->setElapsedTime(res.tv_sec); params->timeCriterion->setElapsedTime(duration);
} }
void CEvolutionaryAlgorithm::outputGraph(){ void CEvolutionaryAlgorithm::outputGraph(){
...@@ -326,27 +347,3 @@ bool CEvolutionaryAlgorithm::allCriteria(){ ...@@ -326,27 +347,3 @@ bool CEvolutionaryAlgorithm::allCriteria(){
} }
return false; return false;
} }
#ifdef WIN32
int gettimeofday
(struct timeval* tp, void* tzp) {
DWORD t;
t = timeGetTime();
tp->tv_sec = t / 1000;
tp->tv_usec = t % 1000;
/* 0 indicates success. */
return 0;
}
void timersub( const timeval * tvp, const timeval * uvp, timeval* vvp )
{
vvp->tv_sec = tvp->tv_sec - uvp->tv_sec;
vvp->tv_usec = tvp->tv_usec - uvp->tv_usec;
if( vvp->tv_usec < 0 )
{
--vvp->tv_sec;
vvp->tv_usec += 1000000;
}
}
#endif
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
* Created on: 22 juin 2009 * Created on: 22 juin 2009
* Author: maitre * Author: maitre
*/ */
#include "boost/program_options.hpp"
#include <boost/program_options.hpp>
#include <iostream> #include <iostream>
namespace po = boost::program_options; namespace po = boost::program_options;
...@@ -137,7 +136,7 @@ void parseArguments(const char* parametersFileName, int ac, char** av, ...@@ -137,7 +136,7 @@ void parseArguments(const char* parametersFileName, int ac, char** av,
("inputfile",po::value<string>(),"Set an input file for the initial 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)") ("printStats",po::value<int>(),"Print the Stats (default : 1)")
("plotStats",po::value<int>(),"Plot the Stats with gnuplot (default : 0)") ("plotStats",po::value<int>(),"Plot the Stats with gnuplot (default : 0)")
("generateCSV",po::value<int>(),"Print the Stats to a CSV File (Filename: ProjectName.csv) (default : 0)") ("generateCSVFile",po::value<int>(),"Print the Stats to a CSV File (Filename: ProjectName.dat) (default : 0)")
("generateGnuplotScript",po::value<int>(),"Generates a Gnuplot script to plat the Stats (Filename: ProjectName.plot) (default : 0)") ("generateGnuplotScript",po::value<int>(),"Generates a Gnuplot script to plat the Stats (Filename: ProjectName.plot) (default : 0)")
("generateRScript",po::value<int>(),"Generates a R script to plat the Stats (Filename: ProjectName.r) (default : 0)") ("generateRScript",po::value<int>(),"Generates a R script to plat the Stats (Filename: ProjectName.r) (default : 0)")
// ("printStatsFile",po::value<int>(),"Print the Stats to a File (Filename: ProjectName.dat) (default : 0)") // ("printStatsFile",po::value<int>(),"Print the Stats to a File (Filename: ProjectName.dat) (default : 0)")
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "include/CStoppingCriterion.h" #include "include/CStoppingCriterion.h"
#include <iostream> #include <iostream>
#include <signal.h> #include <signal.h>
#include "include/global.h"
#include "include/CEvolutionaryAlgorithm.h" #include "include/CEvolutionaryAlgorithm.h"
/* **************************************** /* ****************************************
...@@ -93,19 +92,3 @@ void signal_handler(int sig){ ...@@ -93,19 +92,3 @@ void signal_handler(int sig){
} }
/* ****************************************
Goal stopping criterion class
****************************************/
CGoalCriterion::CGoalCriterion( double goal, bool minimize ){
this->goal = goal;
this->minimize = minimize;
}
bool CGoalCriterion::reached(){
if( minimize ){
//printf("bf : %f\n",bBest->fitness);
return bBest->fitness <= goal;
}
else
return bBest->fitness >= goal;
}
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#define CEVOLUTIONARYALGORITHM_H_ #define CEVOLUTIONARYALGORITHM_H_
#include <stdlib.h> #include <stdlib.h>
#include <string> #include <string>
#include <time.h>
#include "CEvolutionaryAlgorithm.h" #include "CEvolutionaryAlgorithm.h"
#include "CSelectionOperator.h" #include "CSelectionOperator.h"
#include "CPopulation.h" #include "CPopulation.h"
...@@ -46,7 +47,11 @@ public: ...@@ -46,7 +47,11 @@ public:
size_t reduceParents; size_t reduceParents;
size_t reduceOffsprings; size_t reduceOffsprings;
#ifdef WIN32
void showPopulationStats(clock_t beginTime);
#else
void showPopulationStats(struct timeval beginTime); void showPopulationStats(struct timeval beginTime);
#endif
void generateGnuplotScript(); void generateGnuplotScript();
void generateRScript(); void generateRScript();
...@@ -61,9 +66,4 @@ public: ...@@ -61,9 +66,4 @@ public:
std::string* inputfile; std::string* inputfile;
}; };
#ifdef WIN32
int gettimeofday(struct timeval* tp, void* tzp);
void timersub( const timeval * tvp, const timeval * uvp, timeval* vvp );
#endif
#endif /* CEVOLUTIONARYALGORITHM_H_ */ #endif /* CEVOLUTIONARYALGORITHM_H_ */
...@@ -58,19 +58,6 @@ class CTimeCriterion : public CStoppingCriterion { ...@@ -58,19 +58,6 @@ class CTimeCriterion : public CStoppingCriterion {
void setElapsedTime(size_t elapsedTime); void setElapsedTime(size_t elapsedTime);
}; };
/* ****************************************
Goal stopping criterion class
****************************************/
class CGoalCriterion : public CStoppingCriterion {
private:
double goal;
bool minimize;
public:
virtual bool reached();
CGoalCriterion( double goal, bool minimize );
};
/* **************************************** /* ****************************************
ControlCStopingCriterion class ControlCStopingCriterion class
****************************************/ ****************************************/
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
//#define true 1; //#define true 1;
//#define false 0; //#define false 0;
class CIndividual; class CIndividual;
class CRandomGenerator;
extern CIndividual** pPopulation; extern CIndividual** pPopulation;
extern CIndividual* bBest; extern CIndividual* bBest;
extern float* pEZ_MUT_PROB; extern float* pEZ_MUT_PROB;
......
...@@ -287,7 +287,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){ ...@@ -287,7 +287,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->printInitialPopulation = setVariable("printInitialPopulation",0); this->printInitialPopulation = setVariable("printInitialPopulation",0);
this->printFinalPopulation = setVariable("printFinalPopulation",0); this->printFinalPopulation = setVariable("printFinalPopulation",0);
this->outputFilename = (char*)"EASEA"; this->outputFilename = (char*)"EASEA.dat";
this->plotOutputFilename = (char*)"EASEA.png"; this->plotOutputFilename = (char*)"EASEA.png";
} }
......
...@@ -81,7 +81,7 @@ int main(int argc, char** argv){ ...@@ -81,7 +81,7 @@ int main(int argc, char** argv){
using namespace std; using namespace std;
#include "EASEAIndividual.hpp" #include "EASEAIndividual.hpp"
bool INSTEAD_EVAL_STEP = false;
CRandomGenerator* globalRandomGenerator; CRandomGenerator* globalRandomGenerator;
extern CEvolutionaryAlgorithm* EA; extern CEvolutionaryAlgorithm* EA;
...@@ -99,11 +99,6 @@ extern CEvolutionaryAlgorithm* EA; ...@@ -99,11 +99,6 @@ extern CEvolutionaryAlgorithm* EA;