reset; model tsp1.mod; data germany.dat; #ger_part.dat; #tsp.dat; option solver cplex; param l default 1; # actual node in the cycle set next default {} ordered; # the two neighbours of the actual node set T ordered default V; # temporary set for the remaining nodes param termination default 0; repeat until termination=1 { solve; let subtours := subtours+1; let l := 1; let T := V; printf "%d -> ", l ; # node, also print it. let S[subtours] := S[subtours] union {l}; repeat until (card(T)=1) { # until all nodes are checked let T:= T diff {l}; # remove the node already found let next:={j in T: (l0) then # it is zero only when both neighbours are visited let l := first(next); # take any of them else { printf "end\n"; # we finish with the first cycle let subtours := subtours+1; let l := first(T); # take the next cycle } printf "%d -> ", l ; let S[subtours] := S[subtours] union {l}; if card(S[subtours]) = n then let termination := 1; }; printf "end\n"; # we finish with the last cycle } display _total_solve_time;