Commit c0c9e7f1 authored by Frédéric Krüger's avatar Frédéric Krüger

Changements mineurs

parent 93f13b12
......@@ -22,7 +22,7 @@
#include <string.h>
#include "include/CIndividual.h"
#include "include/Parameters.h"
#include "include/CGnuplot.h"
#include "include/CGrapher.h"
#include "include/global.h"
#include "include/CComUDPLayer.h"
#include "include/CRandomGenerator.h"
......@@ -95,13 +95,13 @@ CEvolutionaryAlgorithm::CEvolutionaryAlgorithm(Parameters* params){
this->reduceParents = 0;
this->reduceOffsprings = 0;
this->gnuplot = NULL;
if(params->plotStats || params->generateGnuplotScript){
this->grapher = NULL;
if(params->plotStats || params->generatePlotScript){
string fichier = params->outputFilename;
fichier.append(".dat");
remove(fichier.c_str());
}
if(params->generateGnuplotScript){
if(params->generatePlotScript){
string fichier = params->outputFilename;
fichier.append(".plot");
remove(fichier.c_str());
......@@ -121,8 +121,8 @@ CEvolutionaryAlgorithm::CEvolutionaryAlgorithm(Parameters* params){
string str = "Plotting of the evolution of ";;
string str2 = this->params->outputFilename;
str.append(str2);
//this->gnuplot = new CGnuplot((this->params->offspringPopulationSize*this->params->nbGen)+this->params->parentPopulationSize, (char*)str.c_str());
this->gnuplot = new CGnuplot(this->params, (char*)str.c_str());
//this->grapher = new CGrapher((this->params->offspringPopulationSize*this->params->nbGen)+this->params->parentPopulationSize, (char*)str.c_str());
this->grapher = new CGrapher(this->params, (char*)str.c_str());
}
#endif
......@@ -249,9 +249,9 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
currentGeneration += 1;
}
//#ifdef __linux__
//if(this->params->plotStats && this->gnuplot->valid){
//if(this->params->plotStats && this->grapher->valid){
//outputGraph();
//delete this->gnuplot;
//delete this->grapher;
//}
//#endif
......@@ -269,8 +269,8 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
population->serializePopulation();
}
if(this->params->generateGnuplotScript || !this->params->plotStats)
generateGnuplotScript();
if(this->params->generatePlotScript || !this->params->plotStats)
generatePlotScript();
if(this->params->generateRScript)
generateRScript();
......@@ -279,7 +279,7 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
free(elitistPopulation);
if(this->params->plotStats){
delete this->gnuplot;
delete this->grapher;
}
}
......@@ -342,7 +342,7 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
#endif
}
if((this->params->plotStats && this->gnuplot->valid) || this->params->generateGnuplotScript){
if((this->params->plotStats && this->grapher->valid) || this->params->generatePlotScript){
FILE *f;
string fichier = params->outputFilename;
fichier.append(".dat");
......@@ -376,27 +376,27 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
fclose(f);
}
}
//print Gnuplot
//print grapher
#ifndef WIN32
if(this->params->plotStats && this->gnuplot->valid){
if(this->params->plotStats && this->grapher->valid){
//if(currentGeneration==0)
// fprintf(this->gnuplot->fWrit,"plot \'%s.dat\' using 3:4 t \'Best Fitness\' w lines ls 1, \'%s.dat\' using 3:5 t \'Average\' w lines ls 4, \'%s.dat\' using 3:6 t \'StdDev\' w lines ls 3\n", params->outputFilename,params->outputFilename,params->outputFilename);
// fprintf(this->grapher->fWrit,"plot \'%s.dat\' using 3:4 t \'Best Fitness\' w lines ls 1, \'%s.dat\' using 3:5 t \'Average\' w lines ls 4, \'%s.dat\' using 3:6 t \'StdDev\' w lines ls 3\n", params->outputFilename,params->outputFilename,params->outputFilename);
//else
// fprintf(this->gnuplot->fWrit,"replot\n");
fprintf(this->gnuplot->fWrit,"add coordinate:%d;%f;%f;%f\n",population->currentEvaluationNb, population->Best->fitness, this->cstats->currentAverageFitness, this->cstats->currentStdDev);
// fprintf(this->grapher->fWrit,"replot\n");
fprintf(this->grapher->fWrit,"add coordinate:%d;%f;%f;%f\n",population->currentEvaluationNb, population->Best->fitness, this->cstats->currentAverageFitness, this->cstats->currentStdDev);
if(this->params->remoteIslandModel){
if(population->Best->isImmigrant){
fprintf(this->gnuplot->fWrit,"set immigrant\n");
fprintf(this->grapher->fWrit,"set immigrant\n");
}
fprintf(this->gnuplot->fWrit,"add stat:%d;%d;%d\n",currentGeneration, this->cstats->currentNumberOfImmigrants, this->cstats->currentNumberOfImmigrantReproductions);
fprintf(this->grapher->fWrit,"add stat:%d;%d;%d\n",currentGeneration, this->cstats->currentNumberOfImmigrants, this->cstats->currentNumberOfImmigrantReproductions);
}
if(currentGeneration==0){
fprintf(this->gnuplot->fWrit,"paint\n");
fprintf(this->grapher->fWrit,"paint\n");
}
else{
fprintf(this->gnuplot->fWrit,"repaint\n");
fprintf(this->grapher->fWrit,"repaint\n");
}
fflush(this->gnuplot->fWrit);
fflush(this->grapher->fWrit);
}
#endif
......@@ -511,16 +511,16 @@ void CEvolutionaryAlgorithm::receiveIndividuals(){
}
void CEvolutionaryAlgorithm::outputGraph(){
/* fprintf(this->gnuplot->fWrit,"set term png\n");
fprintf(this->gnuplot->fWrit,"set output \"%s\"\n",params->plotOutputFilename);
fprintf(this->gnuplot->fWrit,"set xrange[0:%d]\n",(int)population->currentEvaluationNb);
fprintf(this->gnuplot->fWrit,"set xlabel \"Number of Evaluations\"\n");
fprintf(this->gnuplot->fWrit,"set ylabel \"Fitness\"\n");
fprintf(this->gnuplot->fWrit,"replot \n");
fflush(this->gnuplot->fWrit);*/
/* fprintf(this->grapher->fWrit,"set term png\n");
fprintf(this->grapher->fWrit,"set output \"%s\"\n",params->plotOutputFilename);
fprintf(this->grapher->fWrit,"set xrange[0:%d]\n",(int)population->currentEvaluationNb);
fprintf(this->grapher->fWrit,"set xlabel \"Number of Evaluations\"\n");
fprintf(this->grapher->fWrit,"set ylabel \"Fitness\"\n");
fprintf(this->grapher->fWrit,"replot \n");
fflush(this->grapher->fWrit);*/
}
void CEvolutionaryAlgorithm::generateGnuplotScript(){
void CEvolutionaryAlgorithm::generatePlotScript(){
FILE* f;
string fichier = this->params->outputFilename;
fichier.append(".plot");
......
#include "include/CGnuplot.h"
#include "include/CGrapher.h"
#include "include/Parameters.h"
#include <stdio.h>
#include <string.h>
CGnuplot::CGnuplot(Parameters* param, char* title){
CGrapher::CGrapher(Parameters* param, char* title){
#ifndef WIN32
int toFils[2];
int toPere[2];
......@@ -79,7 +79,7 @@ CGnuplot::CGnuplot(Parameters* param, char* title){
#endif
}
CGnuplot::~CGnuplot(){
CGrapher::~CGrapher(){
#ifndef WIN32
//fprintf(this->fWrit,"quit\n");
fclose(this->fRead);
......
......@@ -147,9 +147,9 @@ void parseArguments(const char* parametersFileName, int ac, char** av,
("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)")
("plotStats",po::value<int>(),"Plot the Stats with gnuplot (default : 0)")
("plotStats",po::value<int>(),"Plot the Stats (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)")
("generatePlotScript",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)")
// ("printStatsFile",po::value<int>(),"Print the Stats to a File (Filename: ProjectName.dat) (default : 0)")
("printInitialPopulation",po::value<int>(),"Prints the initial population (default : 0)")
......
......@@ -7,7 +7,7 @@ CXXFLAGS = -g -Wall -fmessage-length=0 #-I../boost/
OBJS = CRandomGenerator.o CSelectionOperator.o CEvolutionaryAlgorithm.o\
CStoppingCriterion.o COptionParser.o CPopulation.o CIndividual.o\
CGnuplot.o CCmaes.o CCmaesCuda.o Parameters.o CGPNode.o\
CGrapher.o CCmaes.o CCmaesCuda.o Parameters.o CGPNode.o\
CComUDPLayer.o CCuda.o CStats.o
ifneq ("$(OS)","")
......
......@@ -21,7 +21,7 @@
#endif
class Parameters;
class CGnuplot;
class CGrapher;
class CEvolutionaryAlgorithm {
public:
......@@ -65,13 +65,13 @@ public:
#else
void showPopulationStats(struct timeval beginTime);
#endif
void generateGnuplotScript();
void generatePlotScript();
void generateRScript();
void outputGraph();
Parameters* params;
CGnuplot* gnuplot;
CGrapher* grapher;
CStats* cstats;
......
/*
* CGnuplot.h
* CGrapher.h
*
* Created on: 23 juin 2009
* Author: maitre
*/
#ifndef CGNUPLOT_H_
#define CGNUPLOT_H_
#ifndef CGRAPHER_H_
#define CGRAPHER_H_
class CRandomGenerator;
#include <iostream>
#include <stdlib.h>
#include "Parameters.h"
class CGnuplot {
class CGrapher {
public:
FILE *fWrit;
FILE *fRead;
int pid;
int valid;
public:
CGnuplot(Parameters* param, char* title);
~CGnuplot();
CGrapher(Parameters* param, char* title);
~CGrapher();
};
#endif /* CGNUPLOT_H_ */
#endif /* CGRAPHER_H_ */
......@@ -60,7 +60,7 @@ public:
//Miscalleous parameters
int printStats;
int generateCSVFile;
int generateGnuplotScript;
int generatePlotScript;
int generateRScript;
int plotStats;
int printInitialPopulation;
......
......@@ -293,7 +293,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generatePlotScript = setVariable("generatePlotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
......@@ -519,11 +519,11 @@ endif
##### Stats Ouput #####
--printStats=\PRINT_STATS #print Stats to screen
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--plotStats=\PLOT_STATS #plot Stats
--printInitialPopulation=0 #Print initial population
--printFinalPopulation=0 #Print final population
--generateCSVFile=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generatePlotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
#### Population save ####
......
......@@ -433,7 +433,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generatePlotScript = setVariable("generatePlotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
......@@ -803,11 +803,11 @@ clean:
##### Stats Ouput #####
--printStats=\PRINT_STATS #print Stats to screen
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--plotStats=\PLOT_STATS #plot Stats
--printInitialPopulation=0 #Print initial population
--printFinalPopulation=0 #Print final population
--generateCSVFile=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generatePlotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
\TEMPLATE_END
......@@ -485,7 +485,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generatePlotScript = setVariable("generatePlotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
......@@ -886,9 +886,9 @@ clean:
##### Stats Ouput #####
--printStats=\PRINT_STATS #print Stats to screen
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--plotStats=\PLOT_STATS #plot Stats
--generateCSVFile=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generatePlotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
#### Population save ####
......
......@@ -832,7 +832,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generatePlotScript = setVariable("generatePlotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
......@@ -1173,11 +1173,11 @@ easeaclean:
##### Stats Ouput #####
--printStats=\PRINT_STATS #print Stats to screen
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--plotStats=\PLOT_STATS #plot Stats
--printInitialPopulation=0 #Print initial population
--printFinalPopulation=0 #Print final population
--generateCSV=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generatePlotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
#### Population save ####
......
......@@ -561,7 +561,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generatePlotScript = setVariable("generatePlotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
......@@ -976,11 +976,11 @@ clean:
##### Stats Ouput #####
--printStats=\PRINT_STATS #print Stats to screen
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--plotStats=\PLOT_STATS #plot Stats
--printInitialPopulation=0 #Print initial population
--printFinalPopulation=0 #Print final population
--generateCSVFile=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generatePlotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
#### Population save ####
......
......@@ -289,7 +289,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generatePlotScript = setVariable("generatePlotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
......@@ -517,11 +517,11 @@ endif
##### Stats Ouput #####
--printStats=\PRINT_STATS #print Stats to screen
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--plotStats=\PLOT_STATS #plot Stats
--printInitialPopulation=0 #Print initial population
--printFinalPopulation=0 #Print final population
--generateCSV=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generatePlotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
#### Population save ####
......
......@@ -313,7 +313,7 @@ void ParametersImpl::setDefaultParameters(int argc, char** argv){
this->printStats = setVariable("printStats",\PRINT_STATS);
this->generateCSVFile = setVariable("generateCSVFile",\GENERATE_CSV_FILE);
this->generateGnuplotScript = setVariable("generateGnuplotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generatePlotScript = setVariable("generatePlotScript",\GENERATE_GNUPLOT_SCRIPT);
this->generateRScript = setVariable("generateRScript",\GENERATE_R_SCRIPT);
this->plotStats = setVariable("plotStats",\PLOT_STATS);
this->printInitialPopulation = setVariable("printInitialPopulation",0);
......@@ -559,11 +559,11 @@ endif
##### Stats Ouput #####
--printStats=\PRINT_STATS #print Stats to screen
--plotStats=\PLOT_STATS #plot Stats with gnuplot (requires Gnuplot)
--plotStats=\PLOT_STATS #plot Stats
--printInitialPopulation=0 #Print initial population
--printFinalPopulation=0 #Print final population
--generateCSVFile=\GENERATE_CSV_FILE
--generateGnuplotScript=\GENERATE_GNUPLOT_SCRIPT
--generatePlotScript=\GENERATE_GNUPLOT_SCRIPT
--generateRScript=\GENERATE_R_SCRIPT
#### Population save ####
......
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