CSE505/Assignment2/A/tsp.mod
2024-03-09 23:16:18 +08:00

27 lines
432 B
Modula-2

param N := 20;
var m{1..N};
param dist{1..N,1..N} integer > 0;
var x{1..N,1..N} binary;
minimize Total:
sum{ i in 1..N,j in 1..N: i<>j} dist[i,j]* x[i,j];
C1{k in 1..N}: sum{i in 1..N: i <> k} x[i,k] =1;
C2{k in 1..N}: sum{i in 1..N: i <> k} x[k,i] =1;
C3{i in 2..N, j in 2..N: i <> j}: m[i]-m[j]+N*x[i,j]<=N-1;
C4{i in 2..N}: m[i]<=N-1;
data data20.dat;
option solver cplex;
solve;
display Total;
display x;
display m;