Update for gcc-4.3 compatibility
This commit is contained in:
parent
1187a83c82
commit
0388f95758
11 changed files with 152 additions and 130 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <stdlib.h> // EXIT_SUCCESS EXIT_FAILURE
|
#include <stdlib.h> // EXIT_SUCCESS EXIT_FAILURE
|
||||||
#include <stdexcept> // exception
|
#include <stdexcept> // exception
|
||||||
#include <iostream> // cerr cout
|
#include <iostream> // cerr cout
|
||||||
#include <fstream> // ifstream
|
#include <fstream> // ifstream
|
||||||
#include <string> // string
|
#include <string> // string
|
||||||
|
|
@ -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();
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -65,7 +65,7 @@ int main(int argc, char** argv)
|
||||||
void arg(int argc, char** argv)
|
void arg(int argc, char** argv)
|
||||||
{
|
{
|
||||||
eoParser parser(argc, argv);
|
eoParser parser(argc, argv);
|
||||||
|
|
||||||
parser.processParam(pop_size, "genetic operators");
|
parser.processParam(pop_size, "genetic operators");
|
||||||
parser.processParam(generations, "genetic operators");
|
parser.processParam(generations, "genetic operators");
|
||||||
parser.processParam(mut_rate, "genetic operators");
|
parser.processParam(mut_rate, "genetic operators");
|
||||||
|
|
@ -82,7 +82,7 @@ void arg(int argc, char** argv)
|
||||||
load_file(train, "trn");
|
load_file(train, "trn");
|
||||||
load_file(validate, "val");
|
load_file(validate, "val");
|
||||||
load_file(test, "tst");
|
load_file(test, "tst");
|
||||||
|
|
||||||
phenotype::trn_max = train.size();
|
phenotype::trn_max = train.size();
|
||||||
phenotype::val_max = validate.size();
|
phenotype::val_max = validate.size();
|
||||||
phenotype::tst_max = test.size();
|
phenotype::tst_max = test.size();
|
||||||
|
|
@ -104,8 +104,8 @@ void load_file(mlp::set& set, const string& ext)
|
||||||
{
|
{
|
||||||
cerr << "can't open file \"" << filename << "\"" << endl;
|
cerr << "can't open file \"" << filename << "\"" << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ifs >> set;
|
ifs >> set;
|
||||||
|
|
||||||
if (set.size() == 0)
|
if (set.size() == 0)
|
||||||
|
|
@ -122,18 +122,18 @@ void ga()
|
||||||
// create population
|
// create population
|
||||||
eoInitChrom init;
|
eoInitChrom init;
|
||||||
eoPop<Chrom> pop(pop_size.value(), init);
|
eoPop<Chrom> pop(pop_size.value(), init);
|
||||||
|
|
||||||
// evaluate population
|
// evaluate population
|
||||||
eoEvalFuncPtr<Chrom> evaluator(eoChromEvaluator);
|
eoEvalFuncPtr<Chrom> evaluator(eoChromEvaluator);
|
||||||
apply<Chrom>(evaluator, pop);
|
apply<Chrom>(evaluator, pop);
|
||||||
|
|
||||||
// selector
|
// selector
|
||||||
eoStochTournamentSelect<Chrom> select;
|
eoStochTournamentSelect<Chrom> select;
|
||||||
|
|
||||||
// genetic operators
|
// genetic operators
|
||||||
eoChromMutation mutation;
|
eoChromMutation mutation;
|
||||||
eoChromXover xover;
|
eoChromXover xover;
|
||||||
|
|
||||||
// stop condition
|
// stop condition
|
||||||
eoGenContinue<Chrom> continuator1(generations.value());
|
eoGenContinue<Chrom> continuator1(generations.value());
|
||||||
phenotype p; p.val_ok = validate.size() - 1; p.mse_error = 0;
|
phenotype p; p.val_ok = validate.size() - 1; p.mse_error = 0;
|
||||||
|
|
@ -142,23 +142,23 @@ void ga()
|
||||||
|
|
||||||
// checkpoint
|
// checkpoint
|
||||||
eoCheckPoint<Chrom> checkpoint(continuator);
|
eoCheckPoint<Chrom> checkpoint(continuator);
|
||||||
|
|
||||||
// monitor
|
// monitor
|
||||||
eoStdoutMonitor monitor;
|
eoStdoutMonitor monitor;
|
||||||
checkpoint.add(monitor);
|
checkpoint.add(monitor);
|
||||||
|
|
||||||
// statistics
|
// statistics
|
||||||
eoBestFitnessStat<Chrom> stats;
|
eoBestFitnessStat<Chrom> stats;
|
||||||
checkpoint.add(stats);
|
checkpoint.add(stats);
|
||||||
monitor.add(stats);
|
monitor.add(stats);
|
||||||
|
|
||||||
// genetic algorithm
|
// genetic algorithm
|
||||||
eoSGA<Chrom> sga(select,
|
eoSGA<Chrom> sga(select,
|
||||||
xover, xover_rate.value(),
|
xover, xover_rate.value(),
|
||||||
mutation, mut_rate.value(),
|
mutation, mut_rate.value(),
|
||||||
evaluator,
|
evaluator,
|
||||||
checkpoint);
|
checkpoint);
|
||||||
|
|
||||||
sga(pop);
|
sga(pop);
|
||||||
|
|
||||||
cout << "best: " << *max_element(pop.begin(), pop.end()) << endl;
|
cout << "best: " << *max_element(pop.begin(), pop.end()) << endl;
|
||||||
|
|
@ -166,6 +166,6 @@ void ga()
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode:C++
|
// mode:C++
|
||||||
// End:
|
// End:
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
@ -69,9 +69,9 @@ struct phenotype
|
||||||
{
|
{
|
||||||
return (!(a == b)) && (!(a < b));
|
return (!(a == b)) && (!(a < b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, const phenotype& p)
|
friend std::ostream& operator<<(std::ostream& os, const phenotype& p)
|
||||||
{
|
{
|
||||||
return os << p.trn_ok << "/" << p.trn_max << " "
|
return os << p.trn_ok << "/" << p.trn_max << " "
|
||||||
|
|
@ -79,7 +79,7 @@ struct phenotype
|
||||||
<< p.tst_ok << "/" << p.tst_max << " "
|
<< p.tst_ok << "/" << p.tst_max << " "
|
||||||
<< p.mse_error;
|
<< p.mse_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend std::istream& operator>>(std::istream& is, phenotype& p)
|
friend std::istream& operator>>(std::istream& is, phenotype& p)
|
||||||
{
|
{
|
||||||
return is; // complete me
|
return is; // complete me
|
||||||
|
|
@ -111,14 +111,14 @@ public:
|
||||||
|
|
||||||
std::string className() const { return "Chrom"; }
|
std::string className() const { return "Chrom"; }
|
||||||
|
|
||||||
void printOn (std::ostream& os) const
|
void printOn (std::ostream& os) const
|
||||||
{
|
{
|
||||||
os << std::setprecision(3) << static_cast<genotype>(*this) << " \t"
|
os << std::setprecision(3) << static_cast<genotype>(*this) << " \t"
|
||||||
<< fitness();
|
<< fitness();
|
||||||
// os << fitness();
|
// os << fitness();
|
||||||
}
|
}
|
||||||
|
|
||||||
void readFrom (std::istream& is)
|
void readFrom (std::istream& is)
|
||||||
{
|
{
|
||||||
invalidate(); // complete me
|
invalidate(); // complete me
|
||||||
}
|
}
|
||||||
|
|
@ -201,16 +201,16 @@ public:
|
||||||
int correct(const mlp::net& net, const mlp::set& set)
|
int correct(const mlp::net& net, const mlp::set& set)
|
||||||
{
|
{
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
|
|
||||||
for (mlp::set::const_iterator s = set.begin(); s != set.end(); ++s)
|
for (mlp::set::const_iterator s = set.begin(); s != set.end(); ++s)
|
||||||
{
|
{
|
||||||
unsigned 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 ||
|
||||||
s->output[i] > 0.5 && net(s->input)[i] > 0.5)
|
s->output[i] > 0.5 && net(s->input)[i] > 0.5)
|
||||||
++partial;
|
++partial;
|
||||||
|
|
||||||
if (partial == s->output.size())
|
if (partial == s->output.size())
|
||||||
++sum;
|
++sum;
|
||||||
}
|
}
|
||||||
|
|
@ -234,6 +234,6 @@ phenotype eoChromEvaluator(const Chrom& chrom)
|
||||||
|
|
||||||
#endif // gprop_h
|
#endif // gprop_h
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode:C++
|
// mode:C++
|
||||||
// End:
|
// End:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// eoFitContinue.h
|
// eoFitContinue.h
|
||||||
// (c) Maarten Keijzer, GeNeura Team, 1999, 2000
|
// (c) Maarten Keijzer, GeNeura Team, 1999, 2000
|
||||||
/*
|
/*
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
|
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
#include <eoContinue.h>
|
#include <eoContinue.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fitness continuation:
|
Fitness continuation:
|
||||||
|
|
||||||
Continues until the maximum fitness level is reached.
|
Continues until the maximum fitness level is reached.
|
||||||
*/
|
*/
|
||||||
|
|
@ -39,18 +39,17 @@ public:
|
||||||
/// Define Fitness
|
/// Define Fitness
|
||||||
typedef typename EOT::Fitness FitnessType;
|
typedef typename EOT::Fitness FitnessType;
|
||||||
|
|
||||||
/// Ctor
|
/// Ctor
|
||||||
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);
|
||||||
if (bestCurrentFitness >= maximum)
|
if (bestCurrentFitness >= maximum)
|
||||||
{
|
{
|
||||||
std::cout << "STOP in eoFitContinue: Best fitness has reached " <<
|
std::cout << "STOP in eoFitContinue: Best fitness has reached " <<
|
||||||
bestCurrentFitness << "\n";
|
bestCurrentFitness << "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -110,15 +110,15 @@ private :
|
||||||
/*
|
/*
|
||||||
@param proc First evaluation
|
@param proc First evaluation
|
||||||
@param initVelo Initialization of the velocity
|
@param initVelo Initialization of the velocity
|
||||||
@param initBest Initialization of the best
|
@param initBest Initialization of the best
|
||||||
*/
|
*/
|
||||||
eoUF<POT&, void>& proc;
|
eoUF<POT&, void>& proc;
|
||||||
eoVelocityInit < POT > & initVelo;
|
eoVelocityInit < POT > & initVelo;
|
||||||
eoParticleBestInit <POT> & initBest;
|
eoParticleBestInit <POT> & initBest;
|
||||||
eoPopEvalFunc <POT>& procPara;
|
eoPopEvalFunc <POT>& procPara;
|
||||||
eoTopology <POT> & topology;
|
eoTopology <POT> & topology;
|
||||||
eoPop < POT > & pop;
|
eoPop < POT > & pop;
|
||||||
|
|
||||||
class eoDummyEval : public eoPopEvalFunc<POT>
|
class eoDummyEval : public eoPopEvalFunc<POT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,27 @@
|
||||||
// -*- 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
|
||||||
// (c) INRIA Futurs - Dolphin Team - Thomas Legrand 2007
|
// (c) INRIA Futurs - Dolphin Team - Thomas Legrand 2007
|
||||||
/*
|
/*
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2 of the License, or (at your option) any later version.
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Lesser General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||||
thomas.legrand@lifl.fr
|
thomas.legrand@lifl.fr
|
||||||
Marc.Schoenauer@polytechnique.fr
|
Marc.Schoenauer@polytechnique.fr
|
||||||
mak@dhi.dk
|
mak@dhi.dk
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef eoTwoOptMutation_h
|
#ifndef eoTwoOptMutation_h
|
||||||
|
|
@ -33,48 +31,52 @@
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Especially designed for combinatorial problem such as the TSP.
|
* Especially designed for combinatorial problem such as the TSP.
|
||||||
*/
|
*/
|
||||||
template<class EOT> class eoTwoOptMutation: public eoMonOp<EOT>
|
template<class EOT> class eoTwoOptMutation: public eoMonOp<EOT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef typename EOT::AtomType GeneType;
|
|
||||||
|
|
||||||
/// CTor
|
|
||||||
eoTwoOptMutation(){}
|
|
||||||
|
|
||||||
|
|
||||||
/// The class name.
|
|
||||||
virtual std::string className() const { return "eoTwoOptMutation"; }
|
|
||||||
|
|
||||||
|
typedef typename EOT::AtomType GeneType;
|
||||||
|
|
||||||
/**
|
/// CTor
|
||||||
*
|
eoTwoOptMutation(){}
|
||||||
* @param eo The cromosome which is going to be changed.
|
|
||||||
*/
|
|
||||||
bool operator()(EOT& _eo)
|
|
||||||
{
|
|
||||||
unsigned i,j,from,to;
|
|
||||||
|
|
||||||
// generate two different indices
|
|
||||||
i=eo::rng.random(_eo.size());
|
|
||||||
do j = eo::rng.random(_eo.size()); while (i == j);
|
|
||||||
|
|
||||||
from=std::min(i,j);
|
|
||||||
to=std::max(i,j);
|
|
||||||
int idx =(to-from)/2;
|
|
||||||
|
|
||||||
// inverse between from and to
|
|
||||||
for(unsigned int k = 0; k <= idx ;k++)
|
|
||||||
std::swap(_eo[from+k],_eo[to-k]);
|
|
||||||
|
|
||||||
return true;
|
/// The class name.
|
||||||
|
virtual std::string className() const { return "eoTwoOptMutation"; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param eo The cromosome which is going to be changed.
|
||||||
|
*/
|
||||||
|
bool operator()(EOT& _eo) {
|
||||||
|
// generate two different indices
|
||||||
|
unsigned i(eo::rng.random(_eo.size()));
|
||||||
|
unsigned j;
|
||||||
|
do {
|
||||||
|
j = eo::rng.random(_eo.size());
|
||||||
|
} while(i == j);
|
||||||
|
unsigned from(std::min(i,j));
|
||||||
|
unsigned to(std::max(i,j));
|
||||||
|
unsigned idx((to - from)/2);
|
||||||
|
|
||||||
|
// inverse between from and to
|
||||||
|
for(unsigned k = 0; k <= idx; ++k)
|
||||||
|
std::swap(_eo[from+k],_eo[to-k]);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// coding: iso-8859-1
|
||||||
|
// mode: C++
|
||||||
|
// c-file-offsets: ((c . 0))
|
||||||
|
// c-file-style: "Stroustrup"
|
||||||
|
// fill-column: 80
|
||||||
|
// End:
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
||||||
|
|
@ -102,7 +103,7 @@ public:
|
||||||
{
|
{
|
||||||
resize(bits.size());
|
resize(bits.size());
|
||||||
std::transform(bits.begin(), bits.end(), begin(),
|
std::transform(bits.begin(), bits.end(), begin(),
|
||||||
std::bind2nd(std::equal_to<char>(), '1'));
|
std::bind2nd(std::equal_to<char>(), '1'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -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 */
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
// -*- 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
|
||||||
/*
|
/*
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
|
|
@ -26,19 +24,21 @@
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// to avoid long name warnings
|
// to avoid long name warnings
|
||||||
#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
|
||||||
*
|
*
|
||||||
* MUST be called after ALL parameters have been read in order to list them
|
* MUST be called after ALL parameters have been read in order to list them
|
||||||
*
|
*
|
||||||
* Warning: this is a plain .cpp file and shoudl NOT be included anywhere,
|
* Warning: this is a plain .cpp file and shoudl NOT be included anywhere,
|
||||||
* but compiled separately and stored in a library.
|
* but compiled separately and stored in a library.
|
||||||
*
|
*
|
||||||
* It is declared in all make_xxx.h files in representation-dependent dirs
|
* It is declared in all make_xxx.h files in representation-dependent dirs
|
||||||
|
|
@ -63,15 +63,15 @@ void make_help(eoParser & _parser)
|
||||||
if (_parser.userNeedsHelp())
|
if (_parser.userNeedsHelp())
|
||||||
{
|
{
|
||||||
_parser.printHelp(cout);
|
_parser.printHelp(cout);
|
||||||
cout << "You can use an edited copy of file " << statusParam.value()
|
cout << "You can use an edited copy of file " << statusParam.value()
|
||||||
<< " as parameter file" << endl;
|
<< " as parameter file" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** test a dir.
|
/** test a dir.
|
||||||
* Creates it if does not exist
|
* Creates it if does not exist
|
||||||
* If exists, throws an exception or erase everything there,
|
* If exists, throws an exception or erase everything there,
|
||||||
* depending on last parameter
|
* depending on last parameter
|
||||||
*
|
*
|
||||||
* Always return true (for code easy writing on the other side :-)
|
* Always return true (for code easy writing on the other side :-)
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Reference in a new issue