diff --git a/branches/newMo/src/comparator/moComparator.h b/branches/newMo/src/comparator/moComparator.h index c65c6400c..601778d98 100644 --- a/branches/newMo/src/comparator/moComparator.h +++ b/branches/newMo/src/comparator/moComparator.h @@ -1,34 +1,43 @@ -#ifndef _moNeighborComparator_h -#define _moNeighborComparator_h +#ifndef _moComparator_h +#define _moComparator_h -#include +#include +#include -template< class Neigh > -class moNeighborComparator : public eoBF +// moComparator => comparer deux solutions +// idée : +// - eoComparator +// - moComparator qui hérite de eoComparator ? +// - moeoComparator qui hérite de eoComparator +// idée J : +// - eoComparator : eoBF +// - eoSolComparator : eoComparator ? +// - moNeighborCompartor : : eoComparator +// +// une instantiation possible !! +template< class EOT > +class moComparator : public eoBF { public: /* - * true if the neighbor1 is better than neighbor2 - */ - virtual bool operator()(const Neigh & neighbor1, const Neigh & neighbor2) { - return (neighbor1.fitness() > neighbor2.fitness()); + * Compare two solutions + * @param _sol1 the first solution + * @param _sol2 the second solution + * @return true if the _sol1 is better than _sol2 + */ + virtual bool operator()(const EOT& _sol1, const EOT& _sol2) { + return (_sol1.fitness() > _sol2.fitness()); } - /** Return the class id. - * @return the class name as a std::string - */ - virtual std::string className() const { return "moNeighborComparator"; } + /* + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moComparator"; + } }; - #endif - -// Local Variables: -// coding: iso-8859-1 -// mode: C++ -// c-file-offsets: ((c . 0)) -// c-file-style: "Stroustrup" -// fill-column: 80 -// End: diff --git a/branches/newMo/src/comparator/moNeighborComparator.h b/branches/newMo/src/comparator/moNeighborComparator.h index 85a4d2f25..537af1631 100644 --- a/branches/newMo/src/comparator/moNeighborComparator.h +++ b/branches/newMo/src/comparator/moNeighborComparator.h @@ -1,47 +1,34 @@ #ifndef _moNeighborComparator_h #define _moNeighborComparator_h +#include +#include + #include - - -// moComparator => comparer deux solutions -// idée : -// - eoComparator -// - moComparator qui hérite de eoComparator ? -// - moeoComparator qui hérite de eoComparator -// idée J : -// - eoComparator : eoBF -// - eoSolComparator : eoComparator ? -// - moNeighborCompartor : : eoComparator -// -// une instantiation possible !! -template< class EOT > -class moComparator : public eoBF +template< class Neighbor > +class moNeighborComparator : public eoBF { public: /* - * true if the _sol1 is better than _sol2 - */ - virtual bool operator()(const EOT & _sol1, const EOT & _sol2) { - return (_sol1.fitness() > _sol2.fitness()); + * Compare two neighbors + * @param _neighbor1 the first neighbor + * @param _neighbor2 the second neighbor + * @return true if the neighbor1 is better than neighbor2 + */ + virtual bool operator()(const Neighbor& _neighbor1, const Neighbor& _neighbor2) { + return (neighbor1.fitness() > neighbor2.fitness()); } - /** Return the class id. - * @return the class name as a std::string - */ - virtual std::string className() const { return "moComparator"; } + /* + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moNeighborComparator"; + } }; #endif - - -// Local Variables: -// coding: iso-8859-1 -// mode: C++ -// c-file-offsets: ((c . 0)) -// c-file-style: "Stroustrup" -// fill-column: 80 -// End: diff --git a/branches/newMo/src/continuator/moContinuator.h b/branches/newMo/src/continuator/moContinuator.h index 923219095..dca76d1a4 100644 --- a/branches/newMo/src/continuator/moContinuator.h +++ b/branches/newMo/src/continuator/moContinuator.h @@ -1,9 +1,11 @@ #ifndef _moContinuator_h #define _moContinuator_h +#include + /* - to make specific continuator from a solution -*/ + * To make specific continuator from a solution + */ template< class NH > class moContinuator : public eoUF { @@ -11,19 +13,11 @@ public: typedef NH Neighborhood ; typedef typename Neighborhood::EOT EOT ; - // empty constructor - moContinuator() { } ; - - virtual void init(EOT & solution) = 0 ; + /* + * Init Continuator parameters + * @param _solution the related solution + */ + virtual void init(EOT& _solution) = 0 ; }; #endif - - -// Local Variables: -// coding: iso-8859-1 -// mode: C++ -// c-file-offsets: ((c . 0)) -// c-file-style: "Stroustrup" -// fill-column: 80 -// End: diff --git a/branches/newMo/src/explorer/moNeighborhoodExplorer.h b/branches/newMo/src/explorer/moNeighborhoodExplorer.h index c8c6df60c..d59c242df 100644 --- a/branches/newMo/src/explorer/moNeighborhoodExplorer.h +++ b/branches/newMo/src/explorer/moNeighborhoodExplorer.h @@ -1,40 +1,74 @@ #ifndef _neighborhoodExplorer_h #define _neighborhoodExplorer_h +//EO inclusion +#include + #include + /* - explore the neighborhood -*/ + * Explore the neighborhood + */ template< class NH > -class moNeighborhoodExplorer : public eoUF +class moNeighborhoodExplorer : public eoUF { public: typedef NH Neighborhood ; typedef typename Neighborhood::EOT EOT ; typedef typename Neighborhood::Neighbor Neighbor ; - // empty constructor - moNeighborhoodExplorer() { } ; + /* + * Constructor with a Neighborhood and evaluation function + * @param _neighborhood the neighborhood + * @param _eval the evaluation function + */ + moNeighborhoodExplorer(Neighborhood& _neighborhood, moEval& _eval):neighborhood(_neighborhood), eval(_eval) {} - // empty constructor - moNeighborhoodExplorer(Neighborhood& _neighborhood, moEval& _eval):neighborhood(_neighborhood), eval(_eval) { } ; + /* + * Init Search parameters + * @param _solution the solution to explore + */ + virtual void initParam (EOT& _solution) = 0 ; - virtual void initParam (EOT & solution) = 0 ; + /* + * Update Search parameters + * @param _solution the solution to explore + */ + virtual void updateParam (EOT& _solution) = 0 ; - virtual void updateParam (EOT & solution) = 0 ; + /* + * Test if the exploration continue or not + * @param _solution the solution to explore + * @return true if the exploration continue, else return false + */ + virtual bool isContinue(EOT& _solution) = 0 ; - virtual bool isContinue(EOT & solution) = 0 ; + /* + * Move a solution + * @param _solution the solution to explore + */ + virtual void move(EOT& _solution) = 0 ; - virtual void move(EOT & solution) = 0 ; + /* + * Test if a solution is accepted + * @param _solution the solution to explore + * @return true if the solution is accepted, else return false + */ + virtual bool accept(EOT& _solution) = 0 ; - virtual bool accept(EOT & solution) = 0 ; + /* + * Terminate the search + * @param _solution the solution to explore + */ + virtual void terminate(EOT& _solution) = 0 ; - virtual void terminate(EOT & solution) = 0 ; - - /** Return the class id. - * @return the class name as a std::string - */ - virtual std::string className() const { return "moNeighborhoodExplorer"; } + /* + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moNeighborhoodExplorer"; + } protected: Neighborhood & neighborhood; @@ -42,14 +76,4 @@ protected: }; - #endif - - -// Local Variables: -// coding: iso-8859-1 -// mode: C++ -// c-file-offsets: ((c . 0)) -// c-file-style: "Stroustrup" -// fill-column: 80 -// End: diff --git a/branches/newMo/src/neighborhood/moBackableNeighbor.h b/branches/newMo/src/neighborhood/moBackableNeighbor.h index 397a88525..35a97d646 100644 --- a/branches/newMo/src/neighborhood/moBackableNeighbor.h +++ b/branches/newMo/src/neighborhood/moBackableNeighbor.h @@ -2,17 +2,17 @@ #define _BackableNeighbor_h /* - neighbor with a move back function to use in a moFullEvalByModif -*/ + * Neighbor with a move back function to use in a moFullEvalByModif + */ template< class EOT , class Fitness > class moBackableNeighbor : moNeighbor { public: -/* - * the move back function - * @param _solution the solution to moveBack - */ + /* + * the move back function + * @param _solution the solution to moveBack + */ virtual moveBack(EOT & _solution) = 0; }; diff --git a/branches/newMo/src/neighborhood/moEmptyNeighbor.h b/branches/newMo/src/neighborhood/moEmptyNeighbor.h index 19b553db6..3565a718a 100644 --- a/branches/newMo/src/neighborhood/moEmptyNeighbor.h +++ b/branches/newMo/src/neighborhood/moEmptyNeighbor.h @@ -30,12 +30,3 @@ public: }; #endif - - -// Local Variables: -// coding: iso-8859-1 -// mode: C++ -// c-file-offsets: ((c . 0)) -// c-file-style: "Stroustrup" -// fill-column: 80 -// End: diff --git a/branches/newMo/src/neighborhood/moNeighbor.h b/branches/newMo/src/neighborhood/moNeighbor.h index 55001431e..5421ad40a 100644 --- a/branches/newMo/src/neighborhood/moNeighbor.h +++ b/branches/newMo/src/neighborhood/moNeighbor.h @@ -1,76 +1,96 @@ #ifndef _moNeighbor_h #define _moNeighbor_h -#include +//EO inclusion +#include +#include +#include #include /* - contener of the neighbor informations -*/ + * Container of the neighbor informations + */ template< class EOT , class Fitness > class moNeighbor : public eoObject, public eoPersistent { public: - typedef EOT EOType ; - // empty constructor - moNeighbor() { } ; + /* + * Default Constructor + */ + moNeighbor(){} - // copy constructeur - moNeighbor(const moNeighbor & _n) { - repFitness = _n.fitness(); - } - - // assignment operator - virtual moNeighbor & operator=(const moNeighbor & _n) { - repFitness = _n.fitness(); - return *this ; + /* + * Copy Constructor + * @param _neighbor to copy + */ + moNeighbor(const moNeighbor& _neighbor) { + repFitness = _neighbor.fitness(); } /* - * move the solution - */ - virtual void move(EOT & solution) = 0 ; + * Assignment operator + * @param the _neighbor to assign + * @return a neighbor equal to the other + */ + virtual moNeighbor& operator=(const moNeighbor& _neighbor) { + repFitness = _neighbor.fitness(); + return (*this); + } + + /* + * Move a solution + * @param _solution the related solution + */ + virtual void move(EOT & _solution) = 0 ; - /// Return fitness value. + /* + * Get the fitness of the neighbor + * @return fitness of the neighbor + */ const Fitness& fitness() const { return repFitness; } - /// Get fitness as reference, useful when fitness is set in a multi-stage way, e.g., MOFitness gets performance information, is subsequently ranked + + /* + * Get fitness as reference, useful when fitness is set in a multi-stage way, e.g., MOFitness gets performance information, is subsequently ranked + * @return fitness as reference of the neighbor + */ Fitness& fitnessReference() { return repFitness; } - /** Set fitness. At the same time, validates it. - * @param _fitness New fitness value. - */ - void fitness(const Fitness& _fitness) - { + /* + * Set fitness. At the same time, validates it. + * @param _fitness new fitness value. + */ + void fitness(const Fitness& _fitness){ repFitness = _fitness; } - /** Return the class id. - * @return the class name as a std::string - */ + /* + * Return the class id. + * @return the class name as a std::string + */ virtual std::string className() const { return "moNeighbor"; } - /** - * Read object.\ \ - * Calls base class, just in case that one had something to do. - * The read and print methods should be compatible and have the same format. - * In principle, format is "plain": they just print a number - * @param _is a std::istream. - */ + /* + * Read object. + * Calls base class, just in case that one had something to do. + * The read and print methods should be compatible and have the same format. + * In principle, format is "plain": they just print a number + * @param _is a std::istream. + */ virtual void readFrom(std::istream& _is) { - _is >> repFitness; + _is >> repFitness; } - /** - * Write object. Called printOn since it prints the object _on_ a stream. - * @param _os A std::ostream. - */ + /* + * Write object. Called printOn since it prints the object _on_ a stream. + * @param _os A std::ostream. + */ virtual void printOn(std::ostream& _os) const { _os << repFitness << ' ' ; } diff --git a/branches/newMo/src/neighborhood/moNeighborhood.h b/branches/newMo/src/neighborhood/moNeighborhood.h index 37278331a..bc4050412 100644 --- a/branches/newMo/src/neighborhood/moNeighborhood.h +++ b/branches/newMo/src/neighborhood/moNeighborhood.h @@ -1,35 +1,57 @@ #ifndef _moNeighborhood_h #define _moNeighborhood_h -template< class Neigh > +#include + + +/* + * A Neighborhood + */ +template< class Neighbor > class moNeighborhood : public eoObject { public: - typedef Neigh Neighbor; + /* + * Define type of a solution corresponding to Neighbor + */ typedef typename Neighbor::EOType EOT; - moNeighborhood() { } - - virtual bool hasNeighbor(EOT & solution) = 0 ; + /* + * Default Constructor + */ + moNeighborhood(){} /* - initialisation of the neighborhood - */ - virtual void init(EOT & solution, Neighbor & current) = 0 ; + * Test if a solution has (again) a Neighbor + * @param _solution the related solution + * @return if _solution has a Neighbor + */ + virtual bool hasNeighbor(EOT & _solution) = 0 ; /* - Give the next neighbor - */ - virtual void next(EOT & solution, Neighbor & current) = 0 ; + * Initialization of the neighborhood + * @param _solution the solution to explore + * @param _current the first neighbor + */ + virtual void init(EOT & _solution, Neighbor & _current) = 0 ; /* - if false, there is no neighbor left to explore - */ - virtual bool cont(EOT & solution) = 0 ; + * Give the next neighbor + * @param _solution the solution to explore + * @param _current the next neighbor + */ + virtual void next(EOT & _solution, Neighbor & _current) = 0 ; - /** Return the class id. - * @return the class name as a std::string - */ + /* + * Test if there is again a neighbor + * @param _solution the solution to explore + * @return if there is again a neighbor not explored + */ + virtual bool cont(EOT & _solution) = 0 ; + + /* Return the class id. + * @return the class name as a std::string + */ virtual std::string className() const { return "moNeighborhood"; } }; diff --git a/branches/newMo/tutorial/oneMax/application/testSimpleHC.cpp b/branches/newMo/tutorial/oneMax/application/testSimpleHC.cpp index cfd8591b5..59861980e 100644 --- a/branches/newMo/tutorial/oneMax/application/testSimpleHC.cpp +++ b/branches/newMo/tutorial/oneMax/application/testSimpleHC.cpp @@ -40,7 +40,7 @@ using namespace std; // explore the neighborhood of a bit string in order #include -#include +#include #include