diff --git a/application/common/CMakeLists.txt b/application/common/CMakeLists.txt index 41a16ecfc..d16353f59 100644 --- a/application/common/CMakeLists.txt +++ b/application/common/CMakeLists.txt @@ -3,6 +3,7 @@ PROJECT(common) SET(RESOURCES gplot.py ggobi.py + boxplot_eda_n_edasa.py ) FOREACH(file ${RESOURCES}) diff --git a/application/common/boxplot_eda_n_edasa.py b/application/common/boxplot_eda_n_edasa.py new file mode 100755 index 000000000..a4086a677 --- /dev/null +++ b/application/common/boxplot_eda_n_edasa.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +from pylab import * +#from pprint import pprint + +FILE_LOCATIONS = 'EDA_ResPop/list_of_files.txt' + +data = [] + +locations = [ line.split()[0] for line in open( FILE_LOCATIONS ) ] +#pprint( locations ) + +for cur_file in locations: + fitnesses = [ float(line.split()[0]) for line in open( cur_file ).readlines()[1:-1] ] + data.append( fitnesses[1:] ) + +#pprint( data ) + +boxplot( data ) + +# FILE_LOCATIONS = 'EDASA_ResPop/list_of_files.txt' + +# data = [] + +# locations = [ line.split()[0] for line in open( FILE_LOCATIONS ) ] +# #pprint( locations ) + +# for cur_file in locations: +# fitnesses = [ float(line.split()[0]) for line in open( cur_file ).readlines()[1:-1] ] +# data.append( fitnesses[1:] ) + +# #pprint( data ) + +# boxplot( data ) + +show() diff --git a/application/eda/main.cpp b/application/eda/main.cpp index dd5b81378..3e8e0fae4 100644 --- a/application/eda/main.cpp +++ b/application/eda/main.cpp @@ -159,15 +159,6 @@ int main(int ac, char** av) eoCheckPoint< EOT >& pop_continue = do_make_checkpoint(parser, state, eval, eo_continue); - doPopStat< EOT >* popStat = new doPopStat; - state.storeFunctor(popStat); - pop_continue.add(*popStat); - - doFileSnapshot* fileSnapshot = new doFileSnapshot("EDA_ResPop"); - state.storeFunctor(fileSnapshot); - fileSnapshot->add(*popStat); - pop_continue.add(*fileSnapshot); - //----------------------------------------------------------------------------- @@ -181,21 +172,6 @@ int main(int ac, char** av) doCheckPoint< Distrib >* distribution_continue = new doCheckPoint< Distrib >( *dummy_continue ); state.storeFunctor(distribution_continue); - doDistribStat< Distrib >* distrib_stat = new doStatNormalMulti< EOT >(); - state.storeFunctor(distrib_stat); - - distribution_continue->add( *distrib_stat ); - - // eoMonitor* stdout_monitor = new eoStdoutMonitor(); - // state.storeFunctor(stdout_monitor); - // stdout_monitor->add(*distrib_stat); - // distribution_continue->add( *stdout_monitor ); - - eoFileMonitor* file_monitor = new eoFileMonitor("eda_distribution_bounds.txt"); - state.storeFunctor(file_monitor); - file_monitor->add(*distrib_stat); - distribution_continue->add( *file_monitor ); - //----------------------------------------------------------------------------- @@ -216,21 +192,9 @@ int main(int ac, char** av) //----------------------------------------------------------------------------- - // EDA algorithm configuration + // Some stuff to display helper when we are using -h option //----------------------------------------------------------------------------- - doAlgo< Distrib >* algo = new doEDA< Distrib > - (*selector, *estimator, *selectone, *modifier, *sampler, - pop_continue, *distribution_continue, - eval, - //*sa_continue, *cooling_schedule, initial_temperature, - *replacor); - - //----------------------------------------------------------------------------- - - - // state.storeFunctor(algo); - if (parser.userNeedsHelp()) { parser.printHelp(std::cout); @@ -242,6 +206,63 @@ int main(int ac, char** av) make_verbose(parser); make_help(parser); + //----------------------------------------------------------------------------- + + + //----------------------------------------------------------------------------- + // population output (after helper) + // + // FIXME: theses objects are instanciate there in order to avoid a folder + // removing as doFileSnapshot does within ctor. + //----------------------------------------------------------------------------- + + doPopStat< EOT >* popStat = new doPopStat; + state.storeFunctor(popStat); + pop_continue.add(*popStat); + + doFileSnapshot* fileSnapshot = new doFileSnapshot("EDA_ResPop"); + state.storeFunctor(fileSnapshot); + fileSnapshot->add(*popStat); + pop_continue.add(*fileSnapshot); + + //----------------------------------------------------------------------------- + + + //----------------------------------------------------------------------------- + // distribution output (after helper) + //----------------------------------------------------------------------------- + + doDistribStat< Distrib >* distrib_stat = new doStatNormalMulti< EOT >(); + state.storeFunctor(distrib_stat); + + distribution_continue->add( *distrib_stat ); + + // eoMonitor* stdout_monitor = new eoStdoutMonitor(); + // state.storeFunctor(stdout_monitor); + // stdout_monitor->add(*distrib_stat); + // distribution_continue->add( *stdout_monitor ); + + eoFileMonitor* file_monitor = new eoFileMonitor("eda_distribution_bounds.txt"); + state.storeFunctor(file_monitor); + file_monitor->add(*distrib_stat); + distribution_continue->add( *file_monitor ); + + //----------------------------------------------------------------------------- + + + //----------------------------------------------------------------------------- + // EDA algorithm configuration + //----------------------------------------------------------------------------- + + doAlgo< Distrib >* algo = new doEDA< Distrib > + (*selector, *estimator, *selectone, *modifier, *sampler, + pop_continue, *distribution_continue, + eval, + //*sa_continue, *cooling_schedule, initial_temperature, + *replacor); + + //----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- // Beginning of the algorithm call diff --git a/application/eda_sa/main.cpp b/application/eda_sa/main.cpp index 6e4729de3..2d72ad832 100644 --- a/application/eda_sa/main.cpp +++ b/application/eda_sa/main.cpp @@ -159,15 +159,6 @@ int main(int ac, char** av) eoCheckPoint< EOT >& pop_continue = do_make_checkpoint(parser, state, eval, eo_continue); - doPopStat< EOT >* popStat = new doPopStat; - state.storeFunctor(popStat); - pop_continue.add(*popStat); - - doFileSnapshot* fileSnapshot = new doFileSnapshot("EDASA_ResPop"); - state.storeFunctor(fileSnapshot); - fileSnapshot->add(*popStat); - pop_continue.add(*fileSnapshot); - //----------------------------------------------------------------------------- @@ -181,21 +172,6 @@ int main(int ac, char** av) doCheckPoint< Distrib >* distribution_continue = new doCheckPoint< Distrib >( *dummy_continue ); state.storeFunctor(distribution_continue); - doDistribStat< Distrib >* distrib_stat = new doStatNormalMulti< EOT >(); - state.storeFunctor(distrib_stat); - - distribution_continue->add( *distrib_stat ); - - // eoMonitor* stdout_monitor = new eoStdoutMonitor(); - // state.storeFunctor(stdout_monitor); - // stdout_monitor->add(*distrib_stat); - // distribution_continue->add( *stdout_monitor ); - - eoFileMonitor* file_monitor = new eoFileMonitor("eda_sa_distribution_bounds.txt"); - state.storeFunctor(file_monitor); - file_monitor->add(*distrib_stat); - distribution_continue->add( *file_monitor ); - //----------------------------------------------------------------------------- @@ -216,20 +192,9 @@ int main(int ac, char** av) //----------------------------------------------------------------------------- - // EDASA algorithm configuration + // Some stuff to display helper when we are using -h option //----------------------------------------------------------------------------- - doAlgo< Distrib >* algo = new doEDASA< Distrib > - (*selector, *estimator, *selectone, *modifier, *sampler, - pop_continue, *distribution_continue, - eval, *sa_continue, *cooling_schedule, - initial_temperature, *replacor); - - //----------------------------------------------------------------------------- - - - // state.storeFunctor(algo); - if (parser.userNeedsHelp()) { parser.printHelp(std::cout); @@ -241,6 +206,62 @@ int main(int ac, char** av) make_verbose(parser); make_help(parser); + //----------------------------------------------------------------------------- + + + //----------------------------------------------------------------------------- + // population output (after helper) + // + // FIXME: theses objects are instanciate there in order to avoid a folder + // removing as doFileSnapshot does within ctor. + //----------------------------------------------------------------------------- + + doPopStat< EOT >* popStat = new doPopStat; + state.storeFunctor(popStat); + pop_continue.add(*popStat); + + doFileSnapshot* fileSnapshot = new doFileSnapshot("EDASA_ResPop"); + state.storeFunctor(fileSnapshot); + fileSnapshot->add(*popStat); + pop_continue.add(*fileSnapshot); + + //----------------------------------------------------------------------------- + + + //----------------------------------------------------------------------------- + // distribution output (after helper) + //----------------------------------------------------------------------------- + + doDistribStat< Distrib >* distrib_stat = new doStatNormalMulti< EOT >(); + state.storeFunctor(distrib_stat); + + distribution_continue->add( *distrib_stat ); + + // eoMonitor* stdout_monitor = new eoStdoutMonitor(); + // state.storeFunctor(stdout_monitor); + // stdout_monitor->add(*distrib_stat); + // distribution_continue->add( *stdout_monitor ); + + eoFileMonitor* file_monitor = new eoFileMonitor("eda_sa_distribution_bounds.txt"); + state.storeFunctor(file_monitor); + file_monitor->add(*distrib_stat); + distribution_continue->add( *file_monitor ); + + //----------------------------------------------------------------------------- + + + //----------------------------------------------------------------------------- + // EDASA algorithm configuration + //----------------------------------------------------------------------------- + + doAlgo< Distrib >* algo = new doEDASA< Distrib > + (*selector, *estimator, *selectone, *modifier, *sampler, + pop_continue, *distribution_continue, + eval, *sa_continue, *cooling_schedule, + initial_temperature, *replacor); + + //----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- // Beginning of the algorithm call diff --git a/src/utils/doFileSnapshot.cpp b/src/utils/doFileSnapshot.cpp index 3ad012f76..268cfe82e 100644 --- a/src/utils/doFileSnapshot.cpp +++ b/src/utils/doFileSnapshot.cpp @@ -39,10 +39,12 @@ doFileSnapshot::doFileSnapshot(std::string dirname, std::string filename /*= "gen"*/, std::string delim /*= " "*/, unsigned int counter /*= 0*/, - bool rmFiles /*= true*/) + bool rmFiles /*= true*/, + bool saveFilenames /*= true*/) : _dirname(dirname), _frequency(frequency), _filename(filename), _delim(delim), - _counter(counter), _boolChanged(true) + _counter(counter), _saveFilenames(saveFilenames), + _descOfFiles( NULL ), _boolChanged(true) { std::string s = "test -d " + _dirname; @@ -72,8 +74,15 @@ doFileSnapshot::doFileSnapshot(std::string dirname, int dummy; dummy = system(s.c_str()); // all done + + _descOfFiles = new std::ofstream( std::string(dirname + "/list_of_files.txt").c_str() ); + } +doFileSnapshot::~doFileSnapshot() +{ + delete _descOfFiles; +} void doFileSnapshot::setCurrentFileName() { @@ -93,6 +102,7 @@ eoMonitor& doFileSnapshot::operator()(void) _counter++; _boolChanged = true; setCurrentFileName(); + std::ofstream os(_currentFileName.c_str()); if (!os) @@ -101,6 +111,11 @@ eoMonitor& doFileSnapshot::operator()(void) throw std::runtime_error(str); } + if ( _saveFilenames ) + { + *_descOfFiles << _currentFileName.c_str() << std::endl; + } + return operator()(os); } diff --git a/src/utils/doFileSnapshot.h b/src/utils/doFileSnapshot.h index 9329eed97..ea0ffeb63 100644 --- a/src/utils/doFileSnapshot.h +++ b/src/utils/doFileSnapshot.h @@ -42,7 +42,10 @@ public: std::string filename = "gen", std::string delim = " ", unsigned int counter = 0, - bool rmFiles = true); + bool rmFiles = true, + bool saveFilenames = true); + + virtual ~doFileSnapshot(); virtual bool hasChanged() {return _boolChanged;} virtual std::string getDirName() { return _dirname; } @@ -63,6 +66,8 @@ private : std::string _delim; std::string _currentFileName; unsigned int _counter; + bool _saveFilenames; + std::ofstream* _descOfFiles; bool _boolChanged; };