Home / Computer science / Traveling salesman problem (TSP) / Computation: Python, SAT + NN, permutation
Objective
Minimize the tour length.
\begin{align*} y = \sum_{i = 1}^{n - 1} d_{x_i, x_{i + 1}} + d_{x_n, x_1} \end{align*}N.B.
- Indexing
dwithx[i]must be done withadd_element. - Indexing
dwithadd_elementrequires flattening ofd.
# Set the objective function.
model.minimize(sum(t))