Avancement de la doc
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1654 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
31c6fe9888
commit
6a72d70f23
20 changed files with 487 additions and 1530 deletions
|
|
@ -1,3 +1,4 @@
|
|||
###############################################################
|
||||
# This is a dummy file
|
||||
###############################################################
|
||||
ADD_SUBDIRECTORY(algo)
|
||||
|
|
@ -4,9 +4,9 @@
|
|||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <continuator/moContinuator.h>
|
||||
|
||||
/*
|
||||
the main algorithm of the local search
|
||||
*/
|
||||
/**
|
||||
* the main algorithm of the local search
|
||||
*/
|
||||
template< class NHE , class C >
|
||||
class moLocalSearch: public eoMonOp<typename NHE::EOT>
|
||||
{
|
||||
|
|
@ -15,34 +15,42 @@ public:
|
|||
typedef C Continuator ;
|
||||
typedef typename NeighborhoodExplorer::EOT EOT ;
|
||||
|
||||
moLocalSearch(NeighborhoodExplorer & __searchExpl, Continuator & __continuator) : searchExplorer(__searchExpl), continuator(__continuator) { } ;
|
||||
|
||||
virtual bool operator() (EOT & solution) {
|
||||
/**
|
||||
* Constructor of a moLocalSearch needs a NeighborhooExplorer and a Continuator
|
||||
*/
|
||||
moLocalSearch(NeighborhoodExplorer& _searchExpl, Continuator & _continuator) : searchExplorer(_searchExpl), continuator(_continuator) { } ;
|
||||
|
||||
/**
|
||||
* Run the local search on a solution
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
virtual bool operator() (EOT & _solution) {
|
||||
|
||||
// initialization of the external continuator (for example the time, or the number of generations)
|
||||
continuator.init(solution);
|
||||
continuator.init(_solution);
|
||||
|
||||
// initialization of the parameter of the search (for example fill empty the tabu list)
|
||||
searchExplorer.initParam(solution);
|
||||
searchExplorer.initParam(_solution);
|
||||
|
||||
unsigned num = 0;
|
||||
|
||||
do {
|
||||
// explore the neighborhood of the solution
|
||||
searchExplorer(solution);
|
||||
searchExplorer(_solution);
|
||||
|
||||
// if a solution in the neighborhood can be accepted
|
||||
if (searchExplorer.accept(solution))
|
||||
searchExplorer.move(solution);
|
||||
if (searchExplorer.accept(_solution))
|
||||
searchExplorer.move(_solution);
|
||||
|
||||
// update the parameter of the search (for ex. Temperature of the SA)
|
||||
searchExplorer.updateParam(solution);
|
||||
searchExplorer.updateParam(_solution);
|
||||
|
||||
std::cout << num << " : " << solution << std::endl ;
|
||||
std::cout << num << " : " << _solution << std::endl ;
|
||||
num++;
|
||||
} while (continuator(solution) && searchExplorer.isContinue(solution));
|
||||
} while (continuator(_solution) && searchExplorer.isContinue(_solution));
|
||||
|
||||
searchExplorer.terminate(solution);
|
||||
searchExplorer.terminate(_solution);
|
||||
|
||||
//A CHANGER
|
||||
return true;
|
||||
|
|
@ -51,10 +59,10 @@ public:
|
|||
|
||||
private:
|
||||
// make the exploration of the neighborhood according to a local search heuristic
|
||||
NeighborhoodExplorer & searchExplorer ;
|
||||
NeighborhoodExplorer& searchExplorer ;
|
||||
|
||||
// external continuator
|
||||
Continuator & continuator ;
|
||||
Continuator& continuator ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,12 +15,17 @@
|
|||
// - moNeighborCompartor : : eoComparator<Neighbor>
|
||||
//
|
||||
// une instantiation possible !!
|
||||
|
||||
|
||||
/**
|
||||
* Comparator of two solutions
|
||||
*/
|
||||
template< class EOT >
|
||||
class moComparator : public eoBF<const EOT & , const EOT & , bool>
|
||||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
/**
|
||||
* Compare two solutions
|
||||
* @param _sol1 the first solution
|
||||
* @param _sol2 the second solution
|
||||
|
|
@ -30,7 +35,7 @@ public:
|
|||
return (_sol1.fitness() > _sol2.fitness());
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,12 +6,16 @@
|
|||
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
|
||||
|
||||
/**
|
||||
* Comparator of two neighbors
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moNeighborComparator : public eoBF<const Neighbor & , const Neighbor & , bool>
|
||||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
/**
|
||||
* Compare two neighbors
|
||||
* @param _neighbor1 the first neighbor
|
||||
* @param _neighbor2 the second neighbor
|
||||
|
|
@ -21,7 +25,7 @@ public:
|
|||
return (neighbor1.fitness() > neighbor2.fitness());
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
/*
|
||||
/**
|
||||
* To make specific continuator from a solution
|
||||
*/
|
||||
template< class NH >
|
||||
|
|
@ -13,7 +13,7 @@ public:
|
|||
typedef NH Neighborhood ;
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Init Continuator parameters
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <continuator/moContinuator.h>
|
||||
|
||||
/*
|
||||
/**
|
||||
to make specific continuator from a solution
|
||||
*/
|
||||
template< class NH >
|
||||
|
|
@ -16,7 +16,7 @@ public:
|
|||
// empty constructor
|
||||
moTrueContinuator() { i=0;} ;
|
||||
|
||||
/*
|
||||
/**
|
||||
always true
|
||||
*/
|
||||
virtual bool operator()(EOT & solution) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
/**
|
||||
* Abstract class for the evaluation
|
||||
*/
|
||||
template<class Neighbor>
|
||||
class moEval : public eoBF<typename Neighbor::EOType &, Neighbor&, void>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
#include <neighborhood/moBitNeighbor.h>
|
||||
#include <ga.h>
|
||||
|
||||
/*
|
||||
contener of the neighbor information
|
||||
*/
|
||||
/**
|
||||
* contener of the neighbor information
|
||||
*/
|
||||
template< class Fitness >
|
||||
class moFullEvalBitNeighbor : public moBitNeighbor<Fitness>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
#include <eoEvalFunc.h>
|
||||
#include <moEval.h>
|
||||
|
||||
|
||||
/**
|
||||
* Evaluation by copy
|
||||
*/
|
||||
template<class Neighbor>
|
||||
class moFullEvalByCopy : public moEval<Neighbor>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <eoEvalFunc.h>
|
||||
#include <moEval.h>
|
||||
|
||||
/*
|
||||
/**
|
||||
* Full evaluation to use with a moBackableNeighbor
|
||||
*/
|
||||
template<class BackableNeighbor>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/*
|
||||
/**
|
||||
* Explore the neighborhood
|
||||
*/
|
||||
template< class NH >
|
||||
|
|
@ -17,52 +17,52 @@ public:
|
|||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Constructor with a Neighborhood and evaluation function
|
||||
* @param _neighborhood the neighborhood
|
||||
* @param _eval the evaluation function
|
||||
*/
|
||||
moNeighborhoodExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval):neighborhood(_neighborhood), eval(_eval) {}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Init Search parameters
|
||||
* @param _solution the solution to explore
|
||||
*/
|
||||
virtual void initParam (EOT& _solution) = 0 ;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Update Search parameters
|
||||
* @param _solution the solution to explore
|
||||
*/
|
||||
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 ;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Move a solution
|
||||
* @param _solution the solution to explore
|
||||
*/
|
||||
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 ;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Terminate the search
|
||||
* @param _solution the solution to explore
|
||||
*/
|
||||
virtual void terminate(EOT& _solution) = 0 ;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _BackableNeighbor_h
|
||||
#define _BackableNeighbor_h
|
||||
|
||||
/*
|
||||
/**
|
||||
* Neighbor with a move back function to use in a moFullEvalByModif
|
||||
*/
|
||||
template< class EOT , class Fitness >
|
||||
|
|
@ -9,7 +9,7 @@ class moBackableNeighbor : moNeighbor<EOT, Fitness>
|
|||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
/**
|
||||
* the move back function
|
||||
* @param _solution the solution to moveBack
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,3 +1,39 @@
|
|||
/*
|
||||
<moNeighbor.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _moNeighbor_h
|
||||
#define _moNeighbor_h
|
||||
|
||||
|
|
@ -8,7 +44,7 @@
|
|||
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
|
||||
/*
|
||||
/**
|
||||
* Container of the neighbor informations
|
||||
*/
|
||||
template< class EOT , class Fitness >
|
||||
|
|
@ -16,12 +52,12 @@ class moNeighbor : public eoObject, public eoPersistent
|
|||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moNeighbor(){}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Copy Constructor
|
||||
* @param _neighbor to copy
|
||||
*/
|
||||
|
|
@ -29,9 +65,9 @@ public:
|
|||
repFitness = _neighbor.fitness();
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Assignment operator
|
||||
* @param the _neighbor to assign
|
||||
* @param _neighbor the neighbor to assign
|
||||
* @return a neighbor equal to the other
|
||||
*/
|
||||
virtual moNeighbor<EOT, Fitness>& operator=(const moNeighbor<EOT, Fitness>& _neighbor) {
|
||||
|
|
@ -39,13 +75,13 @@ public:
|
|||
return (*this);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Move a solution
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
virtual void move(EOT & _solution) = 0 ;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Get the fitness of the neighbor
|
||||
* @return fitness of the neighbor
|
||||
*/
|
||||
|
|
@ -54,7 +90,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
|
@ -62,7 +98,7 @@ public:
|
|||
return repFitness;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Set fitness. At the same time, validates it.
|
||||
* @param _fitness new fitness value.
|
||||
*/
|
||||
|
|
@ -70,13 +106,13 @@ public:
|
|||
repFitness = _fitness;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* 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.
|
||||
|
|
@ -87,7 +123,7 @@ public:
|
|||
_is >> repFitness;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Write object. Called printOn since it prints the object _on_ a stream.
|
||||
* @param _os A std::ostream.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,52 +4,53 @@
|
|||
#include <eoObject.h>
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* A Neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moNeighborhood : public eoObject
|
||||
{
|
||||
public:
|
||||
/*
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOType EOT;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moNeighborhood(){}
|
||||
|
||||
/*
|
||||
/**
|
||||
* 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 ;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Initialization of the neighborhood
|
||||
* @param _solution the solution to explore
|
||||
* @param _current the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _current) = 0 ;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Give the next neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @param _current the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _current) = 0 ;
|
||||
|
||||
/*
|
||||
/**
|
||||
* 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 id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const { return "moNeighborhood"; }
|
||||
|
|
|
|||
|
|
@ -39,18 +39,18 @@
|
|||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Definition of a move.
|
||||
// Definition of a move.
|
||||
|
||||
/*!
|
||||
A move transforms a solution to another close solution.
|
||||
It describes how a solution can be modified to another one.
|
||||
*/
|
||||
/*
|
||||
* A move transforms a solution to another close solution.
|
||||
* It describes how a solution can be modified to another one.
|
||||
*/
|
||||
template < class EOT >
|
||||
class moMove:public eoUF < EOT &, void >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the type
|
||||
// Alias for the type
|
||||
typedef EOT EOType;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@
|
|||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! (generally) Efficient evaluation function based a move and a solution.
|
||||
// (generally) Efficient evaluation function based a move and a solution.
|
||||
|
||||
/*!
|
||||
From a move and a solution, it computes
|
||||
a new fitness that could be associated to
|
||||
the solution if this one is updated.
|
||||
*/
|
||||
/*
|
||||
* From a move and a solution, it computes
|
||||
* a new fitness that could be associated to
|
||||
* the solution if this one is updated.
|
||||
*/
|
||||
template < class M, class Objective = typename M::EOType::Fitness>
|
||||
class moMoveIncrEval:public eoBF < const M &, const typename M::EOType &, Objective >
|
||||
{};
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@
|
|||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Move (moMove) initializer
|
||||
/*!
|
||||
Class which allows to initiase a move.
|
||||
Only a description... An object that herits from this class needs to be designed to be used.
|
||||
*/
|
||||
// Move (moMove) initializer
|
||||
/*
|
||||
* Class which allows to initiase a move.
|
||||
* Only a description... An object that herits from this class needs to be designed to be used.
|
||||
*/
|
||||
template < class M >
|
||||
class moMoveInit:public eoBF < M &, const typename M::EOType &, void >
|
||||
{};
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@
|
|||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Class which allows to generate a new move (moMove).
|
||||
/*!
|
||||
Useful for the explorer (for moTS or moHC).
|
||||
Does nothing... An object that herits from this class needs to be designed for being used.
|
||||
*/
|
||||
// Class which allows to generate a new move (moMove).
|
||||
/*
|
||||
* Useful for the explorer (for moTS or moHC).
|
||||
* Does nothing... An object that herits from this class needs to be designed for being used.
|
||||
*/
|
||||
template < class M >
|
||||
class moNextMove:public eoBF < M &, const typename M::EOType &, bool >
|
||||
{};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue