Closed rafaelmarques7 closed 6 years ago
The title says solve with ILP, and then you use the CP solver. Therefore, either you use a MIP solver (preferably a good one), or you use the CP constraint (NoCycle in case).
You can also look at the CP-SAT solver (ortools/sat/doc/index.md) with the circuit constraint.
Anyway, the recommended way is to use the routing library that is tailored for this.
Hi rafaelmarques7! Did you manage to solve this issue efficiently? I used your model, converted it to a CP-SAT Model and solved a 42 node Problem, but it took 2h and i need it to be able to solve ~150 nodes. Did you manage to use the circuit contraint correctly or did you find a solution in the routing library?
Hello,
this is not a question regarding a program stack error, but regarding an error about the solution value. Because of this, if this is the wrong forum to place this question, I will remove it.
I am using Google's Operation Research Tools to provide the solvers necessary to solve the time-dependent Traveling Salesman Problem. In order to do so, i follow the Integer Linear formulation for the TDTSP.
Basically, in this formulation, we have a 3-d cost matrix, with the indexes (i,j,t) and a list of decision variables, X, also with three indexes, X(i,j,t) that determine if the solution component x_ijt (the arc connecting cities i and j at the time t) belongs to the solution.
The objective is to minimize the total cost of the trip. The trip has to respect some constraints, that is: each city must be visited exactly once, and we return to the original city.
Below, is a figure representing the ILP forulation and the constraints. (Note: in constraint 5, the negative part of the summ, the index is XJit, and not XIjt)
Below I present my complete code to solve the problem:
furthermore, in order to compare the solution, I used a function that I previously had, which generated a TDTSP instance, with a known optimal solution the code of this function is below.
Note: the solutions generated by the ILP formulation presented, always start and end at node 0. The code I had to generate a random TDTSP instance with a known solution was for a random depot, and I made a slight alteration in order to start always at 0. but i dont believe it influences the results)
The problems I am experiencing are:
1) The solution presented by the ILP solver does not coincide with the optimal solution (the error is of (normaly) one wrong solution component )
2) How do I print the route of the solution? What I am doing now is printing the IntVar which have a 1 value (belonging thus to the solution, which displays something like x0,5,0, where the [0,5,0] means, from city 0 to city 5 at time 0, and the (0..1) are the allowed values for the variable.
I appreciate your help, and I will be available to provide any further feedback.