From 73c97e6bfa1bfb7a96e7e91f1b5f6778fc91df8e Mon Sep 17 00:00:00 2001 From: kuepper Date: Wed, 29 Sep 2004 18:37:20 +0000 Subject: [PATCH] update for sstream --- eo/Makefile.am | 2 +- eo/Tutorial/.cvsignore | 1 + eo/app/gprop/gprop.h | 2 +- eo/src/do/make_checkpoint_pareto.h | 68 ++++++++++++++++++++++-------- eo/test/t-eoParetoFitness.cpp | 5 ++- 5 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 eo/Tutorial/.cvsignore diff --git a/eo/Makefile.am b/eo/Makefile.am index 034808a6f..5a1ea9277 100644 --- a/eo/Makefile.am +++ b/eo/Makefile.am @@ -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 diff --git a/eo/Tutorial/.cvsignore b/eo/Tutorial/.cvsignore new file mode 100644 index 000000000..70845e08e --- /dev/null +++ b/eo/Tutorial/.cvsignore @@ -0,0 +1 @@ +Makefile.in diff --git a/eo/app/gprop/gprop.h b/eo/app/gprop/gprop.h index 7c96b14cf..60e3bce6a 100644 --- a/eo/app/gprop/gprop.h +++ b/eo/app/gprop/gprop.h @@ -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 || diff --git a/eo/src/do/make_checkpoint_pareto.h b/eo/src/do/make_checkpoint_pareto.h index 37ab768f1..d14d40da3 100644 --- a/eo/src/do/make_checkpoint_pareto.h +++ b/eo/src/do/make_checkpoint_pareto.h @@ -27,13 +27,22 @@ #ifndef _make_checkpoint_pareto_h #define _make_checkpoint_pareto_h -#include +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#ifdef HAVE_SSTREAM +#include +#else +#include +#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& do_make_checkpoint_pareto(eoParser& _parser, eoState& _state, * eoSortedPopStat : whole population - type std::string (!!) */ - eoValueParam& 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& 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 > @@ -107,36 +123,52 @@ eoCheckPoint& 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* 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(obj1, os.str().c_str()); +#else char s[1024]; std::ostrstream os(s, 1022); os << "Obj. " << obj1 << std::ends; fStat = new eoMOFitnessStat(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(obj2, s2); + } + if (!bStat[obj2]) { // not already there: create it +#ifdef HAVE_SSTREAM + std::ostringstream os; + os << "Obj. " << obj2 << std::ends; + fStat = new eoMOFitnessStat(obj2, os.str().c_str()); +#else + char s[1024]; + std::ostrstream os2(s, 1022); + os << "Obj. " << obj2 << std::ends; + fStat = new eoMOFitnessStat(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]); diff --git a/eo/test/t-eoParetoFitness.cpp b/eo/test/t-eoParetoFitness.cpp index 1adcb1702..bd5d0d2bd 100644 --- a/eo/test/t-eoParetoFitness.cpp +++ b/eo/test/t-eoParetoFitness.cpp @@ -24,9 +24,11 @@ */ //----------------------------------------------------------------------------- +#include #include + #include "eoParetoFitness.h" -#include + using namespace std; /** test program for Pareto Fitness */ @@ -192,4 +194,3 @@ int main() } } -