update for sstream
This commit is contained in:
parent
9786fe0a6a
commit
73c97e6bfa
5 changed files with 55 additions and 21 deletions
|
|
@ -8,7 +8,7 @@ if USE_TUTORIAL
|
||||||
SUBDIRS_TUT = tutorial
|
SUBDIRS_TUT = tutorial
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SUBDIRS = src test doc contrib win $(SUBDIRS_APP) $(SUBDIRS_TUT)
|
SUBDIRS = src doc contrib win $(SUBDIRS_APP) $(SUBDIRS_TUT) test
|
||||||
|
|
||||||
|
|
||||||
# Directory for documents
|
# Directory for documents
|
||||||
|
|
|
||||||
1
eo/Tutorial/.cvsignore
Normal file
1
eo/Tutorial/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Makefile.in
|
||||||
|
|
@ -204,7 +204,7 @@ int correct(const mlp::net& net, const mlp::set& set)
|
||||||
|
|
||||||
for (mlp::set::const_iterator s = set.begin(); s != set.end(); ++s)
|
for (mlp::set::const_iterator s = set.begin(); s != set.end(); ++s)
|
||||||
{
|
{
|
||||||
int partial = 0;
|
unsigned partial = 0;
|
||||||
|
|
||||||
for (unsigned i = 0; i < s->output.size(); ++i)
|
for (unsigned i = 0; i < s->output.size(); ++i)
|
||||||
if (s->output[i] < 0.5 && net(s->input)[i] < 0.5 ||
|
if (s->output[i] < 0.5 && net(s->input)[i] < 0.5 ||
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,22 @@
|
||||||
#ifndef _make_checkpoint_pareto_h
|
#ifndef _make_checkpoint_pareto_h
|
||||||
#define _make_checkpoint_pareto_h
|
#define _make_checkpoint_pareto_h
|
||||||
|
|
||||||
#include <stdlib.h>
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#ifdef HAVE_SSTREAM
|
||||||
|
#include <sstream>
|
||||||
|
#else
|
||||||
|
#include <strstream>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "eoParetoFitness.h"
|
|
||||||
#include "utils/selectors.h"
|
|
||||||
#include "EO.h"
|
#include "EO.h"
|
||||||
|
#include "eoParetoFitness.h"
|
||||||
#include "eoEvalFuncCounter.h"
|
#include "eoEvalFuncCounter.h"
|
||||||
#include "utils/checkpointing"
|
#include "utils/checkpointing"
|
||||||
|
#include "utils/selectors.h"
|
||||||
|
|
||||||
// at the moment, in utils/make_help.cpp
|
// at the moment, in utils/make_help.cpp
|
||||||
// this should become some eoUtils.cpp with corresponding eoUtils.h
|
// this should become some eoUtils.cpp with corresponding eoUtils.h
|
||||||
|
|
@ -83,10 +92,17 @@ 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(eoParamParamType("1(0,1)"), "frontFileFrequency", "File save frequency in objective spaces (std::pairs of comma-separated objectives in 1 single parentheses std::pair)", '\0', "Output - Disk");
|
eoValueParam<eoParamParamType>& fPlotParam = _parser.createParam(
|
||||||
|
eoParamParamType("1(0,1)"), "frontFileFrequency",
|
||||||
|
"File save frequency in objective spaces (std::pairs of comma-separated objectives " \
|
||||||
|
"in 1 single parentheses std::pair)",
|
||||||
|
'\0', "Output - Disk");
|
||||||
|
|
||||||
#if !defined(NO_GNUPLOT)
|
#if !defined(NO_GNUPLOT)
|
||||||
bool boolGnuplot = _parser.createParam(false, "plotFront", "Objective plots (requires corresponding files - see frontFileFrequency", '\0', "Output - Graphical").value();
|
bool boolGnuplot = _parser.createParam(false, "plotFront",
|
||||||
|
"Objective plots (requires corresponding files " \
|
||||||
|
"- see frontFileFrequency",
|
||||||
|
'\0', "Output - Graphical").value();
|
||||||
#endif
|
#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> >
|
||||||
|
|
@ -107,23 +123,33 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
|
||||||
unsigned obj1 = atoi(fPlot.second[i].c_str());
|
unsigned obj1 = atoi(fPlot.second[i].c_str());
|
||||||
unsigned obj2 = atoi(fPlot.second[i+1].c_str());
|
unsigned obj2 = atoi(fPlot.second[i+1].c_str());
|
||||||
eoMOFitnessStat<EOT>* fStat;
|
eoMOFitnessStat<EOT>* fStat;
|
||||||
if (!bStat[obj1]) // not already there: create it
|
if (!bStat[obj1]) { // not already there: create it
|
||||||
{
|
#ifdef HAVE_SSTREAM
|
||||||
|
std::ostringstream os;
|
||||||
|
os << "Obj. " << obj1 << std::ends;
|
||||||
|
fStat = new eoMOFitnessStat<EOT>(obj1, os.str().c_str());
|
||||||
|
#else
|
||||||
char s[1024];
|
char s[1024];
|
||||||
std::ostrstream os(s, 1022);
|
std::ostrstream os(s, 1022);
|
||||||
os << "Obj. " << obj1 << std::ends;
|
os << "Obj. " << obj1 << std::ends;
|
||||||
fStat = new eoMOFitnessStat<EOT>(obj1, s);
|
fStat = new eoMOFitnessStat<EOT>(obj1, s);
|
||||||
|
#endif
|
||||||
_state.storeFunctor(fStat);
|
_state.storeFunctor(fStat);
|
||||||
bStat[obj1]=true;
|
bStat[obj1]=true;
|
||||||
theStats[obj1]=fStat;
|
theStats[obj1]=fStat;
|
||||||
checkpoint.add(*fStat);
|
checkpoint.add(*fStat);
|
||||||
}
|
}
|
||||||
if (!bStat[obj2]) // not already there: create it
|
if (!bStat[obj2]) { // not already there: create it
|
||||||
{
|
#ifdef HAVE_SSTREAM
|
||||||
char s2[1024];
|
std::ostringstream os;
|
||||||
std::ostrstream os2(s2, 1022);
|
os << "Obj. " << obj2 << std::ends;
|
||||||
os2 << "Obj. " << obj2 << std::ends;
|
fStat = new eoMOFitnessStat<EOT>(obj2, os.str().c_str());
|
||||||
fStat = new eoMOFitnessStat<EOT>(obj2, s2);
|
#else
|
||||||
|
char s[1024];
|
||||||
|
std::ostrstream os2(s, 1022);
|
||||||
|
os << "Obj. " << obj2 << std::ends;
|
||||||
|
fStat = new eoMOFitnessStat<EOT>(obj, s);
|
||||||
|
#endif
|
||||||
_state.storeFunctor(fStat);
|
_state.storeFunctor(fStat);
|
||||||
bStat[obj2]=true;
|
bStat[obj2]=true;
|
||||||
theStats[obj2]=fStat;
|
theStats[obj2]=fStat;
|
||||||
|
|
@ -131,12 +157,18 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
|
||||||
}
|
}
|
||||||
|
|
||||||
// then the fileSnapshots
|
// then the fileSnapshots
|
||||||
|
#ifdef HAVE_SSTREAM
|
||||||
|
std::ostringstream os;
|
||||||
|
os << "Front." << obj1 << "." << obj2 << "." << std::ends;
|
||||||
|
eoFileSnapshot& snapshot = _state.storeFunctor(
|
||||||
|
new eoFileSnapshot(dirName, frequency, os.str().c_str()));
|
||||||
|
#else
|
||||||
char s3[1024];
|
char s3[1024];
|
||||||
std::ostrstream os3(s3, 1022);
|
std::ostrstream os3(s3, 1022);
|
||||||
os3 << "Front." << obj1 << "." << obj2 << "." << std::ends;
|
os3 << "Front." << obj1 << "." << obj2 << "." << std::ends;
|
||||||
eoFileSnapshot & snapshot = _state.storeFunctor(new
|
eoFileSnapshot & snapshot = _state.storeFunctor(
|
||||||
eoFileSnapshot(dirName, frequency, s3 ) );
|
new eoFileSnapshot(dirName, frequency, s3 ) );
|
||||||
|
#endif
|
||||||
checkpoint.add(snapshot);
|
checkpoint.add(snapshot);
|
||||||
|
|
||||||
snapshot.add(*theStats[obj1]);
|
snapshot.add(*theStats[obj1]);
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,11 @@
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "eoParetoFitness.h"
|
#include "eoParetoFitness.h"
|
||||||
#include <assert.h>
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/** test program for Pareto Fitness */
|
/** test program for Pareto Fitness */
|
||||||
|
|
@ -192,4 +194,3 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue