* eda n eda_sa: bug fixed, while we were using -h the result folder was removed
This commit is contained in:
parent
65191e2212
commit
b1798ad351
6 changed files with 175 additions and 76 deletions
|
|
@ -3,6 +3,7 @@ PROJECT(common)
|
|||
SET(RESOURCES
|
||||
gplot.py
|
||||
ggobi.py
|
||||
boxplot_eda_n_edasa.py
|
||||
)
|
||||
|
||||
FOREACH(file ${RESOURCES})
|
||||
|
|
|
|||
36
application/common/boxplot_eda_n_edasa.py
Executable file
36
application/common/boxplot_eda_n_edasa.py
Executable file
|
|
@ -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()
|
||||
|
|
@ -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<EOT>;
|
||||
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<EOT>;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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<EOT>;
|
||||
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<EOT>;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue