Update for gcc-4.3 compatibility

This commit is contained in:
kuepper 2008-03-31 19:11:13 +00:00
commit 0388f95758
11 changed files with 152 additions and 130 deletions

View file

@ -35,7 +35,7 @@ eoValueParam<unsigned> hiddenp(0, "hidden", "number of neurons in hidden layer",
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void arg(int argc, char** argv); void arg(int argc, char** argv);
void load_file(mlp::set& s, const string& s); void load_file(mlp::set& s1, const string& s2);
void ga(); void ga();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -52,12 +52,12 @@ struct phenotype
friend bool operator<(const phenotype& a, const phenotype& b) friend bool operator<(const phenotype& a, const phenotype& b)
{ {
return a.val_ok < b.val_ok || !(b.val_ok < a.val_ok) && b.mse_error < a.mse_error; return (a.val_ok < b.val_ok) || (!(b.val_ok < a.val_ok)) && (b.mse_error < a.mse_error);
} }
friend bool operator==(const phenotype& a, const phenotype& b) friend bool operator==(const phenotype& a, const phenotype& b)
{ {
return a.val_ok == b.val_ok && b.mse_error == a.mse_error; return (a.val_ok == b.val_ok) && (b.mse_error == a.mse_error);
} }
friend bool operator>=(const phenotype& a, const phenotype& b) friend bool operator>=(const phenotype& a, const phenotype& b)

View file

@ -43,8 +43,7 @@ public:
eoFitContinue( const FitnessType _maximum) eoFitContinue( const FitnessType _maximum)
: eoContinue<EOT> (), maximum( _maximum ) {}; : eoContinue<EOT> (), maximum( _maximum ) {};
/** Returns false when a fitness criterium is /** Returns false when a fitness criterium is reached. Assumes pop is not sorted! */
* reached. Assumes pop is not sorted! */
virtual bool operator() ( const eoPop<EOT>& _pop ) virtual bool operator() ( const eoPop<EOT>& _pop )
{ {
FitnessType bestCurrentFitness = _pop.nth_element_fitness(0); FitnessType bestCurrentFitness = _pop.nth_element_fitness(0);

View file

@ -68,7 +68,7 @@ public:
eoParticleBestInit <POT> &_initBest, eoParticleBestInit <POT> &_initBest,
eoTopology <POT> &_topology, eoTopology <POT> &_topology,
eoPop < POT > &_pop eoPop < POT > &_pop
) : proc(_proc), procPara(dummyEval), initVelo(_initVelo), initBest(_initBest), topology(_topology), pop(_pop) ) : proc(_proc), initVelo(_initVelo), procPara(dummyEval), initBest(_initBest), topology(_topology), pop(_pop)
{} {}
//! Constructor for parallel evaluation //! Constructor for parallel evaluation

View file

@ -1,5 +1,3 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// eoTwoOptMutation.h // eoTwoOptMutation.h
// (c) GeNeura Team, 2000 - EEAAX 2000 - Maarten Keijzer 2000 // (c) GeNeura Team, 2000 - EEAAX 2000 - Maarten Keijzer 2000
@ -44,31 +42,27 @@ template<class EOT> class eoTwoOptMutation: public eoMonOp<EOT>
/// CTor /// CTor
eoTwoOptMutation(){} eoTwoOptMutation(){}
/// The class name. /// The class name.
virtual std::string className() const { return "eoTwoOptMutation"; } virtual std::string className() const { return "eoTwoOptMutation"; }
/** /**
* *
* @param eo The cromosome which is going to be changed. * @param eo The cromosome which is going to be changed.
*/ */
bool operator()(EOT& _eo) bool operator()(EOT& _eo) {
{
unsigned i,j,from,to;
// generate two different indices // generate two different indices
i=eo::rng.random(_eo.size()); unsigned i(eo::rng.random(_eo.size()));
do j = eo::rng.random(_eo.size()); while (i == j); unsigned j;
do {
from=std::min(i,j); j = eo::rng.random(_eo.size());
to=std::max(i,j); } while(i == j);
int idx =(to-from)/2; unsigned from(std::min(i,j));
unsigned to(std::max(i,j));
unsigned idx((to - from)/2);
// inverse between from and to // inverse between from and to
for(unsigned int k = 0; k <= idx ;k++) for(unsigned k = 0; k <= idx; ++k)
std::swap(_eo[from+k],_eo[to-k]); std::swap(_eo[from+k],_eo[to-k]);
return true; return true;
} }
@ -78,3 +72,11 @@ template<class EOT> class eoTwoOptMutation: public eoMonOp<EOT>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif #endif
// Local Variables:
// coding: iso-8859-1
// mode: C++
// c-file-offsets: ((c . 0))
// c-file-style: "Stroustrup"
// fill-column: 80
// End:

View file

@ -35,9 +35,10 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <iostream> // std::ostream, std::istream #include <algorithm>
#include <functional> // bind2nd #include <functional>
#include <string> // std::string #include <iostream>
#include <string>
#include "eoVector.h" #include "eoVector.h"
@ -113,6 +114,9 @@ public:
// Local Variables: // Local Variables:
// coding: iso-8859-1
// mode: C++ // mode: C++
// c-file-offsets: ((c . 0))
// c-file-style: "Stroustrup" // c-file-style: "Stroustrup"
// fill-column: 80
// End: // End:

View file

@ -41,7 +41,7 @@ class eoExternalEO : public EO<Fit>, virtual public External
public : public :
eoExternalEO() eoExternalEO()
: EO<Fit>(), External() : External(), EO<Fit>()
{} {}
/** Init externalEo with the struct itself and set fitness to zero */ /** Init externalEo with the struct itself and set fitness to zero */

View file

@ -1,5 +1,3 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// eoFileSnapshot.h // eoFileSnapshot.h
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2001 // (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2001
@ -27,8 +25,10 @@
#ifndef _eoFileSnapshot_h #ifndef _eoFileSnapshot_h
#define _eoFileSnapshot_h #define _eoFileSnapshot_h
#include <string> #include <cstdlib>
#include <fstream> #include <fstream>
#include <string>
#include <utils/eoParam.h> #include <utils/eoParam.h>
#include <utils/eoMonitor.h> #include <utils/eoMonitor.h>
#include <eoObject.h> #include <eoObject.h>
@ -188,3 +188,12 @@ private :
}; };
#endif #endif
// Local Variables:
// coding: iso-8859-1
// mode: C++
// c-file-offsets: ((c . 0))
// c-file-style: "Stroustrup"
// fill-column: 80
// End:

View file

@ -11,7 +11,6 @@ eoMonitor& eoGnuplot1DSnapshot::operator()()
// update file using the eoFileMonitor method // update file using the eoFileMonitor method
eoFileSnapshot::operator()(); eoFileSnapshot::operator()();
#ifdef HAVE_GNUPLOT #ifdef HAVE_GNUPLOT
// sends plot order to gnuplot // sends plot order to gnuplot
std::ostringstream os; std::ostringstream os;
os << "set title 'Gen. " << getCounter() << "'; plot '" os << "set title 'Gen. " << getCounter() << "'; plot '"
@ -25,8 +24,10 @@ eoMonitor& eoGnuplot1DSnapshot::operator()()
} }
// Local Variables: // Local Variables:
// coding: iso-8859-1
// mode: C++
// c-file-offsets: ((c . 0))
// c-file-style: "Stroustrup" // c-file-style: "Stroustrup"
// fill-column: 80 // fill-column: 80
// End: // End:

View file

@ -1,5 +1,3 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// make_help.h // make_help.h
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001 // (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
@ -28,10 +26,12 @@
#pragma warning(disable:4786) #pragma warning(disable:4786)
#endif #endif
#include <utils/eoParser.h> #include <cstdlib>
#include <fstream> #include <fstream>
#include <stdexcept> #include <stdexcept>
#include <utils/eoParser.h>
using namespace std; using namespace std;
/** Generation of the status file, and output of the help message if needed /** Generation of the status file, and output of the help message if needed
@ -107,3 +107,12 @@ bool testDirRes(std::string _dirName, bool _erase=true)
throw runtime_error(s); throw runtime_error(s);
return true; return true;
} }
// Local Variables:
// coding: iso-8859-1
// mode: C++
// c-file-offsets: ((c . 0))
// c-file-style: "Stroustrup"
// fill-column: 80
// End:

View file

@ -1,13 +1,11 @@
//-----------------------------------------------------------------------------
// to avoid long name warnings // to avoid long name warnings
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4786) #pragma warning(disable:4786)
#endif #endif
#include <stdexcept> // runtime_error #include <cstring>
#include <stdexcept>
// general
#include <eo> #include <eo>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------