finish the handling of gnuplot completely at build-time.
No gnuplot-ifs in headers anymore.
This commit is contained in:
parent
4eb298ac73
commit
afc0659e35
12 changed files with 219 additions and 192 deletions
|
|
@ -26,8 +26,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <gp/eoParseTree.h>
|
#include "gp/eoParseTree.h"
|
||||||
#include <eo>
|
#include "eo"
|
||||||
|
|
||||||
using namespace gp_parse_tree;
|
using namespace gp_parse_tree;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
@ -130,7 +130,7 @@ int main(int argc, char *argv[])
|
||||||
checkPoint.add(avg);
|
checkPoint.add(avg);
|
||||||
checkPoint.add(best);
|
checkPoint.add(best);
|
||||||
|
|
||||||
#if !defined(NO_GNUPLOT)
|
#ifdef HAVE_GNUPLOT
|
||||||
eoGnuplot1DMonitor gnuplotmonitor("gnuplotBestStats");
|
eoGnuplot1DMonitor gnuplotmonitor("gnuplotBestStats");
|
||||||
gnuplotmonitor.add(generationCounter);
|
gnuplotmonitor.add(generationCounter);
|
||||||
gnuplotmonitor.add(best);
|
gnuplotmonitor.add(best);
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,6 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
|
||||||
fileMonitor->add(*secondStat);
|
fileMonitor->add(*secondStat);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(NO_GNUPLOT)
|
|
||||||
if (plotBestParam.value()) // an eoGnuplot1DMonitor for best & average
|
if (plotBestParam.value()) // an eoGnuplot1DMonitor for best & average
|
||||||
{
|
{
|
||||||
std::string stmp = dirNameParam.value() + "/gnu_best.xg";
|
std::string stmp = dirNameParam.value() + "/gnu_best.xg";
|
||||||
|
|
@ -241,7 +240,6 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoEval
|
||||||
// and of course add it to the checkpoint
|
// and of course add it to the checkpoint
|
||||||
checkpoint->add(*fitSnapshot);
|
checkpoint->add(*fitSnapshot);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// State savers
|
// State savers
|
||||||
|
|
|
||||||
|
|
@ -49,17 +49,25 @@ template <class EOT>
|
||||||
eoCheckPoint<EOT>& do_make_checkpoint_assembled(eoParser& _parser, eoState& _state, eoEvalFuncCounter<EOT>& _eval, eoContinue<EOT>& _continue)
|
eoCheckPoint<EOT>& do_make_checkpoint_assembled(eoParser& _parser, eoState& _state, eoEvalFuncCounter<EOT>& _eval, eoContinue<EOT>& _continue)
|
||||||
{
|
{
|
||||||
|
|
||||||
// SOME PARSER PARAMETERS
|
// SOME PARSER PARAMETERS
|
||||||
// ----------------------
|
// ----------------------
|
||||||
std::string dirName = _parser.createParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output").value();
|
std::string dirName = _parser.getORcreateParam(std::string("Res"), "resDir",
|
||||||
bool erase = _parser.createParam(true, "eraseDir", "Erase files in dirName if any", '\0', "Output").value();
|
"Directory to store DISK outputs",
|
||||||
#if !defined(NO_GNUPLOT)
|
'\0', "Output").value();
|
||||||
bool gnuplots = _parser.createParam(true,"plots","Plot stuff using GnuPlot",'\0',"Output").value();
|
bool erase = _parser.getORcreateParam(true, "eraseDir",
|
||||||
#endif
|
"Erase files in dirName if any",
|
||||||
bool printFile = _parser.createParam(true,"printFile","Print statistics file",'\0',"Output").value();
|
'\0', "Output").value();
|
||||||
|
bool gnuplots = _parser.getORcreateParam(true, "plots",
|
||||||
|
"Plot stuff using GnuPlot",
|
||||||
|
'\0', "Output").value();
|
||||||
|
bool printFile = _parser.getORcreateParam(true, "printFile",
|
||||||
|
"Print statistics file",
|
||||||
|
'\0', "Output").value();
|
||||||
|
|
||||||
eoValueParam<unsigned>& saveFrequencyParam =
|
eoValueParam<unsigned>& saveFrequencyParam
|
||||||
_parser.createParam(unsigned(0),"saveFrequency","Save every F generation (0 = only final state, absent = never)",'\0',"Persistence" );
|
= _parser.getORcreateParam(unsigned(0), "saveFrequency",
|
||||||
|
"Save every F generation (0 = only final state, absent = never)",
|
||||||
|
'\0', "Persistence" );
|
||||||
|
|
||||||
testDirRes(dirName, erase); // TRUE
|
testDirRes(dirName, erase); // TRUE
|
||||||
|
|
||||||
|
|
@ -128,7 +136,6 @@ eoCheckPoint<EOT>& do_make_checkpoint_assembled(eoParser& _parser, eoState& _sta
|
||||||
|
|
||||||
// GNUPLOT
|
// GNUPLOT
|
||||||
// -------
|
// -------
|
||||||
#if !defined(NO_GNUPLOT)
|
|
||||||
if (gnuplots ){
|
if (gnuplots ){
|
||||||
std::string stmp;
|
std::string stmp;
|
||||||
|
|
||||||
|
|
@ -156,7 +163,6 @@ eoCheckPoint<EOT>& do_make_checkpoint_assembled(eoParser& _parser, eoState& _sta
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// WRITE STUFF TO FILE
|
// WRITE STUFF TO FILE
|
||||||
// -------------------
|
// -------------------
|
||||||
|
|
|
||||||
|
|
@ -44,22 +44,24 @@ bool testDirRes(std::string _dirName, bool _erase);
|
||||||
/** Of course, Fitness needs to be an eoParetoFitness!!!
|
/** Of course, Fitness needs to be an eoParetoFitness!!!
|
||||||
*/
|
*/
|
||||||
template <class EOT>
|
template <class EOT>
|
||||||
eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state, eoEvalFuncCounter<EOT>& _eval, eoContinue<EOT>& _continue)
|
eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
|
||||||
|
eoEvalFuncCounter<EOT>& _eval, eoContinue<EOT>& _continue)
|
||||||
{
|
{
|
||||||
// first, create a checkpoint from the eoContinue - and store in _state
|
// first, create a checkpoint from the eoContinue - and store in _state
|
||||||
eoCheckPoint<EOT> & checkpoint =
|
eoCheckPoint<EOT> & checkpoint = _state.storeFunctor(new eoCheckPoint<EOT>(_continue));
|
||||||
_state.storeFunctor(new eoCheckPoint<EOT>(_continue));
|
|
||||||
|
|
||||||
/////// get number of obectives from Fitness - not very elegant
|
/////// get number of obectives from Fitness - not very elegant
|
||||||
typedef typename EOT::Fitness Fit;
|
typedef typename EOT::Fitness Fit;
|
||||||
Fit fit;
|
Fit fit;
|
||||||
unsigned nObj = fit.size();
|
unsigned nObj = fit.size();
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Counters
|
// Counters
|
||||||
//////////////////
|
//////////////////
|
||||||
// is nb Eval to be used as counter?
|
// is nb Eval to be used as counter?
|
||||||
bool useEval = _parser.createParam(true, "useEval", "Use nb of eval. as counter (vs nb of gen.)", '\0', "Output").value();
|
bool useEval = _parser.getORcreateParam(true, "useEval",
|
||||||
|
"Use nb of eval. as counter (vs nb of gen.)",
|
||||||
|
'\0', "Output").value();
|
||||||
|
|
||||||
// Create anyway a generation-counter parameter WARNING: not stored anywhere!!!
|
// Create anyway a generation-counter parameter WARNING: not stored anywhere!!!
|
||||||
eoValueParam<unsigned> *generationCounter = new eoValueParam<unsigned>(0, "Gen.");
|
eoValueParam<unsigned> *generationCounter = new eoValueParam<unsigned>(0, "Gen.");
|
||||||
|
|
@ -70,9 +72,13 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
|
||||||
checkpoint.add(increment);
|
checkpoint.add(increment);
|
||||||
|
|
||||||
// dir for DISK output
|
// dir for DISK output
|
||||||
std::string & dirName = _parser.getORcreateParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output - Disk").value();
|
std::string & dirName = _parser.getORcreateParam(std::string("Res"), "resDir",
|
||||||
|
"Directory to store DISK outputs",
|
||||||
|
'\0', "Output - Disk").value();
|
||||||
// shoudl we empty it if exists
|
// shoudl we empty it if exists
|
||||||
eoValueParam<bool>& eraseParam = _parser.createParam(true, "eraseDir", "erase files in dirName if any", '\0', "Output - Disk");
|
eoValueParam<bool>& eraseParam = _parser.getORcreateParam(true, "eraseDir",
|
||||||
|
"erase files in dirName if any",
|
||||||
|
'\0', "Output - Disk");
|
||||||
bool dirOK = false; // not tested yet
|
bool dirOK = false; // not tested yet
|
||||||
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
|
|
@ -84,22 +90,20 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
|
||||||
* eoSortedPopStat : whole population - type std::string (!!)
|
* eoSortedPopStat : whole population - type std::string (!!)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
eoValueParam<eoParamParamType>& fPlotParam = _parser.createParam(
|
eoValueParam<eoParamParamType>& fPlotParam
|
||||||
eoParamParamType("1(0,1)"), "frontFileFrequency",
|
= _parser.getORcreateParam(eoParamParamType("1(0,1)"), "frontFileFrequency",
|
||||||
"File save frequency in objective spaces (std::pairs of comma-separated objectives " \
|
"File save frequency in objective spaces (std::pairs of comma-separated objectives " \
|
||||||
"in 1 single parentheses std::pair)",
|
"in 1 single parentheses std::pair)",
|
||||||
'\0', "Output - Disk");
|
'\0', "Output - Disk");
|
||||||
|
|
||||||
#if !defined(NO_GNUPLOT)
|
bool boolGnuplot = _parser.getORcreateParam(false, "plotFront",
|
||||||
bool boolGnuplot = _parser.createParam(false, "plotFront",
|
"Objective plots (requires corresponding files " \
|
||||||
"Objective plots (requires corresponding files " \
|
"- see frontFileFrequency",
|
||||||
"- see frontFileFrequency",
|
'\0', "Output - Graphical").value();
|
||||||
'\0', "Output - Graphical").value();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
eoParamParamType & fPlot = fPlotParam.value(); // std::pair<std::string,std::vector<std::string> >
|
eoParamParamType & fPlot = fPlotParam.value(); // std::pair<std::string,std::vector<std::string> >
|
||||||
unsigned frequency = atoi(fPlot.first.c_str());
|
unsigned frequency = atoi(fPlot.first.c_str());
|
||||||
if (frequency) // something to plot
|
if (frequency) // something to plot
|
||||||
{
|
{
|
||||||
unsigned nbPlot = fPlot.second.size();
|
unsigned nbPlot = fPlot.second.size();
|
||||||
if ( nbPlot % 2 ) // odd!
|
if ( nbPlot % 2 ) // odd!
|
||||||
|
|
@ -145,20 +149,20 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
|
||||||
snapshot.add(*theStats[obj2]);
|
snapshot.add(*theStats[obj2]);
|
||||||
|
|
||||||
// and create the gnuplotter from the fileSnapshot
|
// and create the gnuplotter from the fileSnapshot
|
||||||
#if !defined(NO_GNUPLOT)
|
if(boolGnuplot)
|
||||||
if (boolGnuplot)
|
|
||||||
{
|
{
|
||||||
eoGnuplot1DSnapshot & plotSnapshot = _state.storeFunctor(new
|
eoGnuplot1DSnapshot & plotSnapshot = _state.storeFunctor(new
|
||||||
eoGnuplot1DSnapshot(snapshot));
|
eoGnuplot1DSnapshot(snapshot));
|
||||||
plotSnapshot.pointSize =3;
|
plotSnapshot.pointSize =3;
|
||||||
checkpoint.add(plotSnapshot);
|
checkpoint.add(plotSnapshot);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Dump of the whole population
|
// Dump of the whole population
|
||||||
//-----------------------------
|
//-----------------------------
|
||||||
bool printPop = _parser.createParam(false, "printPop", "Print sorted pop. every gen.", '\0', "Output").value();
|
bool printPop = _parser.getORcreateParam(false, "printPop",
|
||||||
|
"Print sorted pop. every gen.",
|
||||||
|
'\0', "Output").value();
|
||||||
eoSortedPopStat<EOT> * popStat;
|
eoSortedPopStat<EOT> * popStat;
|
||||||
if ( printPop ) // we do want pop dump
|
if ( printPop ) // we do want pop dump
|
||||||
{
|
{
|
||||||
|
|
@ -217,7 +221,9 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
|
||||||
}
|
}
|
||||||
|
|
||||||
// save state every T seconds
|
// save state every T seconds
|
||||||
eoValueParam<unsigned>& saveTimeIntervalParam = _parser.createParam(unsigned(0), "saveTimeInterval", "Save every T seconds (0 or absent = never)", '\0',"Persistence" );
|
eoValueParam<unsigned>& saveTimeIntervalParam
|
||||||
|
= _parser.getORcreateParam(unsigned(0), "saveTimeInterval",
|
||||||
|
"Save every T seconds (0 or absent = never)", '\0',"Persistence" );
|
||||||
if (_parser.isItThere(saveTimeIntervalParam) && saveTimeIntervalParam.value()>0)
|
if (_parser.isItThere(saveTimeIntervalParam) && saveTimeIntervalParam.value()>0)
|
||||||
{
|
{
|
||||||
// first make sure dirName is OK
|
// first make sure dirName is OK
|
||||||
|
|
|
||||||
|
|
@ -44,30 +44,34 @@ eoGnuplot::eoGnuplot(std::string _title, std::string _extra)
|
||||||
|
|
||||||
eoGnuplot::~eoGnuplot()
|
eoGnuplot::~eoGnuplot()
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_GNUPLOT
|
||||||
if( gpCom ) {
|
if( gpCom ) {
|
||||||
PipeComSend( gpCom, "quit\n" );
|
PipeComSend( gpCom, "quit\n" );
|
||||||
PipeComClose( gpCom );
|
PipeComClose( gpCom );
|
||||||
gpCom =NULL;
|
gpCom =NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void eoGnuplot::gnuplotCommand(const char *_command)
|
void eoGnuplot::gnuplotCommand(const char *_command)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_GNUPLOT
|
||||||
if(gpCom) {
|
if(gpCom) {
|
||||||
PipeComSend( gpCom, _command );
|
PipeComSend( gpCom, _command );
|
||||||
PipeComSend( gpCom, "\n" );
|
PipeComSend( gpCom, "\n" );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
|
void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_GNUPLOT
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "250x150-0+" << numWindow*170;
|
os << "250x150-0+" << 170 * numWindow++;
|
||||||
numWindow++;
|
|
||||||
char *args[6];
|
char *args[6];
|
||||||
args[0] = strdup( GNUPLOT_PROGRAM );
|
args[0] = strdup( GNUPLOT_PROGRAM );
|
||||||
args[1] = strdup( "-geometry" );
|
args[1] = strdup( "-geometry" );
|
||||||
|
|
@ -83,6 +87,7 @@ void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
|
||||||
PipeComSend( gpCom, _extra.c_str() );
|
PipeComSend( gpCom, _extra.c_str() );
|
||||||
PipeComSend( gpCom, "\n" );
|
PipeComSend( gpCom, "\n" );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,29 +29,30 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "eoGnuplot1DMonitor.h"
|
#include "utils/eoGnuplot1DMonitor.h"
|
||||||
#include "eoParam.h"
|
#include "utils/eoParam.h"
|
||||||
|
|
||||||
|
|
||||||
eoMonitor& eoGnuplot1DMonitor::operator() (void)
|
eoMonitor& eoGnuplot1DMonitor::operator() (void)
|
||||||
{
|
{
|
||||||
// update file using the eoFileMonitor
|
// update file using the eoFileMonitor
|
||||||
eoFileMonitor::operator()();
|
eoFileMonitor::operator()();
|
||||||
|
#ifdef HAVE_GNUPLOT
|
||||||
// sends plot order to gnuplot
|
// sends plot order to gnuplot
|
||||||
// assumes successive plots will have same nb of columns!!!
|
// assumes successive plots will have same nb of columns!!!
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
{
|
{
|
||||||
FirstPlot();
|
FirstPlot();
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( gpCom ) {
|
if( gpCom ) {
|
||||||
PipeComSend( gpCom, "replot\n" );
|
PipeComSend( gpCom, "replot\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return *this;
|
#endif
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -62,6 +63,7 @@ void eoGnuplot1DMonitor::FirstPlot()
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Must have some stats to plot!\n");
|
throw std::runtime_error("Must have some stats to plot!\n");
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_GNUPLOT
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "plot";
|
os << "plot";
|
||||||
for (unsigned i=1; i<vec.size(); i++) {
|
for (unsigned i=1; i<vec.size(); i++) {
|
||||||
|
|
@ -72,6 +74,7 @@ void eoGnuplot1DMonitor::FirstPlot()
|
||||||
}
|
}
|
||||||
os << '\n';
|
os << '\n';
|
||||||
PipeComSend( gpCom, os.str().c_str());
|
PipeComSend( gpCom, os.str().c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// eoGnuplot1DMonitor.h
|
// eoGnuplot1DMonitor.h
|
||||||
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
|
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
|
||||||
|
|
@ -49,6 +47,7 @@ everytime
|
||||||
class eoGnuplot1DMonitor : public eoFileMonitor, public eoGnuplot
|
class eoGnuplot1DMonitor : public eoFileMonitor, public eoGnuplot
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using eoMonitor::vec;
|
using eoMonitor::vec;
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
|
|
@ -70,4 +69,13 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif // EO_eoGnuplot1DMonitor_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// c-file-style: "Stroustrup"
|
||||||
|
// comment-column: 35
|
||||||
|
// fill-column: 80
|
||||||
|
// mode: C++
|
||||||
|
// End:
|
||||||
|
|
|
||||||
|
|
@ -6,20 +6,22 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline eoMonitor& eoGnuplot1DSnapshot::operator() (void)
|
eoMonitor& eoGnuplot1DSnapshot::operator()()
|
||||||
{
|
{
|
||||||
// update file using the eoFileMonitor method
|
// update file using the eoFileMonitor method
|
||||||
eoFileSnapshot::operator()();
|
eoFileSnapshot::operator()();
|
||||||
|
|
||||||
// sends plot order to gnuplot
|
#ifdef HAVE_GNUPLOT
|
||||||
//std::string buff; // need local memory
|
// sends plot order to gnuplot
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "set title 'Gen. " << getCounter() << "'; plot '"
|
os << "set title 'Gen. " << getCounter() << "'; plot '"
|
||||||
// mk: had to use getFilename().c_str(), because it seems the string(stream) lib is screwed in gcc3.2
|
// mk: had to use getFilename().c_str(),
|
||||||
<< getFileName().c_str() << "' notitle with points ps " << pointSize;
|
// because it seems the string(stream) lib is screwed in gcc3.2
|
||||||
os << std::endl;
|
<< getFileName().c_str() << "' notitle with points ps " << pointSize
|
||||||
PipeComSend( gpCom, os.str().c_str());
|
<< std::endl;
|
||||||
return (*this);
|
PipeComSend(gpCom, os.str().c_str());
|
||||||
|
#endif
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
|
||||||
public:
|
public:
|
||||||
// Ctor
|
// Ctor
|
||||||
eoGnuplot1DSnapshot(std::string _dirname, unsigned _frequency = 1,
|
eoGnuplot1DSnapshot(std::string _dirname, unsigned _frequency = 1,
|
||||||
std::string _filename = "gen", std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true) :
|
std::string _filename = "gen", std::string _delim = " ",
|
||||||
|
unsigned _counter = 0, bool _rmFiles = true) :
|
||||||
eoFileSnapshot(_dirname, _frequency, _filename, _delim, _counter, _rmFiles),
|
eoFileSnapshot(_dirname, _frequency, _filename, _delim, _counter, _rmFiles),
|
||||||
eoGnuplot(_filename,"set data style points"),
|
eoGnuplot(_filename,"set data style points"),
|
||||||
pointSize(5)
|
pointSize(5)
|
||||||
|
|
@ -88,7 +89,7 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
|
||||||
// Dtor
|
// Dtor
|
||||||
virtual ~eoGnuplot1DSnapshot(){}
|
virtual ~eoGnuplot1DSnapshot(){}
|
||||||
|
|
||||||
virtual eoMonitor& operator() (void) ;
|
virtual eoMonitor& operator()();
|
||||||
|
|
||||||
/// Class name.
|
/// Class name.
|
||||||
virtual std::string className() const { return "eoGnuplot1DSnapshot"; }
|
virtual std::string className() const { return "eoGnuplot1DSnapshot"; }
|
||||||
|
|
@ -96,20 +97,20 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
|
||||||
virtual void handleBounds(eoRealVectorBounds & _bounds)
|
virtual void handleBounds(eoRealVectorBounds & _bounds)
|
||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
// std::ostrstream os;
|
os << "set autoscale\nset yrange [" ;
|
||||||
os << "set autoscale\nset yrange [" ;
|
if (_bounds.isMinBounded(0))
|
||||||
if (_bounds.isMinBounded(0))
|
os << _bounds.minimum(0);
|
||||||
os << _bounds.minimum(0);
|
os << ":" ;
|
||||||
os << ":" ;
|
if (_bounds.isMaxBounded(0))
|
||||||
if (_bounds.isMaxBounded(0))
|
os << _bounds.maximum(0);
|
||||||
os << _bounds.maximum(0);
|
os << "]\n";
|
||||||
os << "]\n";
|
gnuplotCommand(os.str());
|
||||||
gnuplotCommand(os.str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned pointSize;
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
unsigned pointSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,24 +91,26 @@ int main(int argc, char* argv[])
|
||||||
if (!ptDirNameParam) // not found
|
if (!ptDirNameParam) // not found
|
||||||
throw runtime_error("Parameter resDir not found where it was supposed to be");
|
throw runtime_error("Parameter resDir not found where it was supposed to be");
|
||||||
|
|
||||||
#if !defined(NO_GNUPLOT)
|
|
||||||
// now create the snapshot monitor
|
// now create the snapshot monitor
|
||||||
eoValueParam<bool>& plotDistribParam = parser.createParam(false, "plotDistrib", "Plot Distribution", '\0', "Output - Graphical");
|
eoValueParam<bool>& plotDistribParam = parser.getORcreateParam(false, "plotDistrib",
|
||||||
|
"Plot Distribution", '\0',
|
||||||
|
"Output - Graphical");
|
||||||
if (plotDistribParam.value())
|
if (plotDistribParam.value())
|
||||||
{
|
{
|
||||||
unsigned frequency=1; // frequency of plots updates
|
unsigned frequency=1; // frequency of plots updates
|
||||||
eoGnuplot1DSnapshot *distribSnapshot = new eoGnuplot1DSnapshot(ptDirNameParam->value(), frequency, "distrib");
|
eoGnuplot1DSnapshot *distribSnapshot = new eoGnuplot1DSnapshot(ptDirNameParam->value(),
|
||||||
|
frequency, "distrib");
|
||||||
state.storeFunctor(distribSnapshot);
|
state.storeFunctor(distribSnapshot);
|
||||||
// add the distribution (it is an eoValueParam<vector<double> >)
|
// add the distribution (it is an eoValueParam<vector<double> >)
|
||||||
distribSnapshot->add(distrib);
|
distribSnapshot->add(distrib);
|
||||||
// and of course add it to the checkpoint
|
// and of course add it to the checkpoint
|
||||||
checkpoint.add(*distribSnapshot);
|
checkpoint.add(*distribSnapshot);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// the algorithm: EDA
|
// the algorithm: EDA
|
||||||
// don't know where else to put the population size!
|
// don't know where else to put the population size!
|
||||||
unsigned popSize = parser.createParam(unsigned(100), "popSize", "Population Size", 'P', "Algorithm").value();
|
unsigned popSize = parser.getORcreateParam(unsigned(100), "popSize",
|
||||||
|
"Population Size", 'P', "Algorithm").value();
|
||||||
eoSimpleEDA<Indi> eda(update, eval, popSize, checkpoint);
|
eoSimpleEDA<Indi> eda(update, eval, popSize, checkpoint);
|
||||||
|
|
||||||
///// End of construction of the algorith
|
///// End of construction of the algorith
|
||||||
|
|
@ -125,14 +127,12 @@ int main(int argc, char* argv[])
|
||||||
distrib.printOn(std::cout);
|
distrib.printOn(std::cout);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
#if !defined(NO_GNUPLOT)
|
|
||||||
// wait - for graphical output
|
// wait - for graphical output
|
||||||
if (plotDistribParam.value())
|
if (plotDistribParam.value())
|
||||||
{
|
{
|
||||||
string foo;
|
string foo;
|
||||||
cin >> foo;
|
cin >> foo;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch(std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,6 @@ void the_main(int argc, char* argv[])
|
||||||
cp.add(fitness0);
|
cp.add(fitness0);
|
||||||
cp.add(fitness1);
|
cp.add(fitness1);
|
||||||
|
|
||||||
#if !defined(NO_GNUPLOT)
|
|
||||||
eoGnuplot1DSnapshot snapshot("pareto");
|
eoGnuplot1DSnapshot snapshot("pareto");
|
||||||
//snapshot.with(eoGnuplot::Points(3));
|
//snapshot.with(eoGnuplot::Points(3));
|
||||||
|
|
||||||
|
|
@ -213,7 +212,6 @@ void the_main(int argc, char* argv[])
|
||||||
|
|
||||||
snapshot.add(fitness0);
|
snapshot.add(fitness0);
|
||||||
snapshot.add(fitness1);
|
snapshot.add(fitness1);
|
||||||
#endif
|
|
||||||
|
|
||||||
// the algo
|
// the algo
|
||||||
eoEasyEA<eoDouble> ea(cp, eval, breeder, replace);
|
eoEasyEA<eoDouble> ea(cp, eval, breeder, replace);
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ try
|
||||||
// those need to be pointers because of the if's
|
// those need to be pointers because of the if's
|
||||||
eoStdoutMonitor *myStdOutMonitor;
|
eoStdoutMonitor *myStdOutMonitor;
|
||||||
eoFileMonitor *myFileMonitor;
|
eoFileMonitor *myFileMonitor;
|
||||||
#if !defined(NO_GNUPLOT)
|
#ifdef HAVE_GNUPLOT
|
||||||
eoGnuplot1DMonitor *myGnuMonitor;
|
eoGnuplot1DMonitor *myGnuMonitor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -296,7 +296,7 @@ try
|
||||||
myFileMonitor->add(myStat);
|
myFileMonitor->add(myStat);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(NO_GNUPLOT)
|
#ifdef HAVE_GNUPLOT
|
||||||
// should we PLOT it on StdOut ? (one dot per generation, incremental plot)
|
// should we PLOT it on StdOut ? (one dot per generation, incremental plot)
|
||||||
if (plotMyStructStat)
|
if (plotMyStructStat)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Reference in a new issue