Closed vilumaa closed 2 years ago
the max_time_in_vehicle is the max waiting time not including transit between 2 visits
see: https://developers.google.com/optimization/routing/dimensions
Are you saying that the "each parcel can only spend at most 45 minutes in a vehicle (max_time_in_vehicle)" constraint implementation is incorrect? I believe I have seen this in the forums before, including here
Nevertheless, even commenting out that constraint, I still get a solution:
{0: [(0, 0, 0), (3, 0, 1015), (1, 0, 1015), (4, 1015, 1015), (2, 1015, 1015)], 'unperformed': []}
Implying the driving time between nodes 4 and 2 is 0, yet when I look at the time_matrix
it's 150. Or am I misinterpreting the output time windows obtained by assignment.Max(time_var)
?
Moreover, by adding a solution callback, and recording the best objective found during the search, I can see that the solution callback has never been triggered. Yet, it does return a "feasible" solution...
class SolutionCallback:
"""Solution callback for debugging"""
def __init__(self, model):
self.model = model
self.best_objective = float("inf")
def __call__(self):
if self.model.CostVar().Max() < self.best_objective:
self.best_objective = self.model.CostVar().Max()
solution_callback = SolutionCallback(routing)
routing.AddAtSolutionCallback(solution_callback)
Output:
Objective from assignment.ObjectiveValue(): 500
Objective from callback = inf
{0: [(0, 0, 0), (3, 0, 1015), (1, 0, 1015), (4, 1015, 1015), (2, 1015, 1015)], 'unperformed': []}
the code uses max_time_PER_vehicle, which is 50k.
Version: 9.2.9972 Language: Python 3.9.7 Routing solver Windows 10
Runnable python script:
Expect no solution since max_time_in_vehicle=45 but each pickup/dropoff pair in time_matrix > 45.
Instead, I get a "feasible" solution that clearly violates travel time:
{0: [(0, 0, 0), (3, 970, 1015), (1, 970, 1015), (4, 1015, 1015), (2, 1015, 1015)], 'unperformed': []}
Where dict key is vehicle (0), and tuples are (node_id, time_var.Min(), time_var.Max()).Am I wrong in expecting that
if assignment:
will only trigger when there is a feasible solution?