From e3f500947b1d75dc8fe9fd784acdd88fe06c6557 Mon Sep 17 00:00:00 2001 From: Muhammad Musa <47291629+MoosaSaadat@users.noreply.github.com> Date: Fri, 15 May 2020 14:37:44 +0500 Subject: [PATCH] Register dimension callback as unary (#2020) cvrptw_plot.py: Demand callback should use RegisterUnaryTransitCallback(). --- examples/python/cvrptw_plot.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/python/cvrptw_plot.py b/examples/python/cvrptw_plot.py index 728ecfeeef..074cd5ea34 100644 --- a/examples/python/cvrptw_plot.py +++ b/examples/python/cvrptw_plot.py @@ -287,14 +287,13 @@ class Customers(): Return a callback function that gives the demands. Returns: - function: dem_return(a,b) A function that takes the 'from' node - index and the 'to' node index and returns the distance in km. + function: dem_return(a) A function that takes the 'from' node + index and returns the distance in km. """ - def dem_return(from_index, to_index): + def dem_return(from_index): # Convert from routing variable Index to distance matrix NodeIndex. from_node = self.manager.IndexToNode(from_index) - to_node = self.manager.IndexToNode(to_index) return (self.customers[from_node].demand) return dem_return @@ -641,7 +640,7 @@ def main(): dist_fn_index = routing.RegisterTransitCallback(dist_fn) dem_fn = customers.return_dem_callback() - dem_fn_index = routing.RegisterTransitCallback(dem_fn) + dem_fn_index = routing.RegisterUnaryTransitCallback(dem_fn) # Create and register a transit callback. serv_time_fn = customers.make_service_time_call_callback()