parameters: (manager, routing, assignment)
docstring: Prints solution on console.
docstring_summary: Prints solution on console.
docstring_tokens: Prints solution on console .
function: def print_solution(manager, routing, assignment):
      """Prints solution on console."""
      print(f'Objective: {assignment.ObjectiveValue()}')
      # Display dropped nodes.
      dropped_nodes = 'Dropped nodes:'
      for index in range(routing.Size()):
          if routing.IsStart(index) or routing.IsEnd(index):
              continue
          if assignment.Value(routing.NextVar(index)) == index:
              node = manager.IndexToNode(index)
              if node > 16:
                original = node
                while original > 16:
                  original = original - 16
                dropped_nodes += f' {node}({original})'
              else:
                dropped_nodes += f' {node}'
      print(dropped_nodes)
      # Display routes
      time_dimension = routing.GetDimensionOrDie('Time')
      total_time = 0
      for vehicle_id in range(manager.GetNumberOfVehicles()):
          plan_output = f'Route for vehicle {vehicle_id}:\n'
          index = routing.Start(vehicle_id)
          start_time = 0
          while not routing.IsEnd(index):
              time_var = time_dimension.CumulVar(index)
              node = manager.IndexToNode(index)
              if node > 16:
                original = node
                while original > 16:
                  original = original - 16
                plan_output += f'{node}({original})'
              else:
                plan_output += f'{node}'
              plan_output += f' Time:{assignment.Value(time_var)} -> '
              if start_time == 0:
                  start_time = assignment.Value(time_var)
              index = assignment.Value(routing.NextVar(index))
          time_var = time_dimension.CumulVar(index)
          node = manager.IndexToNode(index)
          plan_output += f'{node} Time:{assignment.Value(time_var)}\n'
          end_time = assignment.Value(time_var)
          duration = end_time - start_time
          plan_output += f'Duration of the route:{duration}min\n'
          print(plan_output)
          total_time += duration
      print(f'Total duration of all routes: {total_time}min')
function_tokens: def print_solution ( manager , routing , assignment ) : print ( f'Objective: {assignment.ObjectiveValue()}' ) # Display dropped nodes. dropped_nodes = 'Dropped nodes:' for index in range ( routing . Size ( ) ) : if routing . IsStart ( index ) or routing . IsEnd ( index ) : continue if assignment . Value ( routing . NextVar ( index ) ) == index : node = manager . IndexToNode ( index ) if node > 16 : original = node while original > 16 : original = original - 16 dropped_nodes += f' {node}({original})' else : dropped_nodes += f' {node}' print ( dropped_nodes ) # Display routes time_dimension = routing . GetDimensionOrDie ( 'Time' ) total_time = 0 for vehicle_id in range ( manager . GetNumberOfVehicles ( ) ) : plan_output = f'Route for vehicle {vehicle_id}:\n' index = routing . Start ( vehicle_id ) start_time = 0 while not routing . IsEnd ( index ) : time_var = time_dimension . CumulVar ( index ) node = manager . IndexToNode ( index ) if node > 16 : original = node while original > 16 : original = original - 16 plan_output += f'{node}({original})' else : plan_output += f'{node}' plan_output += f' Time:{assignment.Value(time_var)} -> ' if start_time == 0 : start_time = assignment . Value ( time_var ) index = assignment . Value ( routing . NextVar ( index ) ) time_var = time_dimension . CumulVar ( index ) node = manager . IndexToNode ( index ) plan_output += f'{node} Time:{assignment.Value(time_var)}\n' end_time = assignment . Value ( time_var ) duration = end_time - start_time plan_output += f'Duration of the route:{duration}min\n' print ( plan_output ) total_time += duration print ( f'Total duration of all routes: {total_time}min' )