git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@88 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
055b0ff739
commit
81871bb536
74 changed files with 91611 additions and 0 deletions
42
trunk/paradiseo-mo/tutorial/examples/tsp/src/two_opt.cpp
Normal file
42
trunk/paradiseo-mo/tutorial/examples/tsp/src/two_opt.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// "two_opt.cpp"
|
||||
|
||||
// (c) OPAC Team, LIFL, 2003-2006
|
||||
|
||||
/* LICENCE TEXT
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include "two_opt.h"
|
||||
|
||||
TwoOpt TwoOpt :: operator ! () const {
|
||||
|
||||
TwoOpt move = * this ;
|
||||
std :: swap (move.first, move.second) ;
|
||||
|
||||
return move ;
|
||||
}
|
||||
|
||||
void TwoOpt :: operator () (Route & __route) {
|
||||
|
||||
std :: vector <unsigned> seq_cities ;
|
||||
|
||||
for (unsigned i = second ; i > first ; i --)
|
||||
seq_cities.push_back (__route [i]) ;
|
||||
|
||||
unsigned j = 0 ;
|
||||
for (unsigned i = first + 1 ; i < second + 1 ; i ++)
|
||||
__route [i] = seq_cities [j ++] ;
|
||||
}
|
||||
|
||||
void TwoOpt :: readFrom (std :: istream & __is) {
|
||||
|
||||
__is >> first >> second ;
|
||||
}
|
||||
|
||||
void TwoOpt :: printOn (std :: ostream & __os) const {
|
||||
|
||||
__os << first << ' ' << second ;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue