Originally posted by: max__x
Dear AlexFleischer, I cannot find the example you give, since the website of the attached cannot be found.
can you tell me directly ?
my code is:
// Cities
int n = ...;
range cities = 1..n;
range i =1..n;
range j =1..n;
// Edges -- sparse set
tuple edge {int i; int j;}
setof(edge) Edges = {<i,j> | ordered i,j in cities};
int distance[i][j] = ...;
// Decision variables
dvar boolean x[i][j];
tuple Subtour { int size; int subtour[cities]; }
{Subtour} subtours = ...;
// Objective
minimize sum (i in cities, j in cities) distance[i][j]*x[i][j];
subject to {
// Each city is linked with two other cities
forall (j in cities)
flow_in:
sum (i in cities : i!=j) x[i][j] ==1;
forall (i in cities)
flow_out:
sum (j in cities : j!=i) x[i][j] ==1;
// Subtour elimination constraints.
forall (s in subtours)
sum (i in cities : s.subtour[i] != 0)
x[minl(i, s.subtour[i]), maxl(i, s.subtour[i])]
<= s.size-1;
};
Actually I want to solved when n=10, and all the distance between each pair of cities has been defined: distance[i][j]. The problem of this code is said the subtour is not defined, can you tell me how to define it??
#DecisionOptimization#OPLusingCPLEXOptimizer