example: add max value collectable to print function

This commit is contained in:
Mizux Seiha
2022-03-23 15:05:45 +01:00
parent ffb181590f
commit 81770b17ee
4 changed files with 8 additions and 8 deletions

View File

@@ -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.

View File

@@ -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)

View File

@@ -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.

View File

@@ -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)