Ok ajout des RndRndFC et MHRndFC
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1794 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
85fa0b461f
commit
a8fa583f3d
5 changed files with 51 additions and 24 deletions
|
|
@ -147,7 +147,8 @@
|
||||||
#include <sampling/moFDCsampling.h>
|
#include <sampling/moFDCsampling.h>
|
||||||
#include <sampling/moNeutralDegreeSampling.h>
|
#include <sampling/moNeutralDegreeSampling.h>
|
||||||
#include <sampling/moFitnessCloudSampling.h>
|
#include <sampling/moFitnessCloudSampling.h>
|
||||||
#include <sampling/moMHFitnessCloudSampling.h>
|
#include <sampling/moRndRndFitnessCloudSampling.h>
|
||||||
|
#include <sampling/moMHRndFitnessCloudSampling.h>
|
||||||
|
|
||||||
#include <problems/bitString/moBitNeighbor.h>
|
#include <problems/bitString/moBitNeighbor.h>
|
||||||
#include <problems/eval/moOneMaxIncrEval.h>
|
#include <problems/eval/moOneMaxIncrEval.h>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
<moMHFitnessCloudSampling.h>
|
<moMHRndFitnessCloudSampling.h>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||||
|
|
||||||
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
|
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
|
||||||
|
|
@ -32,21 +32,21 @@
|
||||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef moMHFitnessCloudSampling_h
|
#ifndef moMHRndFitnessCloudSampling_h
|
||||||
#define moMHFitnessCloudSampling_h
|
#define moMHRndFitnessCloudSampling_h
|
||||||
|
|
||||||
#include <eoInit.h>
|
#include <eoInit.h>
|
||||||
#include <neighborhood/moNeighborhood.h>
|
#include <neighborhood/moNeighborhood.h>
|
||||||
#include <eval/moEval.h>
|
#include <eval/moEval.h>
|
||||||
#include <eoEvalFunc.h>
|
#include <eoEvalFunc.h>
|
||||||
#include <algo/moMetropolisHasting.h>
|
#include <algo/moMetropolisHasting.h>
|
||||||
#include <continuator/moFitnessStat.h>
|
|
||||||
#include <continuator/moNeighborFitnessStat.h>
|
#include <continuator/moNeighborFitnessStat.h>
|
||||||
#include <sampling/moSampling.h>
|
#include <sampling/moFitnessCloudSampling.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To compute an estimation of the fitness cloud,
|
* To compute an estimation of the fitness cloud,
|
||||||
* i.e. the scatter plot of solution fitness versus neighbor fitness:
|
* i.e. the scatter plot of solution fitness versus neighbor fitness:
|
||||||
|
*
|
||||||
* Here solution are sampled with Metropolis-Hasting method
|
* Here solution are sampled with Metropolis-Hasting method
|
||||||
*
|
*
|
||||||
* Sample the fitness of solutions from Metropolis-Hasting sampling
|
* Sample the fitness of solutions from Metropolis-Hasting sampling
|
||||||
|
|
@ -56,12 +56,16 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template <class Neighbor>
|
template <class Neighbor>
|
||||||
class moMHFitnessCloudSampling : public moSampling<Neighbor>
|
class moMHRndFitnessCloudSampling : public moFitnessCloudSampling<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT ;
|
typedef typename Neighbor::EOT EOT ;
|
||||||
|
|
||||||
using moSampling<Neighbor>::localSearch;
|
using moSampling<Neighbor>::localSearch;
|
||||||
|
using moSampling<Neighbor>::checkpoint;
|
||||||
|
using moSampling<Neighbor>::monitorVec;
|
||||||
|
using moSampling<Neighbor>::continuator;
|
||||||
|
using moFitnessCloudSampling<Neighbor>::fitnessStat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
|
|
@ -71,27 +75,36 @@ public:
|
||||||
* @param _eval neighbor evaluation, incremental evaluation function
|
* @param _eval neighbor evaluation, incremental evaluation function
|
||||||
* @param _nbStep Number of step of the MH sampling
|
* @param _nbStep Number of step of the MH sampling
|
||||||
*/
|
*/
|
||||||
moMHFitnessCloudSampling(eoInit<EOT> & _init,
|
moMHRndFitnessCloudSampling(eoInit<EOT> & _init,
|
||||||
moNeighborhood<Neighbor> & _neighborhood,
|
moNeighborhood<Neighbor> & _neighborhood,
|
||||||
eoEvalFunc<EOT>& _fullEval,
|
eoEvalFunc<EOT>& _fullEval,
|
||||||
moEval<Neighbor>& _eval,
|
moEval<Neighbor>& _eval,
|
||||||
unsigned int _nbStep) :
|
unsigned int _nbStep) :
|
||||||
moSampling<Neighbor>(_init, * new moMetropolisHasting<Neighbor>(_neighborhood, _fullEval, _eval, _nbStep), fitnessStat),
|
moFitnessCloudSampling<Neighbor>(_init, _neighborhood, _fullEval, _eval, _nbStep),
|
||||||
neighborFitnessStat(_neighborhood, _eval)
|
neighborFitnessStat(_neighborhood, _eval)
|
||||||
{
|
{
|
||||||
|
// delete the dummy local search
|
||||||
|
delete localSearch;
|
||||||
|
|
||||||
|
// random sampling
|
||||||
|
localSearch = new moMetropolisHasting<Neighbor>(_neighborhood, _fullEval, _eval, _nbStep);
|
||||||
|
|
||||||
|
// delete the checkpoint with the wrong continuator
|
||||||
|
delete checkpoint;
|
||||||
|
|
||||||
|
// set the continuator
|
||||||
|
continuator = localSearch->getContinuator();
|
||||||
|
|
||||||
|
// re-construction of the checkpoint
|
||||||
|
checkpoint = new moCheckpoint<Neighbor>(*continuator);
|
||||||
|
checkpoint->add(fitnessStat);
|
||||||
|
checkpoint->add(*monitorVec[0]);
|
||||||
|
|
||||||
|
// one random neighbor
|
||||||
add(neighborFitnessStat);
|
add(neighborFitnessStat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* default destructor
|
|
||||||
*/
|
|
||||||
~moMHFitnessCloudSampling() {
|
|
||||||
// delete the pointer on the local search which has been constructed in the constructor
|
|
||||||
delete &localSearch;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
moFitnessStat<EOT> fitnessStat;
|
|
||||||
moNeighborFitnessStat< Neighbor > neighborFitnessStat;
|
moNeighborFitnessStat< Neighbor > neighborFitnessStat;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@ -60,6 +60,10 @@ public:
|
||||||
typedef typename Neighbor::EOT EOT ;
|
typedef typename Neighbor::EOT EOT ;
|
||||||
|
|
||||||
using moSampling<Neighbor>::localSearch;
|
using moSampling<Neighbor>::localSearch;
|
||||||
|
using moSampling<Neighbor>::checkpoint;
|
||||||
|
using moSampling<Neighbor>::monitorVec;
|
||||||
|
using moSampling<Neighbor>::continuator;
|
||||||
|
using moFitnessCloudSampling<Neighbor>::fitnessStat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
|
|
@ -83,6 +87,17 @@ public:
|
||||||
// random sampling
|
// random sampling
|
||||||
localSearch = new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol);
|
localSearch = new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol);
|
||||||
|
|
||||||
|
// delete the checkpoint with the wrong continuator
|
||||||
|
delete checkpoint;
|
||||||
|
|
||||||
|
// set the continuator
|
||||||
|
continuator = localSearch->getContinuator();
|
||||||
|
|
||||||
|
// re-construction of the checkpoint
|
||||||
|
checkpoint = new moCheckpoint<Neighbor>(*continuator);
|
||||||
|
checkpoint->add(fitnessStat);
|
||||||
|
checkpoint->add(*monitorVec[0]);
|
||||||
|
|
||||||
// one random neighbor
|
// one random neighbor
|
||||||
add(neighborFitnessStat);
|
add(neighborFitnessStat);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ public:
|
||||||
checkpoint->add(_stat);
|
checkpoint->add(_stat);
|
||||||
|
|
||||||
if (_monitoring) {
|
if (_monitoring) {
|
||||||
moVectorMonitor<EOT> * monitor = new moVectorMonitor<EOT>(_stat); // attention fuite memoire a la descruction !
|
moVectorMonitor<EOT> * monitor = new moVectorMonitor<EOT>(_stat);
|
||||||
monitorVec.push_back(monitor);
|
monitorVec.push_back(monitor);
|
||||||
checkpoint->add(*monitor);
|
checkpoint->add(*monitor);
|
||||||
}
|
}
|
||||||
|
|
@ -117,8 +117,6 @@ 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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ using namespace std;
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// the sampling class
|
// the sampling class
|
||||||
#include <sampling/moRndRndFitnessCloudSampling.h>
|
#include <sampling/moRndRndFitnessCloudSampling.h>
|
||||||
//#include <sampling/moMHFitnessCloudSampling.h>
|
#include <sampling/moMHRndFitnessCloudSampling.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
|
||||||
|
|
||||||
moRndRndFitnessCloudSampling<Neighbor> sampling(random, neighborhood, fullEval, neighborEval, nbSol);
|
// moRndRndFitnessCloudSampling<Neighbor> sampling(random, neighborhood, fullEval, neighborEval, nbSol);
|
||||||
//moMHFitnessCloudSampling<Neighbor> sampling(random, neighborhood, fullEval, neighborEval, nbSol);
|
moMHRndFitnessCloudSampling<Neighbor> sampling(random, neighborhood, fullEval, neighborEval, nbSol);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue