Pinned topic TSP  subtour elimination constraints
I have a problem for the input data to the following problem:
http://pic.dhe.ibm.com/infocenter/oplinfoc/v6r3/topic/ilog.odms.ide.help/examples/html/opl/models/TravelingSalesmanProblem/tsp.mod.html
It is a TSP formulation from the OPL samples.
My doubt is how the data of the instance should be written for the tuple:
034: tuple Subtour { int size; int subtourCities; }
035: {Subtour} subtours = ...;
This tuple is related to the subtour elimination constraints.
If you have any TSP.dat, it would be very useful.
Thanks
Stefano

Re: TSP  subtour elimination constraints
20120525T16:50:07ZThis is the accepted answer. This is the accepted answer.Hello
In the sample, the subtours are initially set to an empty collection in the params.dat file. Then subtours are detected in the postProcess and we keep the smallest subtour and resolves the model.
You can display the last subtour added to the MIP
dat.subtours.add(opl.newSubtourSize, opl.newSubtour); writeln( "Last subtour added : ",Opl.last(dat.subtours)); //add this to display the last subtour
For instance, the first subtour is
<3 [0 0 14 0 0 0 0 0 0 0 0 0 0 15 3 0 0]>
which means that we have found a subtour of 3 cities, namely cities 3 (with successor 14) ,14 (with successor 15) and 15 (with successor 3)
If you want to add initial known subtours, you can set additional sets in params.dat
David 
Re: TSP  subtour elimination constraints
20121224T08:05:48ZThis is the accepted answer. This is the accepted answer. davidoff
 20120525T16:50:07Z
Hello
In the sample, the subtours are initially set to an empty collection in the params.dat file. Then subtours are detected in the postProcess and we keep the smallest subtour and resolves the model.
You can display the last subtour added to the MIP
<pre class="jivepre">dat.subtours.add(opl.newSubtourSize, opl.newSubtour); writeln( "Last subtour added : ",Opl.last(dat.subtours)); //add this to display the last subtour
</pre>
For instance, the first subtour is
<pre class="jivepre"><3 [0 0 14 0 0 0 0 0 0 0 0 0 0 15 3 0 0]>
</pre>
which means that we have found a subtour of 3 cities, namely cities 3 (with successor 14) ,14 (with successor 15) and 15 (with successor 3)
If you want to add initial known subtours, you can set additional sets in params.dat
David
sum (i in Cities : s.subtour[i] != 0)
x[<minl(i, s.subtour[i]), maxl(i, s.subtouri])>
<= s.size1;
excuse me, i have some questions obout the code obve. Could you some explainnation about how the constraints make effects on the TSP problem.
I would aprreciate your help very much. 
Re: TSP  subtour elimination constraints
20150113T21:39:23ZThis is the accepted answer. This is the accepted answer. davidoff
 20120525T16:50:07Z
Hello
In the sample, the subtours are initially set to an empty collection in the params.dat file. Then subtours are detected in the postProcess and we keep the smallest subtour and resolves the model.
You can display the last subtour added to the MIP
<pre class="jivepre">dat.subtours.add(opl.newSubtourSize, opl.newSubtour); writeln( "Last subtour added : ",Opl.last(dat.subtours)); //add this to display the last subtour
</pre>
For instance, the first subtour is
<pre class="jivepre"><3 [0 0 14 0 0 0 0 0 0 0 0 0 0 15 3 0 0]>
</pre>
which means that we have found a subtour of 3 cities, namely cities 3 (with successor 14) ,14 (with successor 15) and 15 (with successor 3)
If you want to add initial known subtours, you can set additional sets in params.dat
DavidHello, David
I have the same problems as Stefano,
does this what you mean here ?
tuple subtour { int size;int subtour[cities]; }{Subtour} subtours = ...;dat.subtours.add(opl.newSubtourSize, opl.newSubtour); writeln("Last subtour added : ",Opl.last(dat.subtours));and set the initial subset to be empty?
Is the code used in CPLEX?
because there still some mistake in the code. such as the unexpected "." after dat and writeln I bold.

Re: TSP  subtour elimination constraints
20150114T14:24:26ZThis is the accepted answer. This is the accepted answer. max__x
 20150113T21:39:23Z
Hello, David
I have the same problems as Stefano,
does this what you mean here ?
tuple subtour { int size;int subtour[cities]; }{Subtour} subtours = ...;dat.subtours.add(opl.newSubtourSize, opl.newSubtour); writeln("Last subtour added : ",Opl.last(dat.subtours));and set the initial subset to be empty?
Is the code used in CPLEX?
because there still some mistake in the code. such as the unexpected "." after dat and writeln I bold.
same thread at https://www.ibm.com/developerworks/community/forums/html/topic?id=45075e99c6b9447f94da4b8124f0662c&ps=25