2

I'm facing trouble in counting linked nodes in Mathprog while trying to solve a quite-big TSP problem: let's say I have

set C  := 0..645;  #  a set of nodes
set A  := {i in  C, j in  C: i!=j};  # a set of edges

a distance function d(c1,c2)

var a{(i,j) in A}, binary;  # binary variables that mean "go through edge i-j"
minimize walk: sum{(i,j) in A} d[i,j] * a[i,j];  # an objective function

and some other conditions

subject to get_out {i in C}: sum{(i,j) in A} a[i,j] = 1; 
subject to get_in  {j in C}: sum{(i,j) in A} a[i,j] = 1;

Making all possible cuts to solve the circuit requires the powerset and some other stuff but on more than 20 nodes the problem is too greedy and I can't get a solution.

So I thought I would constrain the solver to concatenate all a[i,j] imposing

 a[i,j], a[j,k], a[k,w], ..., a[z,i] =1 with i!= {j,k,w,...,z} and j!={k,w,...,z} and ...

which is the same as

 check(a[i,C]) {
   while C is empty 
     take j: a[i,j]=1;
     check( a[j,{C diff {i}}] ) 
 }

which may not lead to a solution but is quite frustrating not to be able to implement such a simple thing... is there a way to implement such pseudo-code in mathprog (gmpl)?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

0 Answers0