From 81770b17eebeac56f42a492f9772f23949ed43e2 Mon Sep 17 00:00:00 2001 From: Mizux Seiha Date: Wed, 23 Mar 2022 15:05:45 +0100 Subject: [PATCH] example: add max value collectable to print function --- examples/python/prize_collecting_tsp.py | 4 ++-- examples/python/prize_collecting_tsp_sat.py | 4 ++-- examples/python/prize_collecting_vrp.py | 4 ++-- examples/python/prize_collecting_vrp_sat.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/python/prize_collecting_tsp.py b/examples/python/prize_collecting_tsp.py index 945a5b8f6a..e77d89e353 100755 --- a/examples/python/prize_collecting_tsp.py +++ b/examples/python/prize_collecting_tsp.py @@ -93,7 +93,7 @@ def print_solution(manager, routing, assignment): plan_output += f' {manager.IndexToNode(index)}\n' plan_output += f'Distance of the route: {route_distance}m\n' - plan_output += f'Value collected: {value_collected}\n' + plan_output += f'Value collected: {value_collected}/{sum(VISIT_VALUES)}\n' print(plan_output) @@ -150,7 +150,7 @@ def main(): routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC) search_parameters.local_search_metaheuristic = ( routing_enums_pb2.LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH) - search_parameters.time_limit.FromSeconds(10) + search_parameters.time_limit.FromSeconds(15) #search_parameters.log_search = True # Solve the problem. diff --git a/examples/python/prize_collecting_tsp_sat.py b/examples/python/prize_collecting_tsp_sat.py index 5872950e67..4679abafe7 100755 --- a/examples/python/prize_collecting_tsp_sat.py +++ b/examples/python/prize_collecting_tsp_sat.py @@ -95,7 +95,7 @@ def print_solution(solver, visited_nodes, used_arcs, num_nodes): break plan_output += f' {current_node}\n' plan_output += f'Distance of the route: {route_distance}m\n' - plan_output += f'Value collected: {value_collected}\n' + plan_output += f'Value collected: {value_collected}/{sum(VISIT_VALUES)}\n' print(plan_output) def main(): @@ -152,7 +152,7 @@ def main(): solver = cp_model.CpSolver() # To benefit from the linearization of the circuit constraint. solver.parameters.linearization_level = 2 - solver.parameters.max_time_in_seconds = 10.0 + solver.parameters.max_time_in_seconds = 15.0 #solver.parameters.log_search_progress = True solver.Solve(model) diff --git a/examples/python/prize_collecting_vrp.py b/examples/python/prize_collecting_vrp.py index c945bd5083..5f250a9b85 100755 --- a/examples/python/prize_collecting_vrp.py +++ b/examples/python/prize_collecting_vrp.py @@ -100,7 +100,7 @@ def print_solution(manager, routing, assignment): total_distance += route_distance total_value_collected += value_collected print(f'Total Distance: {total_distance}m') - print(f'Total Value collected: {total_value_collected}') + print(f'Total Value collected: {total_value_collected}/{sum(VISIT_VALUES)}') def main(): @@ -156,7 +156,7 @@ def main(): routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC) search_parameters.local_search_metaheuristic = ( routing_enums_pb2.LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH) - search_parameters.time_limit.FromSeconds(10) + search_parameters.time_limit.FromSeconds(15) #search_parameters.log_search = True # Solve the problem. diff --git a/examples/python/prize_collecting_vrp_sat.py b/examples/python/prize_collecting_vrp_sat.py index 0a917e977a..6a6adc9e3f 100755 --- a/examples/python/prize_collecting_vrp_sat.py +++ b/examples/python/prize_collecting_vrp_sat.py @@ -104,7 +104,7 @@ def print_solution(solver, visited_nodes, used_arcs, num_nodes, num_vehicles): total_distance += route_distance total_value_collected += value_collected print(f'Total Distance: {total_distance}m') - print(f'Total Value collected: {total_value_collected}') + print(f'Total Value collected: {total_value_collected}/{sum(VISIT_VALUES)}') def main(): """Entry point of the program.""" @@ -167,7 +167,7 @@ def main(): solver = cp_model.CpSolver() # To benefit from the linearization of the circuit constraint. solver.parameters.linearization_level = 2 - solver.parameters.max_time_in_seconds = 10.0 + solver.parameters.max_time_in_seconds = 15.0 #solver.parameters.log_search_progress = True solver.Solve(model)