Adjust code to perform to C++ standard according to gcc-3.4
interpretation... (Have not compiled/checked/changed paradisEO.) That is, the current code compiles with gcc-3.4 and the checks (besides t-MGE1bit) all pass.
This commit is contained in:
parent
faaadf7599
commit
85a326c5e4
35 changed files with 1057 additions and 864 deletions
|
|
@ -464,4 +464,5 @@ namespace mlp {
|
|||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// c-file-style: "Stroustrup"
|
||||
// End:
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
CVS Info: $Date: 2003-02-27 19:26:44 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/contrib/MGE/eoVirus.h,v 1.2 2003-02-27 19:26:44 okoenig Exp $ $Author: okoenig $
|
||||
CVS Info: $Date: 2004-12-23 15:29:07 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/contrib/MGE/eoVirus.h,v 1.3 2004-12-23 15:29:07 kuepper Exp $ $Author: kuepper $
|
||||
*/
|
||||
|
||||
#ifndef eoVirus_h
|
||||
|
|
@ -43,10 +43,16 @@ CVS Info: $Date: 2003-02-27 19:26:44 $ $Header: /home/nojhan/dev/eodev/eodev_cvs
|
|||
\ingroup bitstring
|
||||
* based on STL's vector<bool> specialization.
|
||||
*/
|
||||
template <class FitT> class eoVirus: public eoBit<FitT>
|
||||
template <class FitT>
|
||||
class eoVirus: public eoBit<FitT>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoBit<FitT>::begin;
|
||||
using eoBit<FitT>::end;
|
||||
using eoBit<FitT>::size;
|
||||
|
||||
|
||||
/**
|
||||
* (Default) Constructor.
|
||||
* @param size Size of the binary std::string.
|
||||
|
|
@ -110,3 +116,9 @@ template <class FitT> class eoVirus: public eoBit<FitT>
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif //eoBit_h
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// c-file-style: "Stroustrup"
|
||||
// End:
|
||||
|
|
|
|||
|
|
@ -48,13 +48,11 @@ class eoDominanceMap : public eoUF<const eoPop<EoType>&, void>, public std::vect
|
|||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
Clears the map
|
||||
*/
|
||||
void clear()
|
||||
{
|
||||
/** Clears the map */
|
||||
void clear() {
|
||||
std::vector<std::vector<bool> >::clear();
|
||||
fitnesses.clear();
|
||||
#warning Is this correct? Was: "fitnesses.clear()"
|
||||
fitness.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -43,19 +43,21 @@ template <class EOT>
|
|||
class eoLinearFitScaling : public eoPerf2Worth<EOT> // false: do not cache fitness
|
||||
{
|
||||
public:
|
||||
|
||||
using eoLinearFitScaling< EOT >::value;
|
||||
|
||||
/* Ctor:
|
||||
@param _p selective pressure (in (1,2]
|
||||
@param _p selective pressure (in (1,2])
|
||||
@param _e exponent (1 == linear)
|
||||
*/
|
||||
eoLinearFitScaling(double _p=2.0):
|
||||
pressure(_p) {}
|
||||
eoLinearFitScaling(double _p=2.0)
|
||||
: pressure(_p) {}
|
||||
|
||||
/* COmputes the ranked fitness: fitnesses range in [m,M]
|
||||
with m=2-pressure/popSize and M=pressure/popSize.
|
||||
in between, the progression depends on exponent (linear if 1).
|
||||
*/
|
||||
virtual void operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
virtual void operator()(const eoPop<EOT>& _pop) {
|
||||
unsigned pSize =_pop.size();
|
||||
// value() refers to the vector of worthes (we're in an eoParamvalue)
|
||||
value().resize(pSize);
|
||||
|
|
@ -76,12 +78,11 @@ public:
|
|||
double alpha = (pressure-1)/denom;
|
||||
double beta = (bestFitness - pressure*averageFitness)/denom;
|
||||
|
||||
for (i=0; i<pSize; i++) // truncate to 0
|
||||
{
|
||||
for (i=0; i<pSize; i++) { // truncate to 0
|
||||
value()[i] = std::max(alpha*_pop[i].fitness()+beta, 0.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
double pressure; // selective pressure
|
||||
};
|
||||
|
|
|
|||
|
|
@ -43,7 +43,10 @@ class eoNDSorting : public eoPerf2WorthCached<EOT, double>
|
|||
{
|
||||
public:
|
||||
|
||||
eoNDSorting() : nasty_declone_flag_that_only_is_implemented_for_two_objectives(false)
|
||||
using eoNDSorting< EOT >::value;
|
||||
|
||||
eoNDSorting()
|
||||
: nasty_declone_flag_that_only_is_implemented_for_two_objectives(false)
|
||||
{}
|
||||
|
||||
/** Pure virtual function that calculates the 'distance' for each element in the current front
|
||||
|
|
@ -409,14 +412,19 @@ public :
|
|||
double nicheSize;
|
||||
};
|
||||
|
||||
/**
|
||||
Adapted from Deb, Agrawal, Pratab and Meyarivan: A Fast Elitist Non-Dominant Sorting Genetic Algorithm for MultiObjective Optimization: NSGA-II
|
||||
KanGAL Report No. 200001
|
||||
/** @brief Fast Elitist Non-Dominant Sorting Genetic Algorithm
|
||||
|
||||
Note that this class does not do the sorting per se, but the sorting of it worth_std::vector will give the right order
|
||||
Adapted from Deb, Agrawal, Pratab and Meyarivan: A Fast Elitist
|
||||
Non-Dominant Sorting Genetic Algorithm for MultiObjective
|
||||
Optimization: NSGA-II KanGAL Report No. 200001
|
||||
|
||||
The crowding distance is calculated as the sum of the distances to the nearest neighbours. As we need to return the
|
||||
penalty value, we have to invert that and invert it again in the base class, but such is life, sigh
|
||||
Note that this class does not do the sorting per se, but the sorting
|
||||
of it worth_std::vector will give the right order
|
||||
|
||||
The crowding distance is calculated as the sum of the distances to
|
||||
the nearest neighbours. As we need to return the penalty value, we
|
||||
have to invert that and invert it again in the base class, but such
|
||||
is life, sigh
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoNDSorting_II : public eoNDSorting<EOT>
|
||||
|
|
|
|||
|
|
@ -88,21 +88,19 @@ template <class EOT>
|
|||
class eoSequentialOp : public eoOpContainer<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoOpContainer< EOT >::ops;
|
||||
using eoOpContainer< EOT >::rates;
|
||||
|
||||
typedef unsigned position_type;
|
||||
|
||||
|
||||
void apply(eoPopulator<EOT>& _pop)
|
||||
{
|
||||
void apply(eoPopulator<EOT>& _pop) {
|
||||
position_type pos = _pop.tellp();
|
||||
|
||||
for (size_t i = 0; i < rates.size(); ++i)
|
||||
{
|
||||
for (size_t i = 0; i < rates.size(); ++i) {
|
||||
_pop.seekp(pos);
|
||||
|
||||
do
|
||||
{
|
||||
if (eo::rng.flip(rates[i]))
|
||||
{
|
||||
do {
|
||||
if (eo::rng.flip(rates[i])) {
|
||||
// try
|
||||
// {
|
||||
// apply it to all the guys in the todo std::list
|
||||
|
|
@ -131,12 +129,16 @@ class eoSequentialOp : public eoOpContainer<EOT>
|
|||
};
|
||||
|
||||
|
||||
|
||||
/** The proportional versions: easy! */
|
||||
template <class EOT>
|
||||
class eoProportionalOp : public eoOpContainer<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoOpContainer< EOT >::ops;
|
||||
using eoOpContainer< EOT >::rates;
|
||||
|
||||
void apply(eoPopulator<EOT>& _pop)
|
||||
{
|
||||
unsigned i = eo::rng.roulette_wheel(rates);
|
||||
|
|
|
|||
|
|
@ -41,8 +41,11 @@ class eoParetoRanking : public eoPerf2WorthCached<EOT, double>
|
|||
{
|
||||
public:
|
||||
|
||||
eoParetoRanking(eoDominanceMap<EOT>& _dominanceMap) :
|
||||
eoPerf2WorthCached<EOT, double>(), dominanceMap(_dominanceMap) {}
|
||||
using eoParetoRanking< EOT>::value;
|
||||
|
||||
eoParetoRanking(eoDominanceMap<EOT>& _dominanceMap)
|
||||
: eoPerf2WorthCached<EOT, double>(), dominanceMap(_dominanceMap)
|
||||
{}
|
||||
|
||||
void calculate_worths(const eoPop<EOT>& _pop)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
/** Base class to transform raw fitnesses into fitness for selection
|
||||
/** @brief Base class to transform raw fitnesses into fitness for selection
|
||||
|
||||
@see eoSelectFromWorth
|
||||
*/
|
||||
|
|
@ -43,12 +43,16 @@ template <class EOT, class WorthT = double>
|
|||
class eoPerf2Worth : public eoUF<const eoPop<EOT>&, void>, public eoValueParam<std::vector<WorthT> >
|
||||
{
|
||||
public:
|
||||
eoPerf2Worth(std::string _description = "Worths"):eoValueParam<std::vector<WorthT> >(std::vector<WorthT>(0),
|
||||
_description) {}
|
||||
|
||||
/**
|
||||
Sort population according to worth, will keep the worths and fitness_cache in sync with the population.
|
||||
*/
|
||||
using eoPerf2Worth<EOT, WorthT>::value;
|
||||
|
||||
/** @brief default constructor */
|
||||
eoPerf2Worth(std::string _description = "Worths")
|
||||
: eoValueParam<std::vector<WorthT> >(std::vector<WorthT>(0), _description)
|
||||
{}
|
||||
|
||||
/** Sort population according to worth, will keep the worths and
|
||||
fitness_cache in sync with the population. */
|
||||
virtual void sort_pop(eoPop<EOT>& _pop)
|
||||
{ // start with a std::vector of indices
|
||||
std::vector<unsigned> indices(_pop.size());
|
||||
|
|
@ -75,15 +79,14 @@ class eoPerf2Worth : public eoUF<const eoPop<EOT>&, void>, public eoValueParam<s
|
|||
std::swap(value(), tmp_worths);
|
||||
}
|
||||
|
||||
/** helper class used to sort indices into populations/worths
|
||||
*/
|
||||
/** helper class used to sort indices into populations/worths */
|
||||
class compare_worth
|
||||
{
|
||||
public:
|
||||
|
||||
compare_worth(const std::vector<WorthT>& _worths) : worths(_worths) {}
|
||||
|
||||
bool operator()(unsigned a, unsigned b) const
|
||||
{
|
||||
bool operator()(unsigned a, unsigned b) const {
|
||||
return worths[b] < worths[a]; // sort in descending (!) order
|
||||
}
|
||||
|
||||
|
|
@ -92,11 +95,12 @@ class eoPerf2Worth : public eoUF<const eoPop<EOT>&, void>, public eoValueParam<s
|
|||
const std::vector<WorthT>& worths;
|
||||
};
|
||||
|
||||
virtual void resize(eoPop<EOT>& _pop, unsigned sz)
|
||||
{
|
||||
|
||||
|
||||
virtual void resize(eoPop<EOT>& _pop, unsigned sz) {
|
||||
_pop.resize(sz);
|
||||
value().resize(sz);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -107,6 +111,9 @@ template <class EOT, class WorthT = typename EOT::Fitness>
|
|||
class eoPerf2WorthCached : public eoPerf2Worth<EOT, WorthT>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoPerf2Worth<EOT, WorthT>::value;
|
||||
|
||||
eoPerf2WorthCached(std::string _description = "Worths") : eoPerf2Worth<EOT, WorthT>(_description) {}
|
||||
|
||||
|
||||
|
|
@ -164,7 +171,7 @@ class eoPerf2WorthCached : public eoPerf2Worth<EOT, WorthT>
|
|||
indices[i] = i;
|
||||
}
|
||||
|
||||
std::sort(indices.begin(), indices.end(), eoPerf2Worth<EOT,WorthT>::compare_worth(value()));
|
||||
std::sort(indices.begin(), indices.end(), compare_worth(value()));
|
||||
|
||||
eoPop<EOT> tmp_pop;
|
||||
tmp_pop.resize(_pop.size());
|
||||
|
|
@ -216,22 +223,25 @@ class eoPerf2WorthCached : public eoPerf2Worth<EOT, WorthT>
|
|||
std::vector <typename EOT::Fitness> fitness_cache;
|
||||
};
|
||||
|
||||
/**
|
||||
A dummy perf2worth, just in case you need it
|
||||
*/
|
||||
|
||||
|
||||
/** A dummy perf2worth, just in case you need it */
|
||||
template <class EOT>
|
||||
class eoNoPerf2Worth : public eoPerf2Worth<EOT, typename EOT::Fitness>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoValueParam< EOT >::value;
|
||||
|
||||
// default behaviour, just copy fitnesses
|
||||
void operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
void operator()(const eoPop<EOT>& _pop) {
|
||||
unsigned i;
|
||||
value.resize(_pop.size());
|
||||
value().resize(_pop.size());
|
||||
for (i = 0; i < _pop.size(); ++i)
|
||||
value()[i]=_pop[i];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ protected :
|
|||
const eoPop<EOT>& src;
|
||||
|
||||
private:
|
||||
void get_next()
|
||||
{
|
||||
|
||||
void get_next() {
|
||||
if(current == dest.end())
|
||||
{ // get new individual from derived class select()
|
||||
dest.push_back(select());
|
||||
|
|
@ -143,8 +143,9 @@ private :
|
|||
};
|
||||
|
||||
|
||||
/** SeqPopulator: an eoPopulator that sequentially goes through the population
|
||||
is supposed to be used after a batch select of a whole bunch or genitors
|
||||
/** SeqPopulator: an eoPopulator that sequentially goes through the
|
||||
population is supposed to be used after a batch select of a whole
|
||||
bunch or genitors
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoSeqPopulator : public eoPopulator<EOT>
|
||||
|
|
@ -155,18 +156,20 @@ public :
|
|||
eoPopulator<EOT>(_pop, _dest), current(0) {}
|
||||
|
||||
/** the select method simply returns next individual in the src pop */
|
||||
const EOT& select(void)
|
||||
{
|
||||
if (current >= src.size())
|
||||
{
|
||||
const EOT& select(void) {
|
||||
if(current >= eoPopulator< EOT >::src.size()) {
|
||||
throw OutOfIndividuals();
|
||||
}
|
||||
|
||||
const EOT& res = src[current++];
|
||||
const EOT& res = eoPopulator< EOT >::src[current++];
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
struct OutOfIndividuals {};
|
||||
|
||||
unsigned current;
|
||||
};
|
||||
|
||||
|
|
@ -178,19 +181,21 @@ template <class EOT>
|
|||
class eoSelectivePopulator : public eoPopulator<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
using eoPopulator< EOT >::src;
|
||||
|
||||
eoSelectivePopulator(const eoPop<EOT>& _pop, eoPop<EOT>& _dest, eoSelectOne<EOT>& _sel)
|
||||
: eoPopulator<EOT>(_pop, _dest), sel(_sel)
|
||||
{
|
||||
sel.setup(_pop);
|
||||
}
|
||||
{ sel.setup(_pop); };
|
||||
|
||||
/** the select method actually selects one guy from the src pop */
|
||||
const EOT& select()
|
||||
{
|
||||
const EOT& select() {
|
||||
return sel(src);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
eoSelectOne<EOT>& sel;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ template <class EOT>
|
|||
class eoRanking : public eoPerf2Worth<EOT> // false: do not cache fitness
|
||||
{
|
||||
public:
|
||||
|
||||
using eoRanking< EOT >::value;
|
||||
|
||||
/* Ctor:
|
||||
@param _p selective pressure (in (1,2]
|
||||
@param _e exponent (1 == linear)
|
||||
|
|
|
|||
|
|
@ -88,6 +88,12 @@ template <class ScalarType, class Compare, class FitnessTraits >
|
|||
class eoScalarFitnessAssembled : public std::vector<ScalarType> {
|
||||
|
||||
public:
|
||||
|
||||
using std::vector< ScalarType >::empty;
|
||||
using std::vector< ScalarType >::front;
|
||||
using std::vector< ScalarType >::size;
|
||||
|
||||
|
||||
typedef typename std::vector<ScalarType> baseVector;
|
||||
typedef typename baseVector::size_type size_type;
|
||||
|
||||
|
|
@ -134,7 +140,6 @@ public:
|
|||
push_back( v );
|
||||
else
|
||||
front() = v;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,40 +51,36 @@ template <class EOT, class WorthType = double>
|
|||
class eoSelectFromWorth : public eoSelectOne<EOT>
|
||||
{
|
||||
public:
|
||||
/* Default ctor from an eoPerf2Worth object
|
||||
*/
|
||||
eoSelectFromWorth(eoPerf2Worth<EOT, WorthType> & _perf2Worth) :
|
||||
perf2Worth(_perf2Worth) {}
|
||||
|
||||
/* Default ctor from an eoPerf2Worth object */
|
||||
eoSelectFromWorth(eoPerf2Worth<EOT, WorthType>& _perf2Worth)
|
||||
: perf2Worth(_perf2Worth)
|
||||
{}
|
||||
|
||||
/* setup the worthes */
|
||||
virtual void setup(const eoPop<EOT>& _pop)
|
||||
{
|
||||
perf2Worth(_pop);
|
||||
|
||||
virtual void setup(const eoPop<EOT>& pop) {
|
||||
perf2Worth(pop);
|
||||
#ifndef NDEBUG
|
||||
fitness.resize(_pop.size());
|
||||
for (unsigned i = 0; i < _pop.size(); ++i)
|
||||
{
|
||||
fitness[i] = _pop[i].fitness();
|
||||
fitness.resize(pop.size());
|
||||
for (unsigned i = 0; i < pop.size(); ++i) {
|
||||
fitness[i] = pop[i].fitness();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
eoPerf2Worth<EOT, WorthType>& perf2Worth;
|
||||
|
||||
#ifndef NDEBUG
|
||||
std::vector<typename EOT::Fitness> fitness;
|
||||
void check_sync(unsigned index, const EOT& _eo)
|
||||
{
|
||||
if (fitness[index] != _eo.fitness())
|
||||
{
|
||||
void check_sync(unsigned index, const EOT& _eo) {
|
||||
if (fitness[index] != _eo.fitness()) {
|
||||
throw std::runtime_error("eoSelectFromWorth: fitnesses are not in sync");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -95,35 +91,33 @@ template <class EOT, class WorthT = double>
|
|||
class eoDetTournamentWorthSelect : public eoSelectFromWorth<EOT, WorthT>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoSelectFromWorth<EOT, WorthT>::perf2Worth;
|
||||
|
||||
typedef typename std::vector<WorthT>::iterator worthIterator;
|
||||
|
||||
/* Default ctor from an eoPerf2Worth object + tournament size
|
||||
*/
|
||||
eoDetTournamentWorthSelect(eoPerf2Worth<EOT, WorthT> &_perf2Worth,
|
||||
unsigned _tSize) :
|
||||
eoSelectFromWorth<EOT, WorthT>(_perf2Worth), tSize(_tSize) {}
|
||||
|
||||
/* Perform deterministic tournament on worthes
|
||||
by calling the appropriate fn
|
||||
see selectors.h
|
||||
*/
|
||||
virtual const EOT& operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
worthIterator it = deterministic_tournament(
|
||||
perf2Worth.value().begin(),
|
||||
perf2Worth.value().end(), tSize);
|
||||
/* Default ctor from an eoPerf2Worth object + tournament size */
|
||||
eoDetTournamentWorthSelect(eoPerf2Worth<EOT, WorthT>& perf2Worth,
|
||||
unsigned _tSize)
|
||||
: eoSelectFromWorth<EOT, WorthT>(perf2Worth), tSize(_tSize) {}
|
||||
|
||||
/* Perform deterministic tournament on worthes by calling the
|
||||
appropriate fn see selectors.h */
|
||||
virtual const EOT& operator()(const eoPop<EOT>& pop) {
|
||||
worthIterator it = deterministic_tournament(perf2Worth.value().begin(),
|
||||
perf2Worth.value().end(),
|
||||
tSize);
|
||||
unsigned index = it - perf2Worth.value().begin();
|
||||
|
||||
#ifndef NDEBUG
|
||||
// check whether the stuff is still in sync
|
||||
check_sync(index, _pop[index]);
|
||||
check_sync(index, pop[index]);
|
||||
#endif
|
||||
|
||||
return _pop[index];
|
||||
return pop[index];
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
unsigned tSize;
|
||||
};
|
||||
|
||||
|
|
@ -134,22 +128,23 @@ template <class EOT, class WorthT = double>
|
|||
class eoStochTournamentWorthSelect : public eoSelectFromWorth<EOT, WorthT>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoSelectFromWorth<EOT, WorthT>::perf2Worth;
|
||||
|
||||
typedef typename std::vector<WorthT>::iterator worthIterator;
|
||||
|
||||
/* Default ctor from an eoPerf2Worth object + tournament rate
|
||||
*/
|
||||
eoStochTournamentWorthSelect(eoPerf2Worth<EOT, WorthT> &_perf2Worth,
|
||||
double _tRate) :
|
||||
eoSelectFromWorth<EOT, WorthT>(_perf2Worth), tRate(_tRate) {}
|
||||
/* Default ctor from an eoPerf2Worth object + tournament rate */
|
||||
eoStochTournamentWorthSelect(eoPerf2Worth<EOT, WorthT> &_perf2Worth, double _tRate)
|
||||
: eoSelectFromWorth<EOT, WorthT>(_perf2Worth), tRate(_tRate)
|
||||
{}
|
||||
|
||||
/* Perform stochastic tournament on worthes
|
||||
by calling the appropriate fn in selectors.h
|
||||
*/
|
||||
virtual const EOT& operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
worthIterator it = stochastic_tournament(
|
||||
perf2Worth.value().begin(),
|
||||
perf2Worth.value().end(), tRate);
|
||||
virtual const EOT& operator()(const eoPop<EOT>& _pop) {
|
||||
worthIterator it = stochastic_tournament(perf2Worth.value().begin(),
|
||||
perf2Worth.value().end(),
|
||||
tRate);
|
||||
|
||||
unsigned index = it - perf2Worth.value().begin();
|
||||
|
||||
|
|
@ -172,12 +167,16 @@ template <class EOT, class WorthT = double>
|
|||
class eoRouletteWorthSelect : public eoSelectFromWorth<EOT, WorthT>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoSelectFromWorth<EOT, WorthT>::perf2Worth;
|
||||
|
||||
typedef typename std::vector<WorthT>::iterator worthIterator;
|
||||
|
||||
/* Default ctor from an eoPerf2Worth object
|
||||
*/
|
||||
eoRouletteWorthSelect(eoPerf2Worth<EOT, WorthT> &_perf2Worth) :
|
||||
eoSelectFromWorth<EOT, WorthT>(_perf2Worth) {}
|
||||
|
||||
/* Default ctor from an eoPerf2Worth object */
|
||||
eoRouletteWorthSelect(eoPerf2Worth<EOT, WorthT> &_perf2Worth)
|
||||
: eoSelectFromWorth<EOT, WorthT>(_perf2Worth)
|
||||
{}
|
||||
|
||||
/* We have to override the default behavior to compute the total
|
||||
* only once!
|
||||
|
|
@ -195,16 +194,14 @@ public:
|
|||
by calling the appropriate fn
|
||||
see selectors.h
|
||||
*/
|
||||
virtual const EOT& operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
virtual const EOT& operator()(const eoPop<EOT>& _pop) {
|
||||
// cout << "On affiche les worths\n";
|
||||
// for (unsigned i=0;
|
||||
// i<perf2Worth.value().size();
|
||||
// i++)
|
||||
// cout << perf2Worth.value().operator[](i) << "\n";
|
||||
// cout << endl;
|
||||
worthIterator it = roulette_wheel(
|
||||
perf2Worth.value().begin(),
|
||||
worthIterator it = roulette_wheel(perf2Worth.value().begin(),
|
||||
perf2Worth.value().end(),
|
||||
total);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,10 @@ template <class EOT>
|
|||
class eoSharing : public eoPerf2Worth<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoSharing< EOT >::value;
|
||||
|
||||
|
||||
/* Ctor requires a distance - cannot have a default distance! */
|
||||
eoSharing(double _nicheSize, eoDistance<EOT> & _dist) : eoPerf2Worth<EOT>("Sharing"),
|
||||
nicheSize(_nicheSize),
|
||||
|
|
|
|||
|
|
@ -64,22 +64,25 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
an instance (theonly one as of today, Dec. 20, 2000) of an eoSurviveAndDie,
|
||||
that does everything deterministically
|
||||
/** An instance (theonly one as of today, Dec. 20, 2000) of an
|
||||
eoSurviveAndDie, that does everything deterministically
|
||||
|
||||
used in eoDeterministicSaDReplacement
|
||||
Used in eoDeterministicSaDReplacement.
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
class eoDeterministicSurviveAndDie : public eoSurviveAndDie<EOT>
|
||||
{
|
||||
public:
|
||||
eoDeterministicSurviveAndDie(double _survive, double _die,
|
||||
bool _interpret_as_rate = true):
|
||||
eoSurviveAndDie<EOT>(_survive, _die, _interpret_as_rate)
|
||||
|
||||
using eoSurviveAndDie< EOT >::howmanyDie;
|
||||
using eoSurviveAndDie< EOT >::howmanySurvive;
|
||||
|
||||
/** constructor */
|
||||
eoDeterministicSurviveAndDie(double _survive, double _die, bool _interpret_as_rate = true)
|
||||
: eoSurviveAndDie< EOT >(_survive, _die, _interpret_as_rate)
|
||||
{}
|
||||
|
||||
|
||||
void operator()(eoPop<EOT> & _pop, eoPop<EOT> & _luckyGuys)
|
||||
{
|
||||
unsigned pSize = _pop.size();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
Marc.Schoenauer@polytechnique.fr
|
||||
mak@dhi.dk
|
||||
|
||||
CVS Info: $Date: 2003-03-18 16:57:17 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVector.h,v 1.15 2003-03-18 16:57:17 maartenkeijzer Exp $ $Author: maartenkeijzer $
|
||||
CVS Info: $Date: 2004-12-23 15:29:06 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVector.h,v 1.16 2004-12-23 15:29:06 kuepper Exp $ $Author: kuepper $
|
||||
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -47,11 +47,23 @@ class eoVector : public EO<FitT>, public std::vector<GeneType>
|
|||
{
|
||||
public:
|
||||
|
||||
using EO<FitT>::invalidate;
|
||||
using std::vector<GeneType>::operator[];
|
||||
using std::vector<GeneType>::begin;
|
||||
using std::vector<GeneType>::end;
|
||||
using std::vector<GeneType>::resize;
|
||||
using std::vector<GeneType>::size;
|
||||
|
||||
typedef GeneType AtomType;
|
||||
typedef std::vector<GeneType> ContainerType;
|
||||
|
||||
/** default constructor
|
||||
|
||||
eoVector(unsigned size = 0, GeneType value = GeneType()) : EO<FitT>(), std::vector<GeneType>(size, value)
|
||||
@param size Length of vector (default is 0)
|
||||
@param value Initial value of all elements (default is default value of type GeneType)
|
||||
*/
|
||||
eoVector(unsigned size = 0, GeneType value = GeneType())
|
||||
: EO<FitT>(), std::vector<GeneType>(size, value)
|
||||
{}
|
||||
|
||||
/// copy ctor abstracting from the FitT
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ template <class Fit>
|
|||
class eoEsFull : public eoVector<Fit, double>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoEsFull< Fit >::size;
|
||||
|
||||
|
||||
typedef double Type;
|
||||
|
||||
eoEsFull(void) : eoVector<Fit, double>() {}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ class eoEsStdev : public eoVector<Fit, double>
|
|||
{
|
||||
public:
|
||||
|
||||
using eoEsStdev< Fit >::size;
|
||||
|
||||
typedef double Type;
|
||||
|
||||
eoEsStdev(void) : eoVector<Fit, double>() {}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ private:
|
|||
* but this sometimes takes a long time!!!
|
||||
*/
|
||||
|
||||
template<class EOT> class eoNormalMutation: public eoMonOp<EOT>
|
||||
template<class EOT> class eoNormalMutation
|
||||
: public eoMonOp<EOT>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -177,6 +178,9 @@ template<class EOT> class eoOneFifthMutation :
|
|||
public eoNormalMutation<EOT>, public eoUpdatable
|
||||
{
|
||||
public:
|
||||
|
||||
using eoNormalMutation< EOT >::Sigma;
|
||||
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@ template <class FitT> class eoBit: public eoVector<FitT, bool>
|
|||
{
|
||||
public:
|
||||
|
||||
using eoVector< FitT, bool >::begin;
|
||||
using eoVector< FitT, bool >::end;
|
||||
using eoVector< FitT, bool >::size;
|
||||
|
||||
/**
|
||||
* (Default) Constructor.
|
||||
* @param size Size of the binary std::string.
|
||||
|
|
@ -104,3 +108,9 @@ template <class FitT> class eoBit: public eoVector<FitT, bool>
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif //eoBit_h
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// c-file-style: "Stroustrup"
|
||||
// End:
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue