27 lines
428 B
Modula-2
27 lines
428 B
Modula-2
param N := 6;
|
|
|
|
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 tsp.dat;
|
|
option solver cplex;
|
|
solve;
|
|
display Total;
|
|
display x;
|
|
display m;
|