--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/a2d3b69b-ed86-417c-9d4a-debe43fcfde2n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/5909e540-6d25-406e-a1bb-d12b2aa94a55n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/CABcmEeaYHvQw%3D%2BVUag9qjhSQbH-Nx89uKYvo1t%2BtPi_tYFKqUw%40mail.gmail.com.
I tried to write a callback that iterates trough the tours but somehow it cant get the next nodes. I think the problem ist the red marked part.
class solution_found(object):
def __init__(self, model):
self.model = model
self.routing = routing
self.manager = manager
def __call__(self):
print(self.model.CostVar().Min())
tours = []
for vehicle_id in range(data['num_vehicles']):
t = []
print(vehicle_id)
index = self.routing.Start(vehicle_id) #get first node
while not self.routing.IsEnd(index): #append node if not end
node_index = self.manager.IndexToNode(index)
print(node_index)
t.append(node_index)
index = self.routing.NextVar(index) #get next node
print(t)
t.append(self.manager.IndexToNode(index)) #append last node
tours.append(t) #append tour to list of tours
print(tours)
solution_callback = solution_found(routing)
routing.AddAtSolutionCallback(solution_callback)
--
You received this message because you are subscribed to a topic in the Google Groups "or-tools-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/or-tools-discuss/rLjOMvwGZ_I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/9d5c5245-e908-4ba5-9b31-13915e28fb1dn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/000201d74264%24a87d8480%24f9788d80%24%40gmail.com.