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
|
||||
endif
|
||||
|
||||
SUBDIRS = src test doc contrib win $(SUBDIRS_APP) $(SUBDIRS_TUT)
|
||||
SUBDIRS = src doc contrib win $(SUBDIRS_APP) $(SUBDIRS_TUT) test
|
||||
|
||||
|
||||
# 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)
|
||||
{
|
||||
int partial = 0;
|
||||
unsigned partial = 0;
|
||||
|
||||
for (unsigned i = 0; i < s->output.size(); ++i)
|
||||
if (s->output[i] < 0.5 && net(s->input)[i] < 0.5 ||
|
||||
|
|
|
|||
|
|
@ -27,13 +27,22 @@
|
|||
#ifndef _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 "eoParetoFitness.h"
|
||||
#include "eoEvalFuncCounter.h"
|
||||
#include "utils/checkpointing"
|
||||
#include "utils/selectors.h"
|
||||
|
||||
// at the moment, in utils/make_help.cpp
|
||||
// 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 (!!)
|
||||
*/
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
eoParamParamType & fPlot = fPlotParam.value(); // std::pair<std::string,std::vector<std::string> >
|
||||
|
|
@ -107,36 +123,52 @@ eoCheckPoint<EOT>& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state,
|
|||
unsigned obj1 = atoi(fPlot.second[i].c_str());
|
||||
unsigned obj2 = atoi(fPlot.second[i+1].c_str());
|
||||
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];
|
||||
std::ostrstream os(s, 1022);
|
||||
os << "Obj. " << obj1 << std::ends;
|
||||
fStat = new eoMOFitnessStat<EOT>(obj1, s);
|
||||
#endif
|
||||
_state.storeFunctor(fStat);
|
||||
bStat[obj1]=true;
|
||||
theStats[obj1]=fStat;
|
||||
checkpoint.add(*fStat);
|
||||
}
|
||||
if (!bStat[obj2]) // not already there: create it
|
||||
{
|
||||
char s2[1024];
|
||||
std::ostrstream os2(s2, 1022);
|
||||
os2 << "Obj. " << obj2 << std::ends;
|
||||
fStat = new eoMOFitnessStat<EOT>(obj2, s2);
|
||||
}
|
||||
if (!bStat[obj2]) { // not already there: create it
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
os << "Obj. " << obj2 << std::ends;
|
||||
fStat = new eoMOFitnessStat<EOT>(obj2, os.str().c_str());
|
||||
#else
|
||||
char s[1024];
|
||||
std::ostrstream os2(s, 1022);
|
||||
os << "Obj. " << obj2 << std::ends;
|
||||
fStat = new eoMOFitnessStat<EOT>(obj, s);
|
||||
#endif
|
||||
_state.storeFunctor(fStat);
|
||||
bStat[obj2]=true;
|
||||
theStats[obj2]=fStat;
|
||||
checkpoint.add(*fStat);
|
||||
}
|
||||
}
|
||||
|
||||
// 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];
|
||||
std::ostrstream os3(s3, 1022);
|
||||
os3 << "Front." << obj1 << "." << obj2 << "." << std::ends;
|
||||
eoFileSnapshot & snapshot = _state.storeFunctor(new
|
||||
eoFileSnapshot(dirName, frequency, s3 ) );
|
||||
|
||||
eoFileSnapshot & snapshot = _state.storeFunctor(
|
||||
new eoFileSnapshot(dirName, frequency, s3 ) );
|
||||
#endif
|
||||
checkpoint.add(snapshot);
|
||||
|
||||
snapshot.add(*theStats[obj1]);
|
||||
|
|
|
|||
|
|
@ -24,9 +24,11 @@
|
|||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include "eoParetoFitness.h"
|
||||
#include <assert.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/** test program for Pareto Fitness */
|
||||
|
|
@ -192,4 +194,3 @@ int main()
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue