Ajout de continuators, et de moEvalCounter
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1763 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
1ff0a50b86
commit
40deede883
8 changed files with 427 additions and 2 deletions
87
trunk/paradiseo-mo/src/continuator/moCombinedContinuator.h
Normal file
87
trunk/paradiseo-mo/src/continuator/moCombinedContinuator.h
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
<moCombinedContinuator.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 _moCombinedContinuator_h
|
||||
#define _moCombinedContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
/**
|
||||
* Combined several continuators
|
||||
* Continue until one of the continuators is false
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moCombinedContinuator : public moContinuator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* @param _maxFit maximum fitness to reach
|
||||
*/
|
||||
moCombinedContinuator(Fitness _maxFit): maxFit(_maxFit){}
|
||||
|
||||
/**
|
||||
* Default constructor (moCheckpoint must have at least one continuator)
|
||||
* @param _cont a continuator
|
||||
*/
|
||||
moCombinedContinuator(moContinuator<Neighbor>& _cont) : {
|
||||
continuators.push_back(&_cont);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a continuator to the combined continuator
|
||||
* @param _cont a continuator
|
||||
*/
|
||||
void add(moContinuator<Neighbor>& _cont) {
|
||||
continuators.push_back(&_cont);
|
||||
}
|
||||
|
||||
/**
|
||||
*@param _solution a solution
|
||||
*@return true all the continuators are true
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
bool bContinue = true;
|
||||
|
||||
// some data may be update in each continuator.
|
||||
// So, all continuators are tested
|
||||
for(unsigned int i = 0; i < continuators.size(); ++i)
|
||||
if ( !(*continuators[i])(_sol) )
|
||||
bContinue = false;
|
||||
|
||||
return bContinue;
|
||||
}
|
||||
|
||||
private:
|
||||
/** continuators vector */
|
||||
std::vector<moContinuator<Neighbor>*> continuators;
|
||||
|
||||
};
|
||||
#endif
|
||||
62
trunk/paradiseo-mo/src/continuator/moFitContinuator.h
Normal file
62
trunk/paradiseo-mo/src/continuator/moFitContinuator.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
<moFitContinuator.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 _moFitContinuator_h
|
||||
#define _moFitContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
/**
|
||||
* Continue until a maximum fitness is reached
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moFitContinuator : public moContinuator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
/**
|
||||
* @param _maxFit maximum fitness to reach
|
||||
*/
|
||||
moFitContinuator(Fitness _maxFit): maxFit(_maxFit){}
|
||||
|
||||
/**
|
||||
*@param _solution a solution
|
||||
*@return true if counter < maxFit
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
return (_solution.fitness() < maxFit);
|
||||
}
|
||||
|
||||
private:
|
||||
Fitness maxFit;
|
||||
|
||||
};
|
||||
#endif
|
||||
75
trunk/paradiseo-mo/src/continuator/moFullEvalContinuator.h
Normal file
75
trunk/paradiseo-mo/src/continuator/moFullEvalContinuator.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
<moFullEvalContinuator.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 _moFullEvalContinuator_h
|
||||
#define _moFullEvalContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eoEvalFuncCounter.h>
|
||||
|
||||
/**
|
||||
* Continue until a maximum fixed number of full evaluation is reached
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moFullEvalContinuator : public moContinuator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
* @param _eval evaluation function to count
|
||||
* @param _maxFullEval number maximum of iterations
|
||||
*/
|
||||
moFullEvalContinuator(eoEvalFuncCounter<EOT> & _eval, unsigned int _maxFullEval): maxFullEval(_maxFullEval){}
|
||||
|
||||
/**
|
||||
* Test if continue
|
||||
*@param _solution a solution
|
||||
*@return true if number of evaluations < maxFullEval
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
return (eval.value() < maxFullEval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the number of evaluations
|
||||
* @param _solution a solution
|
||||
*/
|
||||
virtual void init(EOT & _solution) {
|
||||
eval.value() = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
eoEvalFuncCounter<EOT> & eval;
|
||||
unsigned int maxFullEval;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
<moNeighborEvalContinuator.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 _moNeighborEvalContinuator_h
|
||||
#define _moNeighborEvalContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eval/moEvalCounter.h>
|
||||
|
||||
/**
|
||||
* Continue until a maximum fixed number of neighbor evaluation is reached
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moNeighborEvalContinuator : public moContinuator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
* @param _eval neighbor evaluation function to count
|
||||
* @param _maxNeighborEval number maximum of iterations
|
||||
*/
|
||||
moNeighborEvalContinuator(moEvalCounter<Neighbor> & _eval, unsigned int _maxNeighborEval): maxNeighborEval(_maxNeighborEval){}
|
||||
|
||||
/**
|
||||
* Test if continue
|
||||
*@param _solution a solution
|
||||
*@return true if number of evaluations < maxNeighborEval
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
return (eval.value() < maxNeighborEval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the number of evaluations
|
||||
* @param _solution a solution
|
||||
*/
|
||||
virtual void init(EOT & _solution) {
|
||||
eval.value() = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
moEvalCounter<Neighbor> & eval;
|
||||
unsigned int maxNeighborEval;
|
||||
|
||||
};
|
||||
#endif
|
||||
66
trunk/paradiseo-mo/src/eval/moEvalCounter.h
Normal file
66
trunk/paradiseo-mo/src/eval/moEvalCounter.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
<moEvalCounter.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 _moEvalCounter_h
|
||||
#define _moEvalCounter_h
|
||||
|
||||
#include <eval/moEval.h>
|
||||
#include <utils/eoParam.h>
|
||||
|
||||
/**
|
||||
Counts the number of neighbor evaluations actually performed, thus checks first
|
||||
if it has to evaluate.. etc.
|
||||
*/
|
||||
template<class Neighbor>
|
||||
class moEvalCounter : public moEval<Neighbor>, public eoValueParam<unsigned long>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
moEvalCounter(moEval<Neighbor>& _eval, std::string _name = "Neighbor Eval. ")
|
||||
: eoValueParam<unsigned long>(0, _name), eval(_eval) {}
|
||||
|
||||
/**
|
||||
* Increase the number of neighbor evaluations and perform the evaluation
|
||||
*
|
||||
* @param _solution a solution
|
||||
* @param _neighbor a neighbor
|
||||
*/
|
||||
void operator()(EOT& _solution, Neighbor& _neigbor) {
|
||||
value()++;
|
||||
eval(_solution, _neighbor);
|
||||
}
|
||||
|
||||
private:
|
||||
moEval<Neighbor> & eval;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -65,11 +65,16 @@
|
|||
#include <continuator/moStatBase.h>
|
||||
#include <continuator/moTrueContinuator.h>
|
||||
#include <continuator/moIterContinuator.h>
|
||||
#include <continuator/moFitContinuator.h>
|
||||
#include <continuator/moCombinedContinuator.h>
|
||||
#include <continuator/moFullEvalContinuator.h>
|
||||
#include <continuator/moNeighborEvalContinuator.h>
|
||||
|
||||
#include <eval/moEval.h>
|
||||
#include <eval/moFullEvalByCopy.h>
|
||||
#include <eval/moFullEvalByModif.h>
|
||||
#include <eval/moDummyEval.h>
|
||||
#include <eval/moEvalCounter.h>
|
||||
|
||||
#include <explorer/moFirstImprHCexplorer.h>
|
||||
#include <explorer/moNeutralHCexplorer.h>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public:
|
|||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/*
|
||||
* incremental evaluation of the solution for the oneMax problem
|
||||
* incremental evaluation of the neighbor for the oneMax problem
|
||||
* @param _solution the solution to move (bit string)
|
||||
* @param _neighbor the neighbor to consider (of type moBitNeigbor)
|
||||
*/
|
||||
|
|
@ -51,7 +51,7 @@ public:
|
|||
_neighbor.fitness(_solution.fitness() + 1);
|
||||
else
|
||||
_neighbor.fitness(_solution.fitness() - 1);
|
||||
};
|
||||
}g
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
55
trunk/paradiseo-mo/src/problems/eval/oneMaxFullEval.h
Normal file
55
trunk/paradiseo-mo/src/problems/eval/oneMaxFullEval.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
<oneMaxFullEval.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 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 _oneMaxFullEval_h
|
||||
#define _oneMaxFullEval_h
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
/**
|
||||
* Fitness function (full evaluation) for the OneMax problem
|
||||
*/
|
||||
template< class EOT >
|
||||
class oneMaxFullEval : public eoEvalFunc<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Count the number of 1 in a bitString
|
||||
* @param _sol the solution to evaluate
|
||||
*/
|
||||
void operator() (EOT& _sol) {
|
||||
unsigned int sum = 0;
|
||||
for (unsigned int i = 0; i < _sol.size(); i++)
|
||||
sum += _sol[i];
|
||||
_sol.fitness(sum);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue