Skip to content

Commit

Permalink
python: fixup examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizux committed Jun 24, 2024
1 parent 06aea80 commit 7e8fef2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions examples/python/prize_collecting_tsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""Simple prize collecting TSP problem with a max distance."""

from ortools.routing import enums_pb2
from ortools.constraint_solver import pywrapcp
from ortools.routing import pywraprouting

DISTANCE_MATRIX = [
[0, 10938, 4542, 2835, 29441, 2171, 1611, 9208, 9528, 11111, 16120, 22606, 22127, 20627, 21246, 23387, 16697, 33609, 26184, 24772, 22644, 20655, 30492, 23296, 32979, 18141, 19248, 17129, 17192, 15645, 12658, 11210, 12094, 13175, 18162, 4968, 12308, 10084, 13026, 15056],
Expand Down Expand Up @@ -106,13 +106,13 @@ def main():
all_nodes = range(num_nodes)

# Create the routing index manager.
manager = pywrapcp.RoutingIndexManager(
manager = pywraprouting.RoutingIndexManager(
num_nodes,
num_vehicles,
depot)

# Create routing model.
routing = pywrapcp.RoutingModel(manager)
routing = pywraprouting.RoutingModel(manager)

# Create and register a transit callback.
def distance_callback(from_index, to_index):
Expand Down Expand Up @@ -145,7 +145,7 @@ def distance_callback(from_index, to_index):
VISIT_VALUES[node])

# Setting first solution heuristic.
search_parameters = pywrapcp.DefaultRoutingSearchParameters()
search_parameters = pywraprouting.DefaultRoutingSearchParameters()
search_parameters.first_solution_strategy = (
enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)
search_parameters.local_search_metaheuristic = (
Expand Down
8 changes: 4 additions & 4 deletions examples/python/prize_collecting_vrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""Simple prize collecting VRP problem with a max distance."""

from ortools.routing import enums_pb2
from ortools.constraint_solver import pywrapcp
from ortools.routing import pywraprouting

DISTANCE_MATRIX = [
[0, 10938, 4542, 2835, 29441, 2171, 1611, 9208, 9528, 11111, 16120, 22606, 22127, 20627, 21246, 23387, 16697, 33609, 26184, 24772, 22644, 20655, 30492, 23296, 32979, 18141, 19248, 17129, 17192, 15645, 12658, 11210, 12094, 13175, 18162, 4968, 12308, 10084, 13026, 15056],
Expand Down Expand Up @@ -112,13 +112,13 @@ def main():
all_nodes = range(num_nodes)

# Create the routing index manager.
manager = pywrapcp.RoutingIndexManager(
manager = pywraprouting.RoutingIndexManager(
num_nodes,
num_vehicles,
depot)

# Create routing model.
routing = pywrapcp.RoutingModel(manager)
routing = pywraprouting.RoutingModel(manager)

# Create and register a transit callback.
def distance_callback(from_index, to_index):
Expand Down Expand Up @@ -151,7 +151,7 @@ def distance_callback(from_index, to_index):
VISIT_VALUES[node])

# Setting first solution heuristic.
search_parameters = pywrapcp.DefaultRoutingSearchParameters()
search_parameters = pywraprouting.DefaultRoutingSearchParameters()
search_parameters.first_solution_strategy = (
enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)
search_parameters.local_search_metaheuristic = (
Expand Down
8 changes: 4 additions & 4 deletions examples/python/random_tsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import random

from ortools.routing import enums_pb2
from ortools.constraint_solver import pywrapcp
from ortools.routing import pywraprouting

parser = argparse.ArgumentParser()

Expand Down Expand Up @@ -91,9 +91,9 @@ def main(args):
# Second argument = 1 to build a single tour (it's a TSP).
# Nodes are indexed from 0 to args_tsp_size - 1, by default the start of
# the route is node 0.
manager = pywrapcp.RoutingIndexManager(args.tsp_size, 1, 0)
routing = pywrapcp.RoutingModel(manager)
search_parameters = pywrapcp.DefaultRoutingSearchParameters()
manager = pywraprouting.RoutingIndexManager(args.tsp_size, 1, 0)
routing = pywraprouting.RoutingModel(manager)
search_parameters = pywraprouting.DefaultRoutingSearchParameters()
# Setting first solution heuristic (cheapest addition).
search_parameters.first_solution_strategy = (
enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)
Expand Down
6 changes: 3 additions & 3 deletions examples/tests/issue117.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from collections import namedtuple
from ortools.constraint_solver import pywrapcp
from ortools.routing import pywraprouting

VEHICLE_COUNT = 30
VEHICLE_CAPACITY = 200
Expand All @@ -14,8 +14,8 @@
customers.append(Customer(1, 1, 2.0, 2.0))
customer_count = len(customers)

manager = pywrapcp.RoutingIndexManager(3, VEHICLE_COUNT, 0)
routing = pywrapcp.RoutingModel(manager)
manager = pywraprouting.RoutingIndexManager(3, VEHICLE_COUNT, 0)
routing = pywraprouting.RoutingModel(manager)

print('Demand Constraint')
demands = []
Expand Down

0 comments on commit 7e8fef2

Please sign in to comment.