début des travaux sur les populations

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1837 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-06-04 13:06:35 +00:00
commit 585d90b082
7 changed files with 246 additions and 22 deletions

View file

@ -0,0 +1,44 @@
/** @mainpage Welcome to ParadisEO-MO
@section Introduction
ParadisEO-MO is a white-box object-oriented generic framework dedicated to the flexible design of local search algorithms.
@section LICENSE
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
*/
/** @page webpages Related webpages
- ParadisEO <a href="http://paradiseo.gforge.inria.fr">homepage</a>
- INRIA GForge <a href="http://gforge.inria.fr/projects/paradiseo/">project page</a>
- <a href="../../README">README</a>
*/

View file

@ -1,4 +1,4 @@
/*
/*
<moFullEvalByCopy.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010

View file

@ -40,6 +40,8 @@
/**
* Full evaluation to use with a moBackableNeighbor
* !!!WARNING!!! Use only when your solution is composed by a fitness Value and a "genotype"
*
*/
template<class BackableNeighbor>
class moFullEvalByModif : public moEval<BackableNeighbor>
@ -64,7 +66,6 @@ public:
// tmp fitness value of the current solution
Fitness tmpFit;
// save current fitness value
tmpFit = _sol.fitness();

View file

@ -40,12 +40,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Neighbor related to a vector of Bit
*/
template< class Fitness >
class moPopBitNeighbor : public moBackableNeighbor< moPopSol<eoBit<Fitness> > >, public moIndexNeighbor< moPopSol<eoBit<Fitness> > >
class moPopBitNeighbor : public moIndexNeighbor< moPopSol<eoBit<Fitness> > >
{
public:
typedef moPopSol<eoBit<Fitness> > EOT ;
typedef eoBit<Fitness> SUBEOT;
using moBackableNeighbor<EOT>::fitness;
using moIndexNeighbor<EOT>::fitness;
using moIndexNeighbor<EOT>::key;
/**
@ -53,23 +54,18 @@ public:
* @param _solution the solution to move
*/
virtual void move(EOT & _solution) {
if(_solution.size()>0){
size=_solution[0].size();
_solution[key/size][key%size] = !_solution[key/size][key%size];
// fit=_solution[key/size].fitness();
_solution[key/size].invalidate();
// fitSol=_solution.fitness();
if(_solution[0].size()>0){
unsigned size=_solution[0].size();
unsigned s = key/size;
unsigned b = key%size;
_solution[s][b] = !_solution[s][b];
_solution[s].fitness(subfit);
_solution.invalidate();
}
}
/**
* move back the solution (useful for the evaluation by modif)
* @param _solution the solution to move back
*/
virtual void moveBack(EOT & _solution) {
_solution[key/size][key%size] = !_solution[key/size][key%size];
// _solution[key/size].fitness(fit);
void setSubFit(Fitness _subfit){
subfit=_subfit;
}
/**
@ -113,7 +109,7 @@ public:
}
private:
unsigned int size;
Fitness subfit;
};
#endif

View file

@ -0,0 +1,85 @@
/*
<moPopBitEval.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 moPopBitEval_H
#define moPopBitEval_H
#include <eoFunctor.h>
#include <eval/moEval.h>
/**
* Abstract class for the evaluation
*/
template<class Neighbor>
class moPopBitEval : public moEval<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
typedef typename Neighbor::SUBEOT SUBEOT;
typedef typename EOT::Fitness Fitness;
moPopBitEval(eoEvalFunc<SUBEOT>& _eval, unsigned int _p):eval(_eval), p(_p){
}
void operator()(EOT& _sol, Neighbor& _n){
if(_sol[0].size()>0){
unsigned int size=_sol[0].size();
unsigned int s=_n.index()/size;
unsigned int b=_n.index()%size;
subfit=_sol[s].fitness();
_sol[s][b]=!_sol[s][b];
_sol[s].invalidate();
eval(_sol[s]);
double fit=0;
for (unsigned int i = 0; i < _sol.size(); i++){
fit+=pow(_sol[i].fitness(), p);
}
fit=pow(fit, (double)1/p);
_n.setSubFit(_sol[s].fitness());
_n.fitness(fit);
_sol[s][b]=!_sol[s][b];
_sol[s].fitness(subfit);
}
}
private:
eoEvalFunc<SUBEOT> & eval;
unsigned int p;
Fitness subfit;
};
#endif

View file

@ -0,0 +1,95 @@
/*
<moPopFitContinuator.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 _moPopFitContinuator_h
#define _moPopFitContinuator_h
#include <continuator/moContinuator.h>
/**
* Termination condition until a running time is reached.
*/
template < class Neighbor >
class moPopFitContinuator: public moContinuator<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
typedef typename EOT::Fitness Fitness;
/**
* Constructor
* @param _fit fitness to reach
* @param _verbose verbose mode true/false -> on/off
*/
moPopFitContinuator(Fitness _fit, bool _verbose=true): fit(_fit), verbose(_verbose) {}
/**
* Returns false when the running time is reached.
* @param _sol the current solution
*/
virtual bool operator() (EOT& _sol)
{
unsigned int i=0;
bool res=true;
while (res && i<_sol.size()){
res= (_sol[i].fitness() < fit);
i++;
}
if (!res && verbose)
std::cout << "STOP in moPopFitContinuator: Reached maximum fitness [" << fit << "]" << std::endl;
return res;
}
/**
* reset the start time
* @param _solution a solution
*/
virtual void init(EOT & _solution) {}
/**
* Class name
*/
virtual std::string className(void) const
{
return "moPopFitContinuator";
}
private:
Fitness fit;
/** verbose mode */
bool verbose;
};
#endif

View file

@ -52,7 +52,7 @@ using namespace std;
// fitness function
#include <eval/oneMaxPopEval.h>
#include <eval/moFullEvalByModif.h>
#include <problems/eval/moPopBitEval.h>
//Neighbors and Neighborhoods
#include <problems/bitString/moPopBitNeighbor.h>
@ -72,6 +72,8 @@ using namespace std;
#include <utils/eoFileMonitor.h>
#include <continuator/moCounterMonitorSaver.h>
#include "moPopFitContinuator.h"
//-----------------------------------------------------------------------------
// Define types of the representation solution, different neighbors and neighborhoods
@ -100,7 +102,7 @@ void main_function(int argc, char **argv)
unsigned seed = seedParam.value();
// description of genotype
eoValueParam<unsigned int> vecSizeParam(4, "vecSize", "Genotype size", 'V');
eoValueParam<unsigned int> vecSizeParam(8, "vecSize", "Genotype size", 'V');
parser.processParam( vecSizeParam, "Representation" );
unsigned vecSize = vecSizeParam.value();
@ -174,7 +176,7 @@ void main_function(int argc, char **argv)
*
* ========================================================= */
moFullEvalByModif<Neighbor> moEval(popEval);
moPopBitEval<Neighbor> evalNeighbor(eval,2);
// Neighbor n;
//
@ -196,6 +198,7 @@ void main_function(int argc, char **argv)
Neighborhood neighborhood(vecSize*popSize);
moPopFitContinuator<Neighbor> cont(vecSize);
/* =========================================================
*
@ -203,7 +206,7 @@ void main_function(int argc, char **argv)
*
* ========================================================= */
moSimpleHC<Neighbor> ls(neighborhood, popEval, moEval);
moSimpleHC<Neighbor> ls(neighborhood, popEval, evalNeighbor, cont);
/* =========================================================
*