Ajout des dummeLS et dummyExplorer. Travaux en cours sur RndRndFC
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1793 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
71fa51d3b5
commit
85fa0b461f
11 changed files with 299 additions and 14 deletions
71
trunk/paradiseo-mo/src/algo/moDummyLS.h
Normal file
71
trunk/paradiseo-mo/src/algo/moDummyLS.h
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
<moDummyLS.h>
|
||||||
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||||
|
|
||||||
|
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
|
||||||
|
|
||||||
|
This software is governed by the CeCILL license under French law and
|
||||||
|
abiding by the rules of distribution of free software. You can ue,
|
||||||
|
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".
|
||||||
|
|
||||||
|
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 _moDummyLS_h
|
||||||
|
#define _moDummyLS_h
|
||||||
|
|
||||||
|
#include <algo/moLocalSearch.h>
|
||||||
|
#include <explorer/moDummyExplorer.h>
|
||||||
|
#include <continuator/moTrueContinuator.h>
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Dummy Local Search:
|
||||||
|
*
|
||||||
|
* To do nothing, only the full evaluation of the solution if necessary ;-)
|
||||||
|
********************************************************/
|
||||||
|
template<class Neighbor>
|
||||||
|
class moDummyLS: public moLocalSearch<Neighbor>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple constructor
|
||||||
|
* @param _fullEval the full evaluation function
|
||||||
|
*/
|
||||||
|
moDummyLS(eoEvalFunc<EOT>& _fullEval):
|
||||||
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return name of the class
|
||||||
|
*/
|
||||||
|
virtual std::string className(void) const {
|
||||||
|
return "moDummyLS";
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// always true continuator
|
||||||
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
|
// the explorer of the simple HC
|
||||||
|
moDummyExplorer<Neighbor> explorer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -72,6 +72,13 @@ public:
|
||||||
explorer(_init, _fullEval, _nbSolMax>0?_nbSolMax - 1:0)
|
explorer(_init, _fullEval, _nbSolMax>0?_nbSolMax - 1:0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return name of the class
|
||||||
|
*/
|
||||||
|
virtual std::string className(void) const {
|
||||||
|
return "moRandomSearch";
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// always true continuator
|
// always true continuator
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
|
|
|
||||||
107
trunk/paradiseo-mo/src/explorer/moDummyExplorer.h
Normal file
107
trunk/paradiseo-mo/src/explorer/moDummyExplorer.h
Normal file
|
|
@ -0,0 +1,107 @@
|
||||||
|
/*
|
||||||
|
<moDummyExplorer.h>
|
||||||
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||||
|
|
||||||
|
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||||
|
|
||||||
|
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 _moDummyExplorer_h
|
||||||
|
#define _moDummyExplorer_h
|
||||||
|
|
||||||
|
#include <explorer/moNeighborhoodExplorer.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dummy Explorer the neighborhood: nothing is explored
|
||||||
|
*/
|
||||||
|
template< class Neighbor >
|
||||||
|
class moDummyExplorer : public moNeighborhoodExplorer<Neighbor>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef moNeighborhood<Neighbor> Neighborhood;
|
||||||
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
typedef typename EOT::Fitness Fitness ;
|
||||||
|
|
||||||
|
moDummyExplorer(): moNeighborhoodExplorer<Neighbor>() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init Search parameters
|
||||||
|
* @param _solution the solution to explore
|
||||||
|
*/
|
||||||
|
void initParam (EOT& _solution) { } ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Search parameters
|
||||||
|
* @param _solution the solution to explore
|
||||||
|
*/
|
||||||
|
void updateParam (EOT& _solution) { } ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the exploration continue or not
|
||||||
|
* @param _solution the solution to explore
|
||||||
|
* @return true if the exploration continue, else return false
|
||||||
|
*/
|
||||||
|
bool isContinue(EOT& _solution) { return false; } ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a solution
|
||||||
|
* @param _solution the solution to explore
|
||||||
|
*/
|
||||||
|
void move(EOT& _solution) { } ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) { return false; } ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terminate the search
|
||||||
|
* @param _solution the solution to explore
|
||||||
|
*/
|
||||||
|
virtual void terminate(EOT& _solution) { } ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explore the neighborhood of a solution
|
||||||
|
* @param _solution
|
||||||
|
*/
|
||||||
|
void operator()(EOT & _solution) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the class id.
|
||||||
|
* @return the class name as a std::string
|
||||||
|
*/
|
||||||
|
virtual std::string className() const {
|
||||||
|
return "moDummyExplorer";
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
#define _newmo_h
|
#define _newmo_h
|
||||||
|
|
||||||
#include <algo/moLocalSearch.h>
|
#include <algo/moLocalSearch.h>
|
||||||
|
#include <algo/moDummyLS.h>
|
||||||
#include <algo/moRandomSearch.h>
|
#include <algo/moRandomSearch.h>
|
||||||
#include <algo/moMetropolisHasting.h>
|
#include <algo/moMetropolisHasting.h>
|
||||||
#include <algo/moSA.h>
|
#include <algo/moSA.h>
|
||||||
|
|
@ -90,6 +91,7 @@
|
||||||
#include <explorer/moNeutralHCexplorer.h>
|
#include <explorer/moNeutralHCexplorer.h>
|
||||||
#include <explorer/moMetropolisHastingExplorer.h>
|
#include <explorer/moMetropolisHastingExplorer.h>
|
||||||
#include <explorer/moNeighborhoodExplorer.h>
|
#include <explorer/moNeighborhoodExplorer.h>
|
||||||
|
#include <explorer/moDummyExplorer.h>
|
||||||
#include <explorer/moRandomSearchExplorer.h>
|
#include <explorer/moRandomSearchExplorer.h>
|
||||||
#include <explorer/moRandomNeutralWalkExplorer.h>
|
#include <explorer/moRandomNeutralWalkExplorer.h>
|
||||||
#include <explorer/moRandomWalkExplorer.h>
|
#include <explorer/moRandomWalkExplorer.h>
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public:
|
||||||
*/
|
*/
|
||||||
~moAutocorrelationSampling() {
|
~moAutocorrelationSampling() {
|
||||||
// delete the pointer on the local search which has been constructed in the constructor
|
// delete the pointer on the local search which has been constructed in the constructor
|
||||||
delete &localSearch;
|
delete localSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public:
|
||||||
*/
|
*/
|
||||||
~moDensityOfStatesSampling() {
|
~moDensityOfStatesSampling() {
|
||||||
// delete the pointer on the local search which has been constructed in the constructor
|
// delete the pointer on the local search which has been constructed in the constructor
|
||||||
delete &localSearch;
|
delete localSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ public:
|
||||||
*/
|
*/
|
||||||
~moHillClimberSampling() {
|
~moHillClimberSampling() {
|
||||||
// delete the pointer on the local search which has been constructed in the constructor
|
// delete the pointer on the local search which has been constructed in the constructor
|
||||||
delete &localSearch;
|
delete localSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ public:
|
||||||
*/
|
*/
|
||||||
~moNeutralDegreeSampling() {
|
~moNeutralDegreeSampling() {
|
||||||
// delete the pointer on the local search which has been constructed in the constructor
|
// delete the pointer on the local search which has been constructed in the constructor
|
||||||
delete &localSearch;
|
delete localSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
<moRndRndFitnessCloudSampling.h>
|
||||||
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||||
|
|
||||||
|
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
|
||||||
|
|
||||||
|
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 moRndRndFitnessCloudSampling_h
|
||||||
|
#define moRndRndFitnessCloudSampling_h
|
||||||
|
|
||||||
|
#include <eoInit.h>
|
||||||
|
#include <neighborhood/moNeighborhood.h>
|
||||||
|
#include <eval/moEval.h>
|
||||||
|
#include <eoEvalFunc.h>
|
||||||
|
#include <algo/moRandomSearch.h>
|
||||||
|
#include <continuator/moNeighborFitnessStat.h>
|
||||||
|
#include <sampling/moFitnessCloudSampling.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To compute an estimation of the fitness cloud,
|
||||||
|
* i.e. the scatter plot of solution fitness versus neighbor fitness:
|
||||||
|
*
|
||||||
|
* Sample the fitness of random solution in the search space
|
||||||
|
* and the fitness of one random neighbor
|
||||||
|
*
|
||||||
|
* The values are collected during the random search
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
template <class Neighbor>
|
||||||
|
class moRndRndFitnessCloudSampling : public moFitnessCloudSampling<Neighbor>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename Neighbor::EOT EOT ;
|
||||||
|
|
||||||
|
using moSampling<Neighbor>::localSearch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default Constructor
|
||||||
|
* @param _init initialisation method of the solution
|
||||||
|
* @param _neighborhood neighborhood to get one random neighbor (supposed to be random neighborhood)
|
||||||
|
* @param _fullEval Fitness function, full evaluation function
|
||||||
|
* @param _eval neighbor evaluation, incremental evaluation function
|
||||||
|
* @param _nbSol Number of solutions in the sample
|
||||||
|
*/
|
||||||
|
moRndRndFitnessCloudSampling(eoInit<EOT> & _init,
|
||||||
|
moNeighborhood<Neighbor> & _neighborhood,
|
||||||
|
eoEvalFunc<EOT>& _fullEval,
|
||||||
|
moEval<Neighbor>& _eval,
|
||||||
|
unsigned int _nbSol) :
|
||||||
|
moFitnessCloudSampling<Neighbor>(_init, _neighborhood, _fullEval, _eval, _nbSol),
|
||||||
|
neighborFitnessStat(_neighborhood, _eval)
|
||||||
|
{
|
||||||
|
// delete the dummy local search
|
||||||
|
delete localSearch;
|
||||||
|
|
||||||
|
// random sampling
|
||||||
|
localSearch = new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol);
|
||||||
|
|
||||||
|
// one random neighbor
|
||||||
|
add(neighborFitnessStat);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
moNeighborFitnessStat< Neighbor > neighborFitnessStat;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -65,7 +65,7 @@ public:
|
||||||
* @param _monitoring the statistic is saved into the monitor if true
|
* @param _monitoring the statistic is saved into the monitor if true
|
||||||
*/
|
*/
|
||||||
template <class ValueType>
|
template <class ValueType>
|
||||||
moSampling(eoInit<EOT> & _init, moLocalSearch<Neighbor> & _localSearch, moStat<EOT,ValueType> & _stat, bool _monitoring = true) : init(_init), localSearch(_localSearch), continuator(_localSearch.getContinuator())
|
moSampling(eoInit<EOT> & _init, moLocalSearch<Neighbor> & _localSearch, moStat<EOT,ValueType> & _stat, bool _monitoring = true) : init(_init), localSearch(&_localSearch), continuator(_localSearch.getContinuator())
|
||||||
{
|
{
|
||||||
checkpoint = new moCheckpoint<Neighbor>(*continuator);
|
checkpoint = new moCheckpoint<Neighbor>(*continuator);
|
||||||
add(_stat, _monitoring);
|
add(_stat, _monitoring);
|
||||||
|
|
@ -93,7 +93,7 @@ public:
|
||||||
checkpoint->add(_stat);
|
checkpoint->add(_stat);
|
||||||
|
|
||||||
if (_monitoring) {
|
if (_monitoring) {
|
||||||
moVectorMonitor<EOT> * monitor = new moVectorMonitor<EOT>(_stat);
|
moVectorMonitor<EOT> * monitor = new moVectorMonitor<EOT>(_stat); // attention fuite memoire a la descruction !
|
||||||
monitorVec.push_back(monitor);
|
monitorVec.push_back(monitor);
|
||||||
checkpoint->add(*monitor);
|
checkpoint->add(*monitor);
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +109,7 @@ public:
|
||||||
monitorVec[i]->clear();
|
monitorVec[i]->clear();
|
||||||
|
|
||||||
// change the checkpoint to compute the statistics
|
// change the checkpoint to compute the statistics
|
||||||
localSearch.setContinuator(*checkpoint);
|
localSearch->setContinuator(*checkpoint);
|
||||||
|
|
||||||
// the initial solution
|
// the initial solution
|
||||||
EOT solution;
|
EOT solution;
|
||||||
|
|
@ -117,11 +117,13 @@ public:
|
||||||
// initialisation of the solution
|
// initialisation of the solution
|
||||||
init(solution);
|
init(solution);
|
||||||
|
|
||||||
|
std::cout << localSearch->className() << std::endl;
|
||||||
|
|
||||||
// compute the sampling
|
// compute the sampling
|
||||||
localSearch(solution);
|
(*localSearch)(solution);
|
||||||
|
|
||||||
// set back to initial continuator
|
// set back to initial continuator
|
||||||
localSearch.setContinuator(*continuator);
|
localSearch->setContinuator(*continuator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -180,7 +182,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eoInit<EOT> & init;
|
eoInit<EOT> & init;
|
||||||
moLocalSearch<Neighbor> & localSearch;
|
moLocalSearch<Neighbor> * localSearch;
|
||||||
|
|
||||||
moContinuator<Neighbor> * continuator;
|
moContinuator<Neighbor> * continuator;
|
||||||
moCheckpoint<Neighbor> * checkpoint;
|
moCheckpoint<Neighbor> * checkpoint;
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ using namespace std;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// the sampling class
|
// the sampling class
|
||||||
#include <sampling/moFitnessCloudSampling.h>
|
#include <sampling/moRndRndFitnessCloudSampling.h>
|
||||||
#include <sampling/moMHFitnessCloudSampling.h>
|
//#include <sampling/moMHFitnessCloudSampling.h>
|
||||||
|
|
||||||
// Declaration of types
|
// Declaration of types
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -165,8 +165,8 @@ void main_function(int argc, char **argv)
|
||||||
// - neighbor evaluation
|
// - neighbor evaluation
|
||||||
// - number of solutions to sample
|
// - number of solutions to sample
|
||||||
|
|
||||||
//moFitnessCloudSampling<Neighbor> sampling(random, neighborhood, fullEval, neighborEval, nbSol);
|
moRndRndFitnessCloudSampling<Neighbor> sampling(random, neighborhood, fullEval, neighborEval, nbSol);
|
||||||
moMHFitnessCloudSampling<Neighbor> sampling(random, neighborhood, fullEval, neighborEval, nbSol);
|
//moMHFitnessCloudSampling<Neighbor> sampling(random, neighborhood, fullEval, neighborEval, nbSol);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue