cplex-example icon indicating copy to clipboard operation
cplex-example copied to clipboard

How to use the positional index t[i] and t[j] well in the TSP solved by CPLEX?

Open worldstar opened this issue 4 years ago • 0 comments

It is good to see the positional index of t[i] and t[j] is formulated shown in the following link. https://github.com/alberto-santini/cplex-example/blob/master/src/solver.cpp This positional index is able to show the sequence of each node. Because this positional index is not used further in the model, what if we like to use this positional index to calculate the objective function, how could we modify the following code? Thank you.

// Create objective function
for(auto i = 0u; i < n; ++i) {
  for(auto j = 0u; j < n; ++j) {
    expr += g.cost(i, j) * x[i][j];
  }
}

worldstar avatar Mar 15 '20 08:03 worldstar