2-opt a tour . removes 2 edges , then reconstructs a tour . in general from http://en.wikipedia.org/wiki/2-opt : 1 . take route 0 to route i-1 and add them in order to new_route 2 . take route i to route k and add them in reverse order to new_route 3 . take route k +1 to end and add them in order to new_route note that reverse is called with min from , to +1 , max from , to . in a 2-opt move , 2 edges are removed , leaving 2 disconnected sub-tours . either one of these subtours is then reversed and the 2 subtours reconnected in a different shorter way . bentley , in his experiements on tsp heuristics paper notes that since either subtour can be reversed , it is best to reverse the shortest one , otherwise an arbitrary reversal will be n/2 array accesses . this implementation currently reverses whatever subtour does not wrap around - which could be the larger of the two . concode_field_sep PlaceHolder placeHolder concode_field_sep double moveCost concode_elem_sep void activate concode_elem_sep double findMove concode_elem_sep int wrap concode_elem_sep double optimise
void function ( final Point [ ] arg0 , final int arg1 , final int arg2 ) { for ( int loc0 = arg1 , loc1 = arg2 ; loc0 < loc1 ; loc0 ++ , loc1 -- ) { final Point loc2 = arg0 [ loc0 ] ; arg0 [ loc0 ] = arg0 [ loc1 ] ; arg0 [ loc1 ] = loc2 ; } }