Skip to content

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

@worldstar

Description

@worldstar

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];
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions