Originally posted by: JorisK
The common way to implement this problem is as follows:
1. Define an interval variable for every city. Designate one of the cities the 'starting city'. Introduce a copy of this city as the 'ending city'. So a tsp solution would be: [start_city, 3,2,4,5, end_city]. In this example, the distance from city 5 to end_city would be equal to the distance from 5 to the start_city.
2. Create a no-overlap sequence of the interval variables. This constraint also takes a matrix containing the distances between every city. Use 'first(start_city,seq)' and 'last(start_city,seq)' constraints to enforce that these 2 interval variables are resp the first and last in your sequence.
3. Specify the objective function: minimize endOf(end_city)
#CPOptimizer#DecisionOptimization