tests added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1702 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
44f971d492
commit
3c08dd0157
11 changed files with 260 additions and 9 deletions
|
|
@ -44,6 +44,7 @@
|
|||
/**
|
||||
* Explorer for the Metropolis-Hasting Sampling
|
||||
* Only the symetric case is considered when Q(x,y) = Q(y,x)
|
||||
* Fitness must be > 0
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moMetropolisHastingExplorer : public moNeighborhoodExplorer<Neighborhood>
|
||||
|
|
@ -103,8 +104,6 @@ public:
|
|||
* @param _solution
|
||||
*/
|
||||
virtual void operator()(EOT & _solution){
|
||||
|
||||
//est qu'on peut initializer
|
||||
//Test if _solution has a Neighbor
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
//init the first neighbor
|
||||
|
|
@ -151,11 +150,18 @@ public:
|
|||
isAccept = true;
|
||||
else{
|
||||
if(_solution.fitness() != 0){
|
||||
alpha = (double) current->fitness() / (double) _solution.fitness();
|
||||
if( (double)current->fitness() < (double)_solution.fitness()) // maximizing
|
||||
alpha = (double) current->fitness() / (double) _solution.fitness();
|
||||
else //minimizing
|
||||
alpha = (double) _solution.fitness() / (double) current->fitness();
|
||||
isAccept = (rng.uniform() < alpha) ;
|
||||
}
|
||||
else
|
||||
isAccept = false;
|
||||
else{
|
||||
if( (double)current->fitness() < (double)_solution.fitness()) // maximizing
|
||||
isAccept = true;
|
||||
else
|
||||
isAccept = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isAccept;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
/**
|
||||
* Explorer for a random neutral walk
|
||||
* accept the movement when the neighbor has the same fitnes
|
||||
* To sample the neutral networks by random walk, there is no memory
|
||||
* neighborhood must be explored in random order
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
* A Indexed Neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moIndexNeighborhood : public moNeighborhood<Neighbor>
|
||||
class moIndexNeighborhood : virtual public moNeighborhood<Neighbor>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
|
|||
38
branches/newMo/src/neighborhood/moRndNeighborhood.h
Normal file
38
branches/newMo/src/neighborhood/moRndNeighborhood.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
<moRndNeighborhood.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 _moRndNeighborhood_h
|
||||
#define _moRndNeighborhood_h
|
||||
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
template< class Neighbor >
|
||||
class moRndNeighborhood : virtual public moNeighborhood<Neighbor>{};
|
||||
|
||||
#endif
|
||||
|
|
@ -36,13 +36,14 @@
|
|||
#define _moRndWithReplNeighborhood_h
|
||||
|
||||
#include <neighborhood/moIndexNeighborhood.h>
|
||||
#include <neighborhood/moRndNeighborhood.h>
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
* A Random With replacement Neighborhood
|
||||
*/
|
||||
template< class N >
|
||||
class moRndWithReplNeighborhood : public moIndexNeighborhood<N>
|
||||
class moRndWithReplNeighborhood : public moIndexNeighborhood<N>, public moRndNeighborhood<N>
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -36,13 +36,14 @@
|
|||
#define _moRndWithoutReplNeighborhood_h
|
||||
|
||||
#include <neighborhood/moIndexNeighborhood.h>
|
||||
#include <neighborhood/moRndNeighborhood.h>
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
* A Random without replacement Neighborhood
|
||||
*/
|
||||
template< class N >
|
||||
class moRndWithoutReplNeighborhood : public moIndexNeighborhood<N>
|
||||
class moRndWithoutReplNeighborhood : public moIndexNeighborhood<N>, public moRndNeighborhood<N>
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@
|
|||
#include <neighborhood/moNeighbor.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <neighborhood/moOrderNeighborhood.h>
|
||||
#include <neighborhood/moRndNeighborhood.h>
|
||||
#include <neighborhood/moRndWithoutReplNeighborhood.h>
|
||||
#include <neighborhood/moRndWithReplNeighborhood.h>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue