- Main Page
- Namespaces
- Classes
- Files

- Search for |

# two_opt.cpp

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 // "two_opt.cpp"
    00004
    00005 // (c) OPAC Team, LIFL, 2003-2006
    00006
    00007 /* LICENCE TEXT
    00008
    00009    Contact: paradiseo-help@lists.gforge.inria.fr
    00010 */
    00011
    00012 #include "two_opt.h"
    00013
    00014 TwoOpt TwoOpt :: operator ! () const
    00015 {
    00016   TwoOpt move = * this ;
    00017   std :: swap (move.first, move.second) ;
    00018
    00019   return move ;
    00020 }
    00021
    00022 void TwoOpt :: operator () (Route & __route)
    00023 {
    00024
    00025   std :: vector <unsigned int> seq_cities ;
    00026
    00027   for (unsigned int i = second ; i > first ; i --)
    00028     {
    00029       seq_cities.push_back (__route [i]) ;
    00030     }
    00031
    00032   unsigned int j = 0 ;
    00033   for (unsigned int i = first + 1 ; i < second + 1 ; i ++)
    00034     {
    00035       __route [i] = seq_cities [j ++] ;
    00036     }
    00037 }
    00038
    00039 void TwoOpt :: readFrom (std :: istream & __is)
    00040 {
    00041   __is >> first >> second ;
    00042 }
    00043
    00044 void TwoOpt :: printOn (std :: ostream & __os) const
    00045 {
    00046   __os << first << ' ' << second ;
    00047 }