add tests interfaces as examples in the doc ; remove unused test binaries ; some code formating

This commit is contained in:
Johann Dreo 2010-11-07 23:12:28 +01:00
commit bd236ee67f
54 changed files with 129 additions and 1410 deletions

View file

@ -55,6 +55,8 @@
@ref Operators that effectively modify EO objects must invalidate them.
The fitness object must have, besides an void ctor, a copy ctor.
@example t-eo.cpp
*/
template<class F = double> class EO: public eoObject, public eoPersistent
{

View file

@ -307,5 +307,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
// that's it!
return *algo;
}
/** @example t-eoGA.cpp
*/
#endif

View file

@ -273,9 +273,11 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
// Friend classes
friend class eoIslandsEasyEA <EOT> ;
friend class eoDistEvalEasyEA <EOT> ;
};
//-----------------------------------------------------------------------------
};
/**
@example t-eoEasyEA.cpp
Example of a test program building an EA algorithm.
*/
#endif

View file

@ -188,6 +188,9 @@ protected:
}dummyInit;
};
/**
* @example t-eoEasyPSO.cpp
* Example of a test program building a PSO algorithm.
*/
#endif /*_EOEASYPSO_H*/

View file

@ -35,7 +35,9 @@
//-----------------------------------------------------------------------------
/** Extended velocity performer for particle swarm optimization. Derivated from abstract eoVelocity,
/** Extended velocity performer for particle swarm optimization.
*
* Derivated from abstract eoVelocity,
* At step t: v(t+1)= w * v(t) + c1 * r1 * ( xbest(t)-x(t) ) + c2 * r2 * ( lbest(t) - x(t) ) + c3 * r3 * ( gbest(t) - x(t) )
* It includes both a "topology" best and a global best in the social knowledge. Each topology
* provides a method to retrieve the global best <=> the best of all the neighborhood the topology contains.
@ -60,7 +62,7 @@ public:
* @param _c3 - Learning factor used for the global best
* @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities.
* If the velocities are not real, they won't be bounded by default. Should have a eoBounds ?
* @param _boundsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only).
* @param _bndsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only).
* @param _gen - The eo random generator, default=rng
*/
eoExtendedVelocity (eoTopology < POT > & _topology,
@ -204,7 +206,9 @@ protected:
// If the bound modifier doesn't need to be used, use the dummy instance
eoDummyRealBoundModifier dummyModifier;
};
/** @todo this example does not appear in the doc for an unknown reason
* @example t-eoExtendedVelocity.cpp
* Example of a test program using this class:
*/
#endif /*eoExtendedVelocity_H */

View file

@ -60,6 +60,8 @@ public :
/// tag to identify a binary function in compile time function selection @see functor_category
struct binary_function_tag {};
};
/** @example t-eoFunctop.cpp
*/
/**
Basic Function. Derive from this class when defining

View file

@ -81,6 +81,8 @@ class eoGenOp : public eoOp<EOT>, public eoUF<eoPopulator<EOT> &, void>
*/
virtual void apply(eoPopulator<EOT>& _pop) = 0;
};
/** @example t-eoGenOp.cpp
*/
/** Wrapper for eoMonOp */

View file

@ -183,6 +183,8 @@ class eoInitPermutation: public eoInit<EOT>
unsigned startFrom;
UF_random_generator<unsigned int> gen;
};
/** @example t-eoInitPermutation.cpp
*/
/**

View file

@ -54,6 +54,8 @@ template <class FitT> class eoInt: public eoVector<FitT, int>
}
};
/** @example t-eoInt.cpp
*/
//-----------------------------------------------------------------------------

View file

@ -63,10 +63,16 @@ Variators are operators that modify individuals.
Selectors are operators that select a subset of a population.
Example:
@include t-eoSelect.cpp
@defgroup Replacors Replacement operators
Replacors are operators that replace a subset of a population by another set of individuals.
Here is an example with several replacement operators:
@include t-eoReplacement.cpp
*/
/** Abstract data types for EO operators.

View file

@ -84,5 +84,7 @@ template<class Chrom> class eoOrderXover: public eoQuadOp<Chrom>
}
};
/** @example t-eoOrderXover.cpp
*/
#endif

View file

@ -81,5 +81,7 @@ private :
typedef std::vector<typename EOT::Fitness> FitVec;
FitVec cumulative;
};
/** @example t-eoRoulette.cpp
*/
#endif

View file

@ -188,5 +188,7 @@ protected:
unsigned neighborhoodSize;
bool isSetup;
};
/** @example t-eoRingTopology.cpp
*/
#endif /*EORINGTOPOLOGY_H_*/

View file

@ -79,6 +79,9 @@ class eoScalarFitness
private :
ScalarType value;
};
/** @example t-eofitness.cpp
*
*/
/**
Typedefs for fitness comparison, Maximizing Fitness compares with less,

View file

@ -77,6 +77,8 @@ public:
private:
static std::vector<std::string> TermDescriptions;
};
/** @example t-eoFitnessAssembled.cpp
*/
//! Implements fitness as std::vector, storing all values that might occur during fitness assembly
/*! Properties:
@ -237,6 +239,10 @@ public:
bool operator>=(const eoScalarFitnessAssembled<ScalarType, Compare, FitnessTraits>& y ) const { return !(*this < y); }
};
/**
* @example t-eoFitnessAssembledEA.cpp
*/
/**
Typedefs for fitness comparison, Maximizing Fitness compares with less,

View file

@ -64,6 +64,8 @@ public:
}
};
/** @example t-eoSecondsElapsedContinue.cpp
*/
#endif

View file

@ -53,6 +53,8 @@ class eoSelectOne : public eoUF<const eoPop<EOT>&, const EOT&>
(void)_pop;
}
};
/** @example t-eoSelectOne.cpp
*/
#endif

View file

@ -53,5 +53,7 @@ public:
private :
eoSharing<EOT> sharing; // derived from eoPerf2Worth
};
/** @example t-eoSharing.cpp
*/
#endif

View file

@ -83,6 +83,8 @@ template<class EOT> class eoShiftMutation: public eoMonOp<EOT>
}
};
/** @example t-eoShiftMutation.cpp
*/
//-----------------------------------------------------------------------------

View file

@ -104,5 +104,7 @@ private :
typedef std::vector<unsigned> IndexVec;
IndexVec indices;
};
/** @example t-eoRoulette.cpp
*/
#endif

View file

@ -75,6 +75,8 @@ template<class Chrom> class eoSwapMutation: public eoMonOp<Chrom>
private:
unsigned int howManySwaps;
};
/** @example t-eoSwapMutation.cpp
*/
//-----------------------------------------------------------------------------
#endif

View file

@ -253,6 +253,8 @@ private:
}dummyInit;
};
/** @example t-eoSyncEasyPSO.cpp
*/
#endif /*_EOSYNCEASYPSO_H*/

View file

@ -69,6 +69,8 @@ public:
}
};
/** @example t-eoTwoOptMutation.cpp
*/
//-----------------------------------------------------------------------------

View file

@ -60,7 +60,7 @@ public:
* @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType
* @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities.
* If the velocities are not real, they won't be bounded by default. Should have a eoBounds ?
* @param _boundsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only).
* @param _bndsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only).
* @param _gen - The eo random generator, default=rng
*/
eoVariableInertiaWeightedVelocity (eoTopology < POT > & _topology,

View file

@ -56,7 +56,7 @@ public :
/** default ctor
* @param nMax max number of atoms
* @param _nMax max number of atoms
* @param _atomInit an Atom initializer
*/
eoVlAddMutation(unsigned _nMax, eoInit<AtomType> & _atomInit) :
@ -118,15 +118,15 @@ public :
/** ctor with an external gene chooser
* @param nMin min number of atoms to leave in the individual
* @param _geneChooser an eoGeneCHooser to choose which one to delete
* @param _nMin min number of atoms to leave in the individual
* @param _chooser an eoGeneCHooser to choose which one to delete
*/
eoVlDelMutation(unsigned _nMin, eoGeneDelChooser<EOT> & _chooser) :
nMin(_nMin), uChooser(), chooser(_chooser) {}
/** ctor with uniform gene chooser - the default
* @param nMin min number of atoms to leave in the individual
* @param _nMin min number of atoms to leave in the individual
*/
eoVlDelMutation(unsigned _nMin) :
nMin(_nMin), uChooser(), chooser(uChooser) {}

View file

@ -66,8 +66,8 @@ public:
/** default constructor
@param size Length of vector (default is 0)
@param value Initial value of all elements (default is default value of type GeneType)
@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)
@ -129,6 +129,8 @@ public:
}
}
};
/** @example t-eoVector.cpp
*/
/** Less than

View file

@ -66,9 +66,9 @@ public:
/** Default constructor.
* @param _size Length of the tree vectors (we expect the same size), default is 0
* @param position
* @param velocity
* @param bestPositions
* @param _position
* @param _velocity
* @param _bestPositions
*/
eoVectorParticle (unsigned _size = 0,PositionType _position = PositionType (), VelocityType _velocity = VelocityType (), PositionType _bestPositions = PositionType ()):PO < FitT > (),std::vector < PositionType > (_size, _position), bestPositions (_size, _bestPositions), velocities (_size,
_velocity)

View file

@ -54,6 +54,8 @@ template <class FitT> class eoReal: public eoVector<FitT, double>
}
};
/** @example t-eoReal.cpp
*/
//-----------------------------------------------------------------------------

View file

@ -44,7 +44,10 @@
/** @defgroup bitstring Bit strings
Various functions for a bitstring representation
Various functions for a bitstring representation.
Example of a complete test program that use various bitstrings operators:
@include t-eobin.cpp
@ingroup Representations
*/

View file

@ -41,6 +41,9 @@ using namespace gp_parse_tree;
Various functions for tree-based Genetic Programming
Example:
@include t-eoSymreg.cpp
@ingroup Representations
*/
@ -166,6 +169,8 @@ public:
*/
}
};
/** @example t-eoSymreg.cpp
*/
// friend function to print eoParseTree
template <class FType, class Node>

View file

@ -22,8 +22,9 @@
class Node (your node in the tree) must have the following implemented:
****** Arity ******
\code
int arity(void) const
\endcode
Note: the default constructor of a Node should provide a
Node with arity 0!
@ -36,7 +37,9 @@
is the simplest evaluation, it will call
\code
RetVal Node::operator()(RetVal, subtree<Node, RetVal>::const_iterator)
\endcode
(Unfortunately the first RetVal argument is mandatory (although you
might not need it. This is because MSVC does not support member template
@ -50,7 +53,9 @@
will call:
\code
RetVal Node::operator()(RetVal, subtree<... , It values)
\endcode
where It is whatever type you desire (most of the time
this will be a std::vector containing the values of your
@ -60,7 +65,9 @@
will call:
\code
RetVal Node::operator()(RetVal, subtree<... , It values, It2 moreValues)
\endcode
although I do not see the immediate use of this, however...
@ -68,7 +75,9 @@
that calls:
\code
RetVal Node::operator()(subtree<... , It values, It2 args, It3 adfs)
\endcode
can be useful for implementing adfs.
@ -77,8 +86,10 @@
arguments open so that different ways of evaluation remain
possible. Implement the simplest eval as:
\code
template <class It>
RetVal operator()(RetVal dummy, It begin) const
\endcode
****** Internal Structure ******
@ -144,7 +155,9 @@
or from an std::istream:
copy(std::istream_iterator<T>(my_stream), std::istream_iterator<T>(), back_inserter(tree));
\code
copy(std::istream_iterator<T>(my_stream), std::istream_iterator<T>(), back_inserter(tree));
\endcode
Note that the back_inserter must be used as there is no
resize member in the parse_tree. back_inserter will use

View file

@ -74,6 +74,8 @@ public :
}
};
/** @example t-eoExternalEO.cpp
*/
/** To remove ambiguities between EO<F> and External, streaming operators are defined yet again
* @ingroup Utilities

View file

@ -39,10 +39,13 @@
*
* Use them with eoStats, eoUpdater and eoMonitor to get statistics at each generation.
*
* @see eoStats
* @see eoStat
* @see eoMonitor
* @see eoUpdater
*
* Example of a test program using checkpointing:
* @include t-eoCheckpointing.cpp
*
* @ingroup Utilities
*
* @{

View file

@ -247,6 +247,8 @@ private:
*/
std::map< std::ostream*, int > _standard_io_streams;
};
/** @example t-eoLogger.cpp
*/
namespace eo
{

View file

@ -438,6 +438,8 @@ private:
*/
eoRng& operator=(const eoRng&);
};
/** @example t-eoRNG.cpp
*/

View file

@ -33,6 +33,12 @@
/**
\defgroup Real Vector of reals
Set of classes related to continuous black-box optimization problems.
Here are several examples of test programs using eoReal, eoEsSimple, eoEsStdev or eoEsFull to build an Evoution Strategies algorithm:
@include t-eoESAll.cpp
@include t-eoESFull.cpp
@ingroup Representations
*/

View file

@ -88,12 +88,16 @@ template <class T = double> class eoUniformGenerator : public eoRndGenerator<T>
for ints and unsigneds
*/
T operator()(void) { return minim+static_cast<T>(uniform.uniform(range)); }
/** @example t-eoUniform.cpp
*/
private :
T minim;
T range;
eoRng& uniform;
};
/** @example t-eoRandom.cpp
*/
/// Specialization for bool, does an unbiased coin flip

View file

@ -407,6 +407,8 @@ private :
}
};
/** @example t-eoSSGA.cpp
*/
template <class EOT>
class eoDistanceStat : public eoStat<EOT, double>

View file

@ -132,5 +132,7 @@ private :
eoState& operator=(const eoState&);
};
/** @example t-eoStateAndParser.cpp
*/
#endif