tsp fitness has been modified and berlin52 instance has been added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@814 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
e0b82a27d1
commit
f78186ac6f
4 changed files with 84 additions and 29 deletions
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
/*
|
||||
* <part_route_eval.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, Thomas Legrand
|
||||
* Sébastien Cahon, Jean-Charles Boisson
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
|
|
@ -37,22 +37,17 @@
|
|||
#include "part_route_eval.h"
|
||||
#include "graph.h"
|
||||
|
||||
PartRouteEval :: PartRouteEval (float __from,
|
||||
float __to
|
||||
) : from (__from),
|
||||
to (__to) {
|
||||
|
||||
}
|
||||
PartRouteEval :: PartRouteEval (float __from, float __to) : from (__from), to (__to)
|
||||
{}
|
||||
|
||||
void PartRouteEval :: operator () (Route & __route) {
|
||||
|
||||
|
||||
void PartRouteEval :: operator () (Route & __route)
|
||||
{
|
||||
float len = 0 ;
|
||||
|
||||
for (unsigned i = (unsigned) (__route.size () * from) ;
|
||||
i < (unsigned) (__route.size () * to) ;
|
||||
i ++)
|
||||
len -= Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
|
||||
|
||||
|
||||
for (unsigned int i = (unsigned int) (__route.size () * from) ; i < (unsigned int ) (__route.size () * to) ; i ++)
|
||||
{
|
||||
len += Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
|
||||
}
|
||||
|
||||
__route.fitness (len) ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
/*
|
||||
* <route.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, Thomas Legrand
|
||||
* Sébastien Cahon, Jean-Charles Boisson
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
|
|
@ -38,7 +38,11 @@
|
|||
#define route_h
|
||||
|
||||
#include <eoVector.h>
|
||||
#include <eoScalarFitness.h>
|
||||
|
||||
typedef eoVector <float, unsigned> Route ; // [Fitness (- length), Gene (city)]
|
||||
// A float that has to be minimized.
|
||||
typedef eoScalarFitness< float, std::greater<float> > tspFitness ;
|
||||
|
||||
typedef eoVector <tspFitness, unsigned int> Route ; // [Fitness (length), Gene (city)]
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
/*
|
||||
* <route_eval.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, Thomas Legrand
|
||||
* Sébastien Cahon, Jean-Charles Boisson
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
|
|
@ -37,12 +37,15 @@
|
|||
#include "route_eval.h"
|
||||
#include "graph.h"
|
||||
|
||||
void RouteEval :: operator () (Route & __route) {
|
||||
|
||||
float len = 0 ;
|
||||
|
||||
for (unsigned i = 0 ; i < Graph :: size () ; i ++)
|
||||
len -= Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
|
||||
|
||||
void RouteEval :: operator () (Route & __route)
|
||||
{
|
||||
|
||||
float len = 0.0 ;
|
||||
|
||||
for (unsigned int i = 0 ; i < Graph :: size () ; i ++)
|
||||
{
|
||||
len += Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
|
||||
}
|
||||
|
||||
__route.fitness (len) ;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue