move paradiseo/eo to deprecated/ before merge with eodev

This commit is contained in:
Johann Dreo 2012-10-05 15:12:12 +02:00
commit 0c5120f675
717 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,35 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
######################################################################################
### 2) Define the ga target
######################################################################################
SET(GA_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
SET(LIBRARY_OUTPUT_PATH ${GA_LIB_OUTPUT_PATH})
SET(GA_SOURCES
make_algo_scalar_ga.cpp
make_checkpoint_ga.cpp
make_continue_ga.cpp
make_genotype_ga.cpp
make_op_ga.cpp
make_pop_ga.cpp
make_run_ga.cpp
)
ADD_LIBRARY(ga STATIC ${GA_SOURCES})
INSTALL(TARGETS ga ARCHIVE DESTINATION local/${LIB} COMPONENT libraries)
######################################################################################
### 3) Optionnal
######################################################################################
SET(GA_VERSION ${GLOBAL_VERSION})
SET_TARGET_PROPERTIES(ga PROPERTIES VERSION "${GA_VERSION}")
######################################################################################

View file

@ -0,0 +1,11 @@
2007-08-21 Jochen Küpper <jochen@fhi-berlin.mpg.de>
* eoBitOp.h (eoNPtsBitXover::operator()): Make sure bit is within
allocated length of vector points: [0, max_size).
* Local Variables:
* coding: iso-8859-1
* mode: flyspell
* fill-column: 80
* End:

View file

@ -0,0 +1,20 @@
This directory contains:
- some standard EO source files, named eoXXXXX, that define objects
for the eoBit<FitT> representation (bitstrings).
- some make_XXX.cpp files that are instanciations for EO bitstrings
(eoBit<double> AND eoBit<eoMinimizingFitness>) of the tempatized code
that is defined in the EO src/do dir.
This MK's trick allows to actually compile all these bits in a library
(eolibga.a) and to only recompile the bits you need for your own
(bitstring!) application.
@see src/do/make_XXX.h files, and test/t-eoGA.cpp for an example use.
Note:
Also are *defined* here two representation dependent make_XXX.h files
(together with their instanciations in make_XXX.cpp), namely the ones
that constructs the EOType initializer (make_genotype.h) and the one
that buils up the operators (make_op.h).
MS, April 23, 2001CVS

View file

@ -0,0 +1,128 @@
/*
eoBit.h
(c) GeNeura Team 1998, Marc Schoenauer 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
*/
/* MS, Nov. 23, 2000
Added the calls to base class I/O routines that print the fitness
Left printing/reading of the size of the bitstring,
for backward compatibility, and as it is a general practice in EO
MS, Feb. 7, 2001
replaced all ...Bin... names with ...Bit... names - for bitstring
as it was ambiguous with bin...ary things
*/
#ifndef eoBit_h
#define eoBit_h
//-----------------------------------------------------------------------------
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include "eoVector.h"
/** @defgroup bitstring Bit strings
Various functions for a bitstring representation.
Example of a complete test program that use various bitstrings operators:
@include t-eobin.cpp
@ingroup Representations
*/
/** Implementation of bitstring chromosome.
@class eoBit eoBit.h ga/eoBit.h
@ingroup bitstring
Based on STL's std::vector<bool> specialization.
*/
template <class FitT> class eoBit: public eoVector<FitT, bool>
{
public:
using eoVector< FitT, bool >::begin;
using eoVector< FitT, bool >::end;
using eoVector< FitT, bool >::resize;
using eoVector< FitT, bool >::size;
/**
* (Default) Constructor.
* @param size Size of the binary std::string.
* @param value Default value.
*/
eoBit(unsigned size = 0, bool value = false):
eoVector<FitT, bool>(size, value) {}
/// My class name.
virtual std::string className() const
{
return "eoBit";
}
/**
* To print me on a stream.
* @param os The std::ostream.
*/
virtual void printOn(std::ostream& os) const
{
EO<FitT>::printOn(os);
os << ' ';
os << size() << ' ';
std::copy(begin(), end(), std::ostream_iterator<bool>(os));
}
/**
* To read me from a stream.
* @param is The std::istream.
*/
virtual void readFrom(std::istream& is)
{
EO<FitT>::readFrom(is);
unsigned s;
is >> s;
std::string bits;
is >> bits;
if (is)
{
resize(bits.size());
std::transform(bits.begin(), bits.end(), begin(),
std::bind2nd(std::equal_to<char>(), '1'));
}
}
};
//-----------------------------------------------------------------------------
#endif //eoBit_h
// Local Variables:
// coding: iso-8859-1
// mode: C++
// c-file-offsets: ((c . 0))
// c-file-style: "Stroustrup"
// fill-column: 80
// End:

View file

@ -0,0 +1,496 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoBitOp.h
// (c) GeNeura Team, 2000 - EEAAX 2000 - Maarten Keijzer 2000
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mak@dhi.dk
CVS Info: $Date: 2007-08-21 14:52:50 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/ga/eoBitOp.h,v 1.18 2007-08-21 14:52:50 kuepper Exp $ $Author: kuepper $
*/
//-----------------------------------------------------------------------------
#ifndef eoBitOp_h
#define eoBitOp_h
//-----------------------------------------------------------------------------
#include <algorithm> // swap_ranges
#include <utils/eoRNG.h>
#include <eoInit.h> // eoMonOp
#include <ga/eoBit.h>
/** eoOneBitFlip --> changes 1 bit
\class eoOneBitFlip eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
@ingroup Variators
*/
template<class Chrom> class eoOneBitFlip: public eoMonOp<Chrom>
{
public:
/// The class name.
virtual std::string className() const { return "eoOneBitFlip"; }
/**
* Change one bit.
* @param chrom The cromosome which one bit is going to be changed.
*/
bool operator()(Chrom& chrom)
{
unsigned i = eo::rng.random(chrom.size());
chrom[i] = !chrom[i];
return true;
}
};
/** eoDetBitFlip --> changes exactly k bits
\class eoDetBitFlip eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
*/
template<class Chrom> class eoDetBitFlip: public eoMonOp<Chrom>
{
public:
/**
* (Default) Constructor.
* @param _num_bit The number of bits to change
* default is one - equivalent to eoOneBitFlip then
*/
eoDetBitFlip(const unsigned& _num_bit = 1): num_bit(_num_bit) {}
/// The class name.
virtual std::string className() const { return "eoDetBitFlip"; }
/**
* Change num_bit bits.
* @param chrom The cromosome which one bit is going to be changed.
*/
bool operator()(Chrom& chrom)
{
// for duplicate checking see eoDetSingleBitFlip
for (unsigned k=0; k<num_bit; k++)
{
unsigned i = eo::rng.random(chrom.size());
chrom[i] = !chrom[i];
}
return true;
}
private:
unsigned num_bit;
};
/** eoDetSingleBitFlip --> changes exactly k bits with checking for duplicate
\class eoDetSingleBitFlip eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
*/
template<class Chrom> class eoDetSingleBitFlip: public eoMonOp<Chrom>
{
public:
/**
* (Default) Constructor.
* @param _num_bit The number of bits to change
* default is one - equivalent to eoOneBitFlip then
*/
eoDetSingleBitFlip(const unsigned& _num_bit = 1): num_bit(_num_bit) {}
/// The class name.
virtual std::string className() const { return "eoDetSingleBitFlip"; }
/**
* Change num_bit bits.
* @param chrom The cromosome which one bit is going to be changed.
*/
bool operator()(Chrom& chrom)
{
std::vector< unsigned > selected;
// check for duplicate
for (unsigned k=0; k<num_bit; k++)
{
unsigned temp;
do
{
temp = eo::rng.random( chrom.size() );
}
while ( find( selected.begin(), selected.end(), temp ) != selected.end() );
selected.push_back(temp);
}
for ( size_t i = 0; i < selected.size(); ++i )
{
chrom[i] = !chrom[i];
}
return true;
}
private:
unsigned num_bit;
};
/** eoBitMutation --> classical mutation
\class eoBitMutation eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
*/
template<class Chrom> class eoBitMutation: public eoMonOp<Chrom>
{
public:
/**
* (Default) Constructor.
* @param _rate Rate of mutation.
* @param _normalize use rate/chrom.size if true
*/
eoBitMutation(const double& _rate = 0.01, bool _normalize=false):
rate(_rate), normalize(_normalize) {}
/// The class name.
virtual std::string className() const { return "eoBitMutation"; }
/**
* Mutate a chromosome.
* @param chrom The chromosome to be mutated.
*/
bool operator()(Chrom& chrom)
{
double actualRate = (normalize ? rate/chrom.size() : rate);
bool changed_something = false;
for (unsigned i = 0; i < chrom.size(); i++)
if (eo::rng.flip(actualRate))
{
chrom[i] = !chrom[i];
changed_something = true;
}
return changed_something;
}
private:
double rate;
bool normalize; // divide rate by chromSize
};
/** eoBitInversion: inverts the bits of the chromosome between an interval
\class eoBitInversion eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
*/
template<class Chrom> class eoBitInversion: public eoMonOp<Chrom>
{
public:
/// The class name.
virtual std::string className() const { return "eoBitInversion"; }
/**
* Inverts a range of bits in a binary chromosome.
* @param chrom The chromosome whos bits are going to be inverted (a range).
*/
bool operator()(Chrom& chrom)
{
unsigned u1 = eo::rng.random(chrom.size() + 1) , u2;
do u2 = eo::rng.random(chrom.size() + 1); while (u1 == u2);
unsigned r1 = std::min(u1, u2), r2 = std::max(u1, u2);
std::reverse(chrom.begin() + r1, chrom.begin() + r2);
return true;
}
};
/** eoBitNext --> next value when bitstring considered as binary value
\class eoBitNext eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
*/
template<class Chrom> class eoBitNext: public eoMonOp<Chrom>
{
public:
/// The class name.
virtual std::string className() const { return "eoBitNext"; }
/**
* Change the bit std::string x to be x+1.
* @param chrom The chromosome to be added one.
*/
bool operator()(Chrom& chrom)
{
for (int i = chrom.size() - 1; i >= 0; i--)
if (chrom[i])
{
chrom[i] = 0;
continue;
}
else
{
chrom[i] = 1;
break;
}
return true;
}
};
/** eoBitPrev --> previous value when bitstring treated as binary value
\class eoBitPrev eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
*/
template<class Chrom> class eoBitPrev: public eoMonOp<Chrom>
{
public:
/// The class name.
virtual std::string className() const { return "eoBitPrev"; }
/**
* Change the bit std::string x to be x-1.
* @param chrom The chromosome to be substracted one.
*/
bool operator()(Chrom& chrom)
{
for (int i = chrom.size() - 1; i >= 0; i--)
if (chrom[i])
{
chrom[i] = 0;
break;
}
else
{
chrom[i] = 1;
continue;
}
return true;
}
};
/** eo1PtBitXover --> classic 1-point crossover
\class eo1PtBitCrossover eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
*/
template<class Chrom> class eo1PtBitXover: public eoQuadOp<Chrom>
{
public:
/// The class name.
virtual std::string className() const { return "eo1PtBitXover"; }
/**
* 1-point crossover for binary chromosomes.
* @param chrom1 The first chromosome.
* @param chrom2 The first chromosome.
*/
bool operator()(Chrom& chrom1, Chrom& chrom2)
{
unsigned site = eo::rng.random(std::min(chrom1.size(), chrom2.size()));
if (!std::equal(chrom1.begin(), chrom1.begin()+site, chrom2.begin()))
{
std::swap_ranges(chrom1.begin(), chrom1.begin() + site, chrom2.begin());
return true;
}
return false;
}
};
/** eoUBitXover --> classic Uniform crossover
\class eoUBitXover eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
*/
template<class Chrom> class eoUBitXover: public eoQuadOp<Chrom>
{
public:
/// (Default) Constructor.
eoUBitXover(const float& _preference = 0.5): preference(_preference)
{
if ( (_preference <= 0.0) || (_preference >= 1.0) )
std::runtime_error("UxOver --> invalid preference");
}
/// The class name.
virtual std::string className() const { return "eoUBitXover"; }
/**
* Uniform crossover for binary chromosomes.
* @param chrom1 The first chromosome.
* @param chrom2 The first chromosome.
* std::runtime_error if sizes don't match
*/
bool operator()(Chrom& chrom1, Chrom& chrom2)
{
if ( chrom1.size() != chrom2.size())
std::runtime_error("UxOver --> chromosomes sizes don't match" );
bool changed = false;
for (unsigned int i=0; i<chrom1.size(); i++)
{
if (chrom1[i] != chrom2[i] && eo::rng.flip(preference))
{
bool tmp = chrom1[i];
chrom1[i]=chrom2[i];
chrom2[i] = tmp;
changed = true;
}
}
return changed;
}
private:
float preference;
};
/** eoNPtsBitXover --> n-point crossover
\class eoNPtsBitXover eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
*/
template<class Chrom> class eoNPtsBitXover : public eoQuadOp<Chrom>
{
public:
/** (Default) Constructor. */
eoNPtsBitXover(const unsigned& _num_points = 2) : num_points(_num_points)
{
if (num_points < 1)
std::runtime_error("NxOver --> invalid number of points");
}
/** The class name */
virtual std::string className() const { return "eoNPtsBitXover"; }
/** n-point crossover for binary chromosomes.
@param chrom1 The first chromosome.
@param chrom2 The first chromosome.
*/
bool operator()(Chrom& chrom1, Chrom& chrom2) {
unsigned max_size(std::min(chrom1.size(), chrom2.size()));
unsigned max_points(std::min(max_size - 1, num_points));
std::vector<bool> points(max_size, false);
// select ranges of bits to swap
do {
unsigned bit(eo::rng.random(max_size));
if(points[bit])
continue;
else {
points[bit] = true;
--max_points;
}
} while(max_points);
// swap bits between chromosomes
bool change(false);
for (unsigned bit = 1; bit < points.size(); bit++) {
if (points[bit])
change = !change;
if (change) {
typename Chrom::AtomType tmp = chrom1[bit];
chrom1[bit] = chrom2[bit];
chrom2[bit] = tmp;
}
}
return true;
}
private:
/** @todo Document this data member */
unsigned num_points;
};
/** eoBitGxOver --> Npts crossover when bistd::string considered
as a std::string of binary-encoded genes (exchanges genes)
Is anybody still using it apart from historians ??? :-)
\class eoBitGxOver eoBitOp.h ga/eoBitOp.h
\ingroup bitstring
*/
template<class Chrom> class eoBitGxOver: public eoQuadOp<Chrom>
{
public:
/// Constructor.
eoBitGxOver(const unsigned _gene_size, const unsigned _num_points = 2):
gene_size(_gene_size), num_points(_num_points)
{
if (gene_size < 1)
std::runtime_error("GxOver --> invalid gene size");
if (num_points < 1)
std::runtime_error("GxOver --> invalid number of points");
}
/// The class name
virtual std::string className() const { return "eoBitGxOver"; }
/**
* Gene crossover for binary chromosomes.
* @param chrom1 The first chromosome.
* @param chrom2 The first chromosome.
*/
bool operator()(Chrom& chrom1, Chrom& chrom2)
{
unsigned max_genes = std::min(chrom1.size(), chrom2.size()) / gene_size;
unsigned cut_genes = std::min(max_genes, num_points);
std::vector<bool> points(max_genes, false);
// selects genes to swap
do {
unsigned bit = eo::rng.random(max_genes);
if (points[bit])
continue;
else
{
points[bit] = true;
cut_genes--;
}
} while (cut_genes);
// swaps genes
for (unsigned i = 0; i < points.size(); i++)
if (points[i])
std::swap_ranges(chrom1.begin() + i * gene_size,
chrom1.begin() + i * gene_size + gene_size,
chrom2.begin() + i * gene_size);
return true;
}
private:
unsigned gene_size;
unsigned num_points;
};
//-----------------------------------------------------------------------------
//@}
#endif

View file

@ -0,0 +1,172 @@
// eoBitOpFactory.h
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoOpFactory.h
// (c) GeNeura Team, 1998
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
*/
//-----------------------------------------------------------------------------
#ifndef _EOBITOPFACTORY_H
#define _EOBITOPFACTORY_H
#include <eoFactory.h>
#include <ga/eoBitOp.h>
//-----------------------------------------------------------------------------
/** EO Factory. An instance of the factory class to create operators that act
on bitstring chromosomes. Only those chromosomes can instantiate the operators
that are created here
@see eoSelect
@ingroup Variators
*/
template< class EOT>
class eoBitOpFactory: public eoFactory<EOT>
{
public:
/// @name ctors and dtors
//{@
/// constructor
eoBitOpFactory( ) {};
/// destructor
virtual ~eoBitOpFactory() {};
//@}
/** Another factory method: creates an object from an std::istream, reading from
it whatever is needed to create the object. Usually, the format for the std::istream will be\\
objectType parameter1 parameter2 ... parametern\\
If there are problems, an std::exception is raised; it should be caught at the
upper level, because it might be something for that level\\
At the same time, it catches std::exceptions thrown at a lower level, which will
indicate that whatever is in the stream is for this method to process
@param _is an stream from where a single line will be read
@throw runtime_std::exception if the object type is not known
*/
virtual eoOp<EOT>* make(std::istream& _is)
{
eoOp<EOT> * opPtr = NULL;
try {
opPtr = eoFactory<EOT>::make( _is );
} catch ( const std::string& objectTypeStr ) {
if ( objectTypeStr == "eoBinBitFlip" ) {
opPtr = new eoOneBitFlip<EOT>( );
}
// handles old operator names as well as new ones
if ( objectTypeStr == "eoOneBitFlip" ) {
opPtr = new eoOneBitFlip<EOT>( );
}
// Standard BitFilp Mutation
if ( objectTypeStr == "eoBinMutation" ) {
float rate;
_is >> rate;
opPtr = new eoBitMutation<EOT>( rate );
}
if ( objectTypeStr == "eoBitMutation" ) {
float rate;
_is >> rate;
opPtr = new eoBitMutation<EOT>( rate );
}
// Bit inversion
if ( objectTypeStr == "eoBinInversion" ) {
opPtr = new eoBitInversion<EOT>( );
}
if ( objectTypeStr == "eoBitInversion" ) {
opPtr = new eoBitInversion<EOT>( );
}
// Next binary value
if ( objectTypeStr == "eoBinNext" ) {
opPtr = new eoBitNext<EOT>( );
}
if ( objectTypeStr == "eoBitNext" ) {
opPtr = new eoBitNext<EOT>( );
}
// Previous binary value
if ( objectTypeStr == "eoBinPrev" ) {
opPtr = new eoBitPrev<EOT>( );
}
if ( objectTypeStr == "eoBitPrev" ) {
opPtr = new eoBitPrev<EOT>( );
}
// 1 point Xover
if ( objectTypeStr == "eoBinCrossover" ) {
opPtr = new eo1PtBitXover<EOT>( );
}
if ( objectTypeStr == "eo1PtBitXover" ) {
opPtr = new eo1PtBitXover<EOT>( );
}
// Npts Xover
if ( objectTypeStr == "eoBinNxOver" ) {
unsigned nPoints;
_is >> nPoints;
opPtr = new eoNPtsBitXover<EOT>( nPoints );
}
if ( objectTypeStr == "eoNPtsBitXover" ) {
unsigned nPoints;
_is >> nPoints;
opPtr = new eoNPtsBitXover<EOT>( nPoints );
}
// Gene Xover (obsolete)
if ( objectTypeStr == "eoBinGxOver" ) {
unsigned geneSize, nPoints;
_is >> geneSize >> nPoints;
opPtr = new eoBitGxOver<EOT>( geneSize, nPoints );
}
if ( objectTypeStr == "eoBitGxOver" ) {
unsigned geneSize, nPoints;
_is >> geneSize >> nPoints;
opPtr = new eoBitGxOver<EOT>( geneSize, nPoints );
}
// Uniform Xover
if ( objectTypeStr == "eoBinUxOver" ) {
float rate;
_is >> rate;
opPtr = new eoUBitXover<EOT>( rate );
}
if ( objectTypeStr == "eoUBitXover" ) {
float rate;
_is >> rate;
opPtr = new eoUBitXover<EOT>( rate );
}
// nothing read!
if ( !opPtr ) { // to be caught by the upper level
throw objectTypeStr;
}
}
return opPtr;
};
};
#endif

View file

@ -0,0 +1,49 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoBoolFlip.h
// (c) Marc Schoenauer, 2003
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: Marc.Schoenauer@inria.fr
*/
//-----------------------------------------------------------------------------
#ifndef _eoBoolFlip_h
#define _eoBoolFlip_h
#include <eoOp.h>
/** a simple boolean mutation - to be used in generic eoOp's
*
@ingroup bitstring
@ingroup Variators
*/
class eoBoolFlip : public eoMonOp<bool> {
public:
/** simply flips the boolean argument */
bool operator()(bool & _b)
{
_b = !_b;
return true;
}
/** inherited className() */
virtual string className() const {return "boolFlip";}
};
#endif

View file

@ -0,0 +1,119 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoPBILAdditive.h
// (c) Marc Schoenauer, Maarten Keijzer, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _eoPBILAdditive_H
#define _eoPBILAdditive_H
#include <eoDistribUpdater.h>
#include <ga/eoPBILDistrib.h>
/**
* Distribution Class for PBIL algorithm
* (Population-Based Incremental Learning, Baluja and Caruana 96)
*
* This class implements an extended update rule:
* in the original paper, the authors used
*
* p(i)(t+1) = (1-LR)*p(i)(t) + LR*best(i)
*
* here the same formula is applied, with some of the best individuals
* and for some of the worst individuals (with different learning rates)
*/
template <class EOT>
class eoPBILAdditive : public eoDistribUpdater<EOT>
{
public:
/** Ctor with parameters
* using the default values is equivalent to using eoPBILOrg
*/
eoPBILAdditive(double _LRBest, unsigned _nbBest = 1,
double _tolerance=0.0,
double _LRWorst = 0.0, unsigned _nbWorst = 0 ) :
maxBound(1.0-_tolerance), minBound(_tolerance),
LR(0.0), nbBest(_nbBest), nbWorst(_nbWorst)
{
if (nbBest+nbWorst == 0)
throw std::runtime_error("Must update either from best or from worst in eoPBILAdditive");
if (_nbBest)
{
lrb = _LRBest/_nbBest;
LR += _LRBest;
}
else
lrb=0.0; // just in case
if (_nbWorst)
{
lrw = _LRWorst/_nbWorst;
LR += _LRWorst;
}
else
lrw=0.0; // just in case
}
/** Update the distribution from the current population */
virtual void operator()(eoDistribution<EOT> & _distrib, eoPop<EOT>& _pop)
{
eoPBILDistrib<EOT>& distrib = dynamic_cast<eoPBILDistrib<EOT>&>(_distrib);
std::vector<double> & p = distrib.value();
unsigned i, popSize=_pop.size();
std::vector<const EOT*> result;
_pop.sort(result); // is it necessary to sort the whole population?
// but I'm soooooooo lazy !!!
for (unsigned g=0; g<distrib.size(); g++)
{
p[g] *= (1-LR); // relaxation
if (nbBest) // update from some of the best
for (i=0; i<nbBest; i++)
{
const EOT & best = (*result[i]);
if ( best[g] ) // if 1, increase proba
p[g] += lrb;
}
if (nbWorst)
for (i=popSize-1; i>=popSize-nbWorst; i--)
{
const EOT & best = (*result[i]);
if ( !best[g] ) // if 0, increase proba
p[g] += lrw;
}
// stay in [0,1] (possibly strictly due to tolerance)
p[g] = std::min(maxBound, p[g]);
p[g] = std::max(minBound, p[g]);
}
}
private:
double maxBound, minBound; // proba stay away from 0 and 1 by at least tolerance
double LR; // learning rate
unsigned nbBest; // number of Best individuals used for update
unsigned nbWorst; // number of Worse individuals used for update
double lrb, lrw; // "local" learning rates (see operator())
};
#endif

View file

@ -0,0 +1,100 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoPBILDistrib.h
// (c) Marc Schoenauer, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: Marc.Schoenauer@inria.fr
*/
//-----------------------------------------------------------------------------
#ifndef _eoPBILDistrib_H
#define _eoPBILDistrib_H
#include <eoDistribution.h>
/**
* Distribution Class for PBIL algorithm
* (Population-Based Incremental Learning, Baluja and Caruana 96)
*
* It encodes a univariate distribution on the space of bitstrings,
* i.e. one probability for each bit to be one
*
* It is an eoValueParam<std::vector<double> > :
* the std::vector<double> stores the probabilities that each bit is 1
*
* It is still pure virtual, as the update method needs to be specified
*/
template <class EOT>
class eoPBILDistrib : public eoDistribution<EOT>,
public eoValueParam<std::vector<double> >
{
public:
/** Ctor with size of genomes, and update parameters */
eoPBILDistrib(unsigned _genomeSize) :
eoDistribution<EOT>(),
eoValueParam<std::vector<double> >(std::vector<double>(_genomeSize, 0.5), "Distribution"),
genomeSize(_genomeSize)
{}
/** the randomizer of indis */
virtual void operator()(EOT & _eo)
{
_eo.resize(genomeSize); // just in case
for (unsigned i=0; i<genomeSize; i++)
_eo[i] = eo::rng.flip(value()[i]);
_eo.invalidate(); // DO NOT FORGET!!!
}
/** Accessor to the genome size */
unsigned Size() {return genomeSize;}
/** printing... */
virtual void printOn(std::ostream& os) const
{
os << value().size() << ' ';
for (unsigned i=0; i<value().size(); i++)
os << value()[i] << ' ';
}
/** reading...*/
virtual void readFrom(std::istream& is)
{
unsigned sz;
is >> sz;
value().resize(sz);
unsigned i;
for (i = 0; i < sz; ++i)
{
double atom;
is >> atom;
value()[i] = atom;
}
}
unsigned int size() {return genomeSize;}
virtual std::string className() const {return "eoPBILDistrib";};
private:
unsigned genomeSize; // size of indis
};
#endif

View file

@ -0,0 +1,78 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoPBILOrg.h
// (c) Marc Schoenauer, Maarten Keijzer, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _eoPBILOrg_H
#define _eoPBILOrg_H
#include <eoDistribUpdater.h>
#include <ga/eoPBILDistrib.h>
/**
* Distribution Class for PBIL algorithm
* (Population-Based Incremental Learning, Baluja and Caruana 95)
*
* This class implements the update rule from the original paper:
*
* p(i)(t+1) = (1-LR)*p(i)(t) + LR*best(i)
*/
template <class EOT>
class eoPBILOrg : public eoDistribUpdater<EOT>
{
public:
/** Ctor with size of genomes, and update parameters */
eoPBILOrg(double _LR, double _tolerance=0.0 ) :
LR(_LR), maxBound(1.0-_tolerance), minBound(_tolerance)
{}
/** Update the distribution from the current population */
virtual void operator()(eoDistribution<EOT> & _distrib, eoPop<EOT>& _pop)
{
const EOT & best = _pop.best_element();
eoPBILDistrib<EOT>& distrib = dynamic_cast<eoPBILDistrib<EOT>&>(_distrib);
std::vector<double> & p = distrib.value();
for (unsigned g=0; g<distrib.size(); g++)
{
// double & r = value()[g];
p[g] *= (1-LR);
if ( best[g] )
p[g] += LR;
// else nothing
// stay away from 0 and 1
p[g] = std::min(maxBound, p[g]);
p[g] = std::max(minBound, p[g]);
}
}
private:
double LR; // learning rate for best guys
double maxBound, minBound; // proba stay away from 0 and 1 by at least tolerance
};
#endif

View file

@ -0,0 +1,101 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_PBILdistrib.h
// (c) Marc Schoenauer, Maarten Keijzer, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _make_PBILdistrib_h
#define _make_PBILdistrib_h
#include <ctime> // for time(0) for random seeding
#include <ga/eoPBILOrg.h>
#include <utils/eoRNG.h>
#include <utils/eoParser.h>
#include <utils/eoState.h>
//////////////////////////DISTRIB CONSTRUCTION ///////////////////////////////
/**
* Templatized version of parser-based construct of the distribution
* for PBIL distribution evolution algorithm
*
* It must then be instantiated, and compiled on its own for a given EOType
* (see test/t-eoPBIL.cpp
*
* Last argument is template-disambiguating
*/
template <class EOT>
eoPBILDistrib<EOT> & do_make_PBILdistrib(eoParser & _parser, eoState& _state, EOT)
{
// First the random seed
eoValueParam<uint32_t>& seedParam = _parser.createParam(uint32_t(0), "seed", "Random number seed", 'S');
if (seedParam.value() == 0)
seedParam.value() = time(0);
// chromosome size:
unsigned theSize;
// but it might have been already read in the definition fo the performance
eoParam* ptParam = _parser.getParamWithLongName(std::string("chromSize"));
if (!ptParam) // not already defined: read it here
{
theSize = _parser.createParam(unsigned(10), "chromSize", "The length of the bitstrings", 'n',"Problem").value();
}
else // it was read before, get its value
{
eoValueParam<unsigned>* ptChromSize = dynamic_cast<eoValueParam<unsigned>*>(ptParam);
theSize = ptChromSize->value();
}
eoPBILDistrib<EOT> * ptDistrib = new eoPBILDistrib<EOT>(theSize);
_state.storeFunctor(ptDistrib);
// now the initialization: read a previously saved distribution, or random
eoValueParam<std::string>& loadNameParam = _parser.createParam(std::string(""), "Load","A save file to restart from",'L', "Persistence" );
if (loadNameParam.value() != "") // something to load
{
// create another state for reading
eoState inState; // a state for loading - WITHOUT the parser
// register the rng and the distribution in the state,
// so they can be loaded,
// and the present run will be the exact continuation of the saved run
// eventually with different parameters
inState.registerObject(*ptDistrib);
inState.registerObject(rng);
inState.load(loadNameParam.value()); // load the distrib and the rng
}
else // nothing loaded from a file
{
rng.reseed(seedParam.value());
}
// for future stateSave, register the algorithm into the state
_state.registerObject(_parser);
_state.registerObject(*ptDistrib);
_state.registerObject(rng);
return *ptDistrib;
}
#endif

View file

@ -0,0 +1,79 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_PBILupdate.h
// (c) Marc Schoenauer, Maarten Keijzer, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _make_PBILupdate_h
#define _make_PBILupdate_h
#include <ga/eoPBILOrg.h>
#include <utils/eoRNG.h>
#include <utils/eoParser.h>
#include <utils/eoState.h>
///////CONSTRUCTION of PBIL distribution updaters/////////////////
/**
* Templatized version of parser-based construct of the update rule for PBIL
* distributions (see eoPBILDistrib.h)
*
* It must then be instantiated, and compiled on its own for a given EOType
* (see test/t-eoPBIL.cpp)
*
* Last argument is template-disambiguating
*/
template <class EOT>
eoDistribUpdater<EOT> & do_make_PBILupdate(eoParser & _parser, eoState& _state, EOT)
{
// ast the moment, a single update rule is available
// but at some point we'll have to choose among different rules
std::string UType = _parser.createParam(std::string("PBIL"), "updateRule", "Type of update rule (only PBIL additive at the moment)", 'U', "Algorithm").value();
unsigned nbBest = _parser.createParam(unsigned(1), "nbBest", "Number of good guys to update from", 'B', "Algorithm").value();
double LRBest = _parser.createParam(0.1, "LRBest", "Learning Rate (from best guys)", 'L', "Algorithm").value();
unsigned nbWorst = _parser.createParam(unsigned(0), "nbWorst", "Number of bad guys to update from", 'W', "Algorithm").value();
double LRWorst = _parser.createParam(0.01, "LRWorst", "Learning Rate (from best guys)", 'L', "Algorithm").value();
double tolerance = _parser.createParam(0.0, "tolerance", "Keeping away from 0 and 1", 't', "Algorithm").value();
// a pointer to choose among several possible types
eoDistribUpdater<EOT> * ptUpdate;
if (UType == std::string("PBIL"))
{
if ( (nbWorst == 0) && (nbBest == 1) )
ptUpdate = new eoPBILOrg<EOT>(LRBest, tolerance);
else
ptUpdate = new eoPBILAdditive<EOT>(LRBest, nbBest, tolerance, LRWorst, nbWorst);
}
else
throw std::runtime_error("Only PBIL additive update rule available at the moment");
// done: don't forget to store the allocated pointers
_state.storeFunctor(ptUpdate);
return *ptUpdate;
}
#endif

View file

@ -0,0 +1,63 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_algo_scalar_ga.cpp
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifdef _MSC_VER
// to avoid long name warnings
#pragma warning(disable:4786)
#endif
/** This file contains all ***INSTANCIATED DEFINITIONS*** of pop. init.
* of the library for ***BISTRING*** evolution inside EO.
* It should be included in the file that calls any of the corresponding fns
* Compiling this file allows one to generate part of the library (i.e. object
* files that you just need to link with your own main and fitness code).
*
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
* in src/ga/ga.h
* while the TEMPLATIZED code is define in make_algo_scalar.h in the src/do dir
*
* Unlike most EO .h files, it does not (and should not) contain any code,
* just declarations
*/
// The templatized code
#include <do/make_algo_scalar.h>
// the instanciating EOType
#include <ga/eoBit.h>
/// The following function merely call the templatized do_* functions above
// Algo
///////
eoAlgo<eoBit<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _continue, eoGenOp<eoBit<double> >& _op, eoDistance<eoBit<double> >* _dist)
{
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op, _dist);
}
eoAlgo<eoBit<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _continue, eoGenOp<eoBit<eoMinimizingFitness> >& _op, eoDistance<eoBit<eoMinimizingFitness> >* _dist)
{
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op, _dist);
}

View file

@ -0,0 +1,62 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_checkpoint_ga.cpp
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifdef _MSC_VER
// to avoid long name warnings
#pragma warning(disable:4786)
#endif
/** This file contains all ***INSTANCIATED DEFINITIONS*** of operators
* of the library for ***BISTRING*** evolution inside EO.
* It should be included in the file that calls any of the corresponding fns
* Compiling this file allows one to generate part of the library (i.e. object
* files that you just need to link with your own main and fitness code).
*
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
* in make_checkpoint_ga.h
* while the TEMPLATIZED code is define in make_checkpoint.h in the do dir
*
* Unlike most EO .h files, it does not (and should not) contain any code,
* just declarations
*/
// The templatized code
#include <do/make_checkpoint.h>
// the instanciating EOType
#include <ga/eoBit.h>
/// The following function merely call the templatized do_* functions
// checkpoint
/////////////
eoCheckPoint<eoBit<double> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _continue)
{
return do_make_checkpoint(_parser, _state, _eval, _continue);
}
eoCheckPoint<eoBit<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _continue)
{
return do_make_checkpoint(_parser, _state, _eval, _continue);
}

View file

@ -0,0 +1,62 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_continue_ga.cpp
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifdef _MSC_VER
// to avoid long name warnings
#pragma warning(disable:4786)
#endif
/** This file contains all ***INSTANCIATED DEFINITIONS*** of operators
* of the library for ***BISTRING*** evolution inside EO.
* It should be included in the file that calls any of the corresponding fns
* Compiling this file allows one to generate part of the library (i.e. object
* files that you just need to link with your own main and fitness code).
*
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
* in ga.h
* while the TEMPLATIZED code is define in make_continue.h in the src/do dir
*
* Unlike most EO .h files, it does not (and should not) contain any code,
* just declarations
*/
// The templatized code
#include <do/make_continue.h>
// the instanciating EOType
#include <ga/eoBit.h>
/// The following function merely call the templatized do_* functions above
// continue
///////////
eoContinue<eoBit<double> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<double> > & _eval)
{
return do_make_continue(_parser, _state, _eval);
}
eoContinue<eoBit<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<eoMinimizingFitness> > & _eval)
{
return do_make_continue(_parser, _state, _eval);
}

View file

@ -0,0 +1,99 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// ga.h
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
/** This file contains all ***INSTANCIATED*** declarations of all components
* of the library for ***BISTRING*** evolution inside EO.
* It should be included in the file that calls any of the corresponding fns
*
* The corresponding ***INSTANCIATED*** definitions are contained in ga.cpp
* while the TEMPLATIZED code is define in the different makeXXX.h files
*
* Unlike most EO .h files, it does not (and should not) contain any code,
* just declarations
*/
#ifndef ga_h
#define ga_h
#include <eoAlgo.h>
#include <eoScalarFitness.h>
#include <utils/eoParser.h>
#include <eoEvalFuncCounter.h>
#include <utils/eoCheckPoint.h>
#include <eoGenOp.h>
#include <eoPop.h>
#include <utils/eoDistance.h>
#include <ga/eoBit.h>
//Representation dependent - rewrite everything anew for each representation
//////////////////////////
/** @addtogroup Builders
* @{
*/
// the genotypes
eoInit<eoBit<double> > & make_genotype(eoParser& _parser, eoState& _state, eoBit<double> _eo, float _bias=0.5);
eoInit<eoBit<eoMinimizingFitness> > & make_genotype(eoParser& _parser, eoState& _state, eoBit<eoMinimizingFitness> _eo, float _bias=0.5);
// the operators
eoGenOp<eoBit<double> >& make_op(eoParser& _parser, eoState& _state, eoInit<eoBit<double> >& _init);
eoGenOp<eoBit<eoMinimizingFitness> >& make_op(eoParser& _parser, eoState& _state, eoInit<eoBit<eoMinimizingFitness> >& _init);
//Representation INdependent
////////////////////////////
// if you use your own representation, simply change the types of templates
// init pop
eoPop<eoBit<double> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoBit<double> >&);
eoPop<eoBit<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoBit<eoMinimizingFitness> >&);
// the continue's
eoContinue<eoBit<double> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<double> > & _eval);
eoContinue<eoBit<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<eoMinimizingFitness> > & _eval);
// the checkpoint
eoCheckPoint<eoBit<double> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _continue);
eoCheckPoint<eoBit<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _continue);
// the algo
eoAlgo<eoBit<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _ccontinue, eoGenOp<eoBit<double> >& _op, eoDistance<eoBit<double> >* _dist = NULL);
eoAlgo<eoBit<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _ccontinue, eoGenOp<eoBit<eoMinimizingFitness> >& _op, eoDistance<eoBit<eoMinimizingFitness> >* _dist = NULL);
// run
void run_ea(eoAlgo<eoBit<double> >& _ga, eoPop<eoBit<double> >& _pop);
void run_ea(eoAlgo<eoBit<eoMinimizingFitness> >& _ga, eoPop<eoBit<eoMinimizingFitness> >& _pop);
// end of parameter input (+ .status + help)
// that one is not templatized
// Because of that, the source is in src/utils dir
void make_help(eoParser & _parser);
/** @} */
#endif

View file

@ -0,0 +1,55 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_genotype_ga.cpp
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifdef _MSC_VER
// to avoid long name warnings
#pragma warning(disable:4786)
#endif
/** This file contains all ***INSTANCIATED DEFINITIONS*** of operators
* of the library for ***BISTRING*** evolution inside EO.
* It should be included in the file that calls any of the corresponding fns
* Compiling this file allows one to generate part of the library (i.e. object
* files that you just need to link with your own main and fitness code).
*
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
* in ga.h in src/ga dir
* while the TEMPLATIZED code is define in make_genotype_ga.h
*/
// the templatized code
#include <ga/make_genotype_ga.h>
/// The following function merely call the templatized do_* functions above
eoInit<eoBit<double> > & make_genotype(eoParser& _parser, eoState& _state, eoBit<double> _eo, float _bias)
{
return do_make_genotype(_parser, _state, _eo, _bias);
}
eoInit<eoBit<eoMinimizingFitness> > & make_genotype(eoParser& _parser, eoState& _state, eoBit<eoMinimizingFitness> _eo, float _bias)
{
return do_make_genotype(_parser, _state, _eo, _bias);
}

View file

@ -0,0 +1,79 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_genotype.h
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _make_genotype_h
#define _make_genotype_h
#include <ga/eoBit.h>
#include <eoInit.h>
// also need the parser and param includes
#include <utils/eoParser.h>
#include <utils/eoState.h>
/////////////////// the bitstring ////////////////
/*
* This fuction does the initialization of what's needed for a particular
* genotype (here, bitstrings).
* It could be here tempatied only on the fitness, as it can be used to evolve
* bitstrings with any fitness.
* However, for consistency reasons, it was finally chosen, as in
* the rest of EO, to templatize by the full EOT, as this eventually
* allows to choose the type of genotype at run time (see in es dir)
*
* It is instanciated in ga/ga.cpp - and incorporated in the ga/libga.a
*
* It returns an eoInit<eoBit<FitT> > tha can later be used to initialize
* the population (see make_pop.h).
*
* It uses a parser (to get user parameters) and a state (to store the memory)
* the last argument is to disambiguate the call upon different instanciations.
*
* WARNING: that last argument will generally be the result of calling
* the default ctor of EOT, resulting in most cases in an EOT
* that is ***not properly initialized***
*
* @ingroup bitstring
* @ingroup Builders
*/
template <class EOT>
eoInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT, float _bias=0.5)
{
// for bitstring, only thing needed is the size
// but it might have been already read in the definition fo the performance
unsigned theSize = _parser.getORcreateParam(unsigned(10), "chromSize", "The length of the bitstrings", 'n',"Problem").value();
// Then we can built a bitstring random initializer
// based on boolean_generator class (see utils/rnd_generator.h)
eoBooleanGenerator * gen = new eoBooleanGenerator(_bias);
_state.storeFunctor(gen);
eoInitFixedLength<EOT>* init = new eoInitFixedLength<EOT>(theSize, *gen);
// store in state
_state.storeFunctor(init);
return *init;
}
#endif

View file

@ -0,0 +1,231 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_op.h
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _make_op_h
#define _make_op_h
// the operators
#include <eoOp.h>
#include <eoGenOp.h>
#include <eoCloneOps.h>
#include <eoOpContainer.h>
// combinations of simple eoOps (eoMonOp and eoQuadOp)
#include <eoProportionalCombinedOp.h>
// the specialized GA stuff
#include <ga/eoBit.h>
#include <ga/eoBitOp.h>
// also need the parser and param includes
#include <utils/eoParser.h>
#include <utils/eoState.h>
/////////////////// bitstring operators ///////////////
// canonical (crossover + mutation) only at the moment //
/*
* This function builds the operators that will be applied to the bitstrings
*
* It uses a parser (to get user parameters) and a state (to store the memory)
* the last argument is an individual, needed for 2 reasons
* it disambiguates the call after instanciations
* some operator might need some private information about the indis
*
* This is why the template is the complete EOT even though only the fitness
* is actually templatized here: the following only applies to bitstrings
*
* Note : the last parameter is an eoInit: if some operator needs some info
* about the gneotypes, the init has it all (e.g. bounds, ...)
* Simply do
* EOT myEO;
* _init(myEO);
* and myEO is then an ACTUAL object
*
* @ingroup bitstring
* @ingroup Builders
*/
template <class EOT>
eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init)
{
// this is a temporary version, while Maarten codes the full tree-structured
// general operator input
// BTW we must leave that simple version available somehow, as it is the one
// that 90% people use!
eoValueParam<std::string>& operatorParam = _parser.createParam(std::string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators");
if (operatorParam.value() != std::string("SGA"))
throw std::runtime_error("Only SGA-like operator available right now\n");
// now we read Pcross and Pmut,
// the relative weights for all crossovers -> proportional choice
// the relative weights for all mutations -> proportional choice
// and create the eoGenOp that is exactly
// crossover with pcross + mutation with pmut
eoValueParam<double>& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
// minimum check
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
throw std::runtime_error("Invalid pCross");
eoValueParam<double>& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
// minimum check
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
throw std::runtime_error("Invalid pMut");
// the crossovers
/////////////////
// the parameters
eoValueParam<double>& onePointRateParam = _parser.createParam(double(1.0), "onePointRate", "Relative rate for one point crossover", '1', "Variation Operators" );
// minimum check
if ( (onePointRateParam.value() < 0) )
throw std::runtime_error("Invalid onePointRate");
eoValueParam<double>& twoPointsRateParam = _parser.createParam(double(1.0), "twoPointRate", "Relative rate for two point crossover", '2', "Variation Operators" );
// minimum check
if ( (twoPointsRateParam.value() < 0) )
throw std::runtime_error("Invalid twoPointsRate");
eoValueParam<double>& uRateParam = _parser.createParam(double(2.0), "uRate", "Relative rate for uniform crossover", 'U', "Variation Operators" );
// minimum check
if ( (uRateParam.value() < 0) )
throw std::runtime_error("Invalid uRate");
// minimum check
// bool bCross = true; // not used ?
if (onePointRateParam.value()+twoPointsRateParam.value()+uRateParam.value()==0)
{
std::cerr << "Warning: no crossover" << std::endl;
// bCross = false;
}
// Create the CombinedQuadOp
eoPropCombinedQuadOp<EOT> *ptCombinedQuadOp = NULL;
eoQuadOp<EOT> *ptQuad = NULL;
// 1-point crossover for bitstring
ptQuad = new eo1PtBitXover<EOT>;
_state.storeFunctor(ptQuad);
ptCombinedQuadOp = new eoPropCombinedQuadOp<EOT>(*ptQuad, onePointRateParam.value());
// uniform crossover for bitstring
ptQuad = new eoUBitXover<EOT>;
_state.storeFunctor(ptQuad);
ptCombinedQuadOp->add(*ptQuad, uRateParam.value());
// 2-points xover
ptQuad = new eoNPtsBitXover<EOT>;
_state.storeFunctor(ptQuad);
ptCombinedQuadOp->add(*ptQuad, twoPointsRateParam.value());
// don't forget to store the CombinedQuadOp
_state.storeFunctor(ptCombinedQuadOp);
// the mutations
/////////////////
// the parameters
eoValueParam<double> & pMutPerBitParam = _parser.createParam(0.01, "pMutPerBit", "Probability of flipping 1 bit in bit-flip mutation", 'b', "Variation Operators" );
// minimum check
if ( (pMutPerBitParam.value() < 0) || (pMutPerBitParam.value() > 0.5) )
throw std::runtime_error("Invalid pMutPerBit");
eoValueParam<double> & bitFlipRateParam = _parser.createParam(0.01, "bitFlipRate", "Relative rate for bit-flip mutation", 's', "Variation Operators" );
// minimum check
if ( (bitFlipRateParam.value() < 0) )
throw std::runtime_error("Invalid bitFlipRate");
// oneBitFlip
eoValueParam<double> & oneBitRateParam = _parser.createParam(0.01, "oneBitRate", "Relative rate for deterministic bit-flip mutation", 'd', "Variation Operators" );
// minimum check
if ( (oneBitRateParam.value() < 0) )
throw std::runtime_error("Invalid oneBitRate");
// kBitFlip
eoValueParam<unsigned> & kBitParam = _parser.createParam((unsigned)1, "kBit", "Number of bit for deterministic k bit-flip mutation", 0, "Variation Operators" );
// minimum check
if ( ! kBitParam.value() )
throw std::runtime_error("Invalid kBit");
eoValueParam<double> & kBitRateParam = _parser.createParam(0.0, "kBitRate", "Relative rate for deterministic k bit-flip mutation", 0, "Variation Operators" );
// minimum check
if ( (kBitRateParam.value() < 0) )
throw std::runtime_error("Invalid kBitRate");
// minimum check
// bool bMut = true; // not used ?
if (bitFlipRateParam.value()+oneBitRateParam.value()==0)
{
std::cerr << "Warning: no mutation" << std::endl;
// bMut = false;
}
// Create the CombinedMonOp
eoPropCombinedMonOp<EOT> *ptCombinedMonOp = NULL;
eoMonOp<EOT> *ptMon = NULL;
// standard bit-flip mutation for bitstring
ptMon = new eoBitMutation<EOT>(pMutPerBitParam.value());
_state.storeFunctor(ptMon);
// create the CombinedMonOp
ptCombinedMonOp = new eoPropCombinedMonOp<EOT>(*ptMon, bitFlipRateParam.value());
// mutate exactly 1 bit per individual
ptMon = new eoDetBitFlip<EOT>;
_state.storeFunctor(ptMon);
ptCombinedMonOp->add(*ptMon, oneBitRateParam.value());
// mutate exactly k bit per individual
ptMon = new eoDetBitFlip<EOT>(kBitParam.value());
_state.storeFunctor(ptMon);
ptCombinedMonOp->add(*ptMon, kBitRateParam.value());
_state.storeFunctor(ptCombinedMonOp);
// now build the eoGenOp:
// to simulate SGA (crossover with proba pCross + mutation with proba pMut
// we must construct
// a sequential combination of
// with proba 1, a proportional combination of
// a QuadCopy and our crossover
// with proba pMut, our mutation
// the crossover - with probability pCross
eoProportionalOp<EOT> * cross = new eoProportionalOp<EOT> ;
_state.storeFunctor(cross);
ptQuad = new eoQuadCloneOp<EOT>;
_state.storeFunctor(ptQuad);
cross->add(*ptCombinedQuadOp, pCrossParam.value()); // user crossover
cross->add(*ptQuad, 1-pCrossParam.value()); // clone operator
// now the sequential
eoSequentialOp<EOT> *op = new eoSequentialOp<EOT>;
_state.storeFunctor(op);
op->add(*cross, 1.0); // always crossover (but clone with prob 1-pCross
op->add(*ptCombinedMonOp, pMutParam.value());
// that's it!
return *op;
}
#endif

View file

@ -0,0 +1,61 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_op_ga.cpp
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifdef _MSC_VER
// to avoid long name warnings
#pragma warning(disable:4786)
#endif
/** This file contains all ***INSTANCIATED DEFINITIONS*** of operators
* of the library for ***BISTRING*** evolution inside EO.
* It should be included in the file that calls any of the corresponding fns
* Compiling this file allows one to generate part of the library (i.e. object
* files that you just need to link with your own main and fitness code).
*
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
* in make_op_ga.h
* while the TEMPLATIZED code is define in make_op.h in the ga dir
*
* Unlike most EO .h files, it does not (and should not) contain any code,
* just declarations
*/
// Templatized code
#include <ga/make_op.h>
/// The following function merely call the templatized do_* functions above
// oeprators
////////////
eoGenOp<eoBit<double> >& make_op(eoParser& _parser, eoState& _state, eoInit<eoBit<double> >& _init)
{
return do_make_op(_parser, _state, _init);
}
eoGenOp<eoBit<eoMinimizingFitness> >& make_op(eoParser& _parser, eoState& _state, eoInit<eoBit<eoMinimizingFitness> >& _init)
{
return do_make_op(_parser, _state, _init);
}

View file

@ -0,0 +1,61 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_pop_ga.cpp
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifdef _MSC_VER
// to avoid long name warnings
#pragma warning(disable:4786)
#endif
/** This file contains all ***INSTANCIATED DEFINITIONS*** of population init
* of the library for ***BISTRING*** evolution inside EO.
* It should be included in the file that calls any of the corresponding fns
* Compiling this file allows one to generate part of the library (i.e. object
* files that you just need to link with your own main and fitness code).
*
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
* in ga/make_ga.h
* while the TEMPLATIZED code is define in make_pop.h in the src/do dir
*
*/
// The templatized code
#include <do/make_pop.h>
// the instanciating EOType
#include <ga/eoBit.h>
/// The following function merely call the templatized do_* functions above
// Init POP
///////////
eoPop<eoBit<double> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoBit<double> > & _init)
{
return do_make_pop(_parser, _state, _init);
}
eoPop<eoBit<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoBit<eoMinimizingFitness> > & _init)
{
return do_make_pop(_parser, _state, _init);
}

View file

@ -0,0 +1,65 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// make_run_ga.cpp
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifdef _MSC_VER
// to avoid long name warnings
#pragma warning(disable:4786)
#endif
/** This file contains all ***INSTANCIATED DEFINITIONS*** of operators
* of the library for ***BISTRING*** evolution inside EO.
* It should be included in the file that calls any of the corresponding fns
* Compiling this file allows one to generate part of the library (i.e. object
* files that you just need to link with your own main and fitness code).
*
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
* in make_run_ga.h
* while the TEMPLATIZED code is define in make_run.h in the do dir
*
* Unlike most EO .h files, it does not (and should not) contain any code,
* just declarations
*/
// The templatized code
#include <do/make_run.h>
// the instanciating EOType
#include <ga/eoBit.h>
// the instanciating fitnesses
#include <eoScalarFitness.h>
/// The following function merely call the templatized do_* functions above
// run
/////////
void run_ea(eoAlgo<eoBit<double> >& _ga, eoPop<eoBit<double> >& _pop)
{
do_run(_ga, _pop);
}
void run_ea(eoAlgo<eoBit<eoMinimizingFitness> >& _ga, eoPop<eoBit<eoMinimizingFitness> >& _pop)
{
do_run(_ga, _pop);
}