In the TSP, the fitness has to be minimized ... with all the needed modification (for example, moSA.h)

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@587 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jboisson 2007-08-03 14:28:06 +00:00
commit 1d94071693
170 changed files with 748 additions and 837 deletions

View file

@ -31,16 +31,10 @@ template < class M > class moSA:public moAlgo < typename M::EOType >
{
//! Alias for the type
typedef
typename
M::EOType
EOT;
typedef typename M::EOType EOT;
//! Alias for the fitness
typedef
typename
EOT::Fitness
Fitness;
typedef typename EOT::Fitness Fitness;
public:
@ -91,32 +85,38 @@ public:
EOT best_sol = __sol;
Fitness current_fitness, delta;
double exp1, exp2;
do
{
cont.init ();
do
{
move_rand (move);
Fitness delta_fit = incr_eval (move, __sol) - __sol.fitness ();
current_fitness= incr_eval (move, __sol);
if (delta_fit > 0 || rng.uniform () < exp (delta_fit / temp))
delta = current_fitness - __sol.fitness();
if(((long double)delta) < 0.0)
{
__sol.fitness (incr_eval (move, __sol));
move (__sol);
/* Updating the best solution found
until now ? */
if (__sol.fitness () > best_sol.fitness ())
best_sol = __sol;
delta=-delta;
}
if ((current_fitness > __sol.fitness()) || ((rng.uniform ()) < (exp (-delta/ temp))))
{
__sol.fitness (current_fitness);
move (__sol);
/* Updating the best solution found until now ? */
if (__sol.fitness () > best_sol.fitness ())
{
best_sol = __sol;
}
}
}
while (cont (__sol));
}
while (cool_sched (temp));