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/moNeutralDegreeSampling.h>
|
||||
#include <sampling/moFitnessCloudSampling.h>
|
||||
#include <sampling/moMHFitnessCloudSampling.h>
|
||||
#include <sampling/moRndRndFitnessCloudSampling.h>
|
||||
#include <sampling/moMHRndFitnessCloudSampling.h>
|
||||
|
||||
#include <problems/bitString/moBitNeighbor.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
|
||||
|
||||
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
|
||||
|
|
@ -32,21 +32,21 @@
|
|||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#ifndef moMHFitnessCloudSampling_h
|
||||
#define moMHFitnessCloudSampling_h
|
||||
#ifndef moMHRndFitnessCloudSampling_h
|
||||
#define moMHRndFitnessCloudSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moMetropolisHasting.h>
|
||||
#include <continuator/moFitnessStat.h>
|
||||
#include <continuator/moNeighborFitnessStat.h>
|
||||
#include <sampling/moSampling.h>
|
||||
#include <sampling/moFitnessCloudSampling.h>
|
||||
|
||||
/**
|
||||
* To compute an estimation of the fitness cloud,
|
||||
* i.e. the scatter plot of solution fitness versus neighbor fitness:
|
||||
*
|
||||
* Here solution are sampled with Metropolis-Hasting method
|
||||
*
|
||||
* Sample the fitness of solutions from Metropolis-Hasting sampling
|
||||
|
|
@ -56,12 +56,16 @@
|
|||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moMHFitnessCloudSampling : public moSampling<Neighbor>
|
||||
class moMHRndFitnessCloudSampling : public moFitnessCloudSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
using moSampling<Neighbor>::checkpoint;
|
||||
using moSampling<Neighbor>::monitorVec;
|
||||
using moSampling<Neighbor>::continuator;
|
||||
using moFitnessCloudSampling<Neighbor>::fitnessStat;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
|
|
@ -71,27 +75,36 @@ public:
|
|||
* @param _eval neighbor evaluation, incremental evaluation function
|
||||
* @param _nbStep Number of step of the MH sampling
|
||||
*/
|
||||
moMHFitnessCloudSampling(eoInit<EOT> & _init,
|
||||
moMHRndFitnessCloudSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbStep) :
|
||||
moSampling<Neighbor>(_init, * new moMetropolisHasting<Neighbor>(_neighborhood, _fullEval, _eval, _nbStep), fitnessStat),
|
||||
moFitnessCloudSampling<Neighbor>(_init, _neighborhood, _fullEval, _eval, _nbStep),
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* default destructor
|
||||
*/
|
||||
~moMHFitnessCloudSampling() {
|
||||
// delete the pointer on the local search which has been constructed in the constructor
|
||||
delete &localSearch;
|
||||
}
|
||||
|
||||
protected:
|
||||
moFitnessStat<EOT> fitnessStat;
|
||||
moNeighborFitnessStat< Neighbor > neighborFitnessStat;
|
||||
|
||||
};
|
||||
|
|
@ -60,6 +60,10 @@ public:
|
|||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
using moSampling<Neighbor>::checkpoint;
|
||||
using moSampling<Neighbor>::monitorVec;
|
||||
using moSampling<Neighbor>::continuator;
|
||||
using moFitnessCloudSampling<Neighbor>::fitnessStat;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
|
|
@ -83,6 +87,17 @@ public:
|
|||
// random sampling
|
||||
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
|
||||
add(neighborFitnessStat);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public:
|
|||
checkpoint->add(_stat);
|
||||
|
||||
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);
|
||||
checkpoint->add(*monitor);
|
||||
}
|
||||
|
|
@ -117,8 +117,6 @@ public:
|
|||
// initialisation of the solution
|
||||
init(solution);
|
||||
|
||||
std::cout << localSearch->className() << std::endl;
|
||||
|
||||
// compute the sampling
|
||||
(*localSearch)(solution);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ using namespace std;
|
|||
//-----------------------------------------------------------------------------
|
||||
// the sampling class
|
||||
#include <sampling/moRndRndFitnessCloudSampling.h>
|
||||
//#include <sampling/moMHFitnessCloudSampling.h>
|
||||
#include <sampling/moMHRndFitnessCloudSampling.h>
|
||||
|
||||
// Declaration of types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -165,8 +165,8 @@ void main_function(int argc, char **argv)
|
|||
// - neighbor evaluation
|
||||
// - number of solutions to sample
|
||||
|
||||
moRndRndFitnessCloudSampling<Neighbor> sampling(random, neighborhood, fullEval, neighborEval, nbSol);
|
||||
//moMHFitnessCloudSampling<Neighbor> sampling(random, neighborhood, fullEval, neighborEval, nbSol);
|
||||
// moRndRndFitnessCloudSampling<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