Commit 4648a50a authored by Adrian Bürger's avatar Adrian Bürger
Browse files

added tsp.mod

parent bb7358c8
set S ordered;
param n := card {S};
set SS := 1..(2^n - 2); # 1 to number of subtours
set POW {k in SS} := {i in S: (k div 2^(ord(i)-1)) mod 2 = 1}; # subtours
set LINKS := {i in S, j in S: ord(i) < ord(j)};
param cost {LINKS} >= 0;
var x {LINKS} binary;
minimize tot_cost: sum {(i,j) in LINKS} cost[i,j] * x[i,j];
s.t. tour: sum {(i,j) in LINKS} x[i,j] = n;
s.t. subtour_elim {k in SS : 3 <= card{POW[k]} <= n-1}:
sum {i in POW[k], j in POW[k]: (i,j) in LINKS} x[i,j] <= card{POW[k]}-1;
data toy.dat;
#data 10city.dat;
#data 12city.dat;
#display SS;
#display POW;
#option solver cplex;
#display x;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment