Reputation: 145
I am trying to solve small instances of TSP in AMPL. But the subtour elimination constraints are too many even for a small instance. What would be a efficient way to write these constraints in AMPL. thanks
Upvotes: 1
Views: 520
Reputation: 55524
Here's the usual formulation of a set of subtour elimination constraints in AMPL
subj to SubtourElim {k in SS diff {0,2**n-1}}:
sum {i in POW[k], j in S diff POW[k]: (i,j) in LINKS} X[i,j] +
sum {i in POW[k], j in S diff POW[k]: (j,i) in LINKS} X[j,i] >= 2;
taken from http://ampl.com/FAQ/tsp.mod.
Since the number of constraints grows exponentially with n
, instead of adding all of them in advance you can add them dynamically in an AMPL script as described here.
Upvotes: 1