Skip to content
OpenSmartRoute
Skillv1.0.0

cuopt-routing-api-python

Vehicle routing (VRP, TSP, PDP) with cuOpt — Python API only. Use when the user is building or solving routing in Python.

by nvidia(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from nvidia/skills (skills/cuopt-routing-api-python/SKILL.md) via skills.sh. Install upstream with npx skills add nvidia/skills --skill cuopt-routing-api-python. Copyright stays with the author (Apache-2.0).

cuOpt Routing — Python API

This skill is Python only. Routing has no C API in cuOpt.

Required questions

Ask these if not already clear:

  1. Problem type — TSP, VRP, or PDP?
  2. Locations — How many? Depot(s)? Cost or distance between pairs (matrix or derived)?
  3. Orders / tasks — Which locations must be visited? Demand or service per stop?
  4. Fleet — Number of vehicles, capacity per vehicle (and per dimension if multiple), start/end locations?
  5. Constraints — Time windows (earliest/latest arrival), service times, precedence (order A before B)?

Minimal VRP Example

import cudf
from cuopt import routing

cost_matrix = cudf.DataFrame([...], dtype="float32")
dm = routing.DataModel(n_locations=4, n_fleet=2, n_orders=3)
dm.add_cost_matrix(cost_matrix)
dm.set_order_locations(cudf.Series([1, 2, 3], dtype="int32"))
solution = routing.Solve(dm, routing.SolverSettings())

if solution.get_status() == 0:
    solution.display_routes()

Adding Constraints

# Time windows
dm.add_transit_time_matrix(transit_time_matrix)
dm.set_order_time_windows(earliest_series, latest_series)

# Capacities
dm.add_capacity_dimension("weight", demand_series, capacity_series)
dm.set_order_service_times(service_times)
dm.set_vehicle_locations(start_locations, end_locations)
dm.set_vehicle_time_windows(earliest_start, latest_return)

# Pickup-delivery pairs
dm.set_pickup_delivery_pairs(pickup_indices, delivery_indices)

# Precedence
dm.add_order_precedence(node_id=2, preceding_nodes=np.array([0, 1]))

Solution Checking

status = solution.get_status()  # 0=SUCCESS, 1=FAIL, 2=TIMEOUT, 3=EMPTY
if status == 0:
    route_df = solution.get_route()
    total_cost = solution.get_total_objective()
else:
    print(solution.get_error_message())
    print(solution.get_infeasible_orders().to_list())

Data Types (use explicit dtypes)

cost_matrix = cost_matrix.astype("float32")
order_locations = cudf.Series([...], dtype="int32")
demand = cudf.Series([...], dtype="int32")

Solver Settings

ss = routing.SolverSettings()
ss.set_time_limit(30)
ss.set_verbose_mode(True)
ss.set_error_logging_mode(True)

Common Issues

Problem Fix
Empty solution Widen time windows or check travel times
Infeasible orders Increase fleet or capacity
Status != 0 with time windows Add add_transit_time_matrix()
Wrong cost Check cost_matrix is symmetric
compute_waypoint_sequence alters route_df It replaces the location column with waypoint ids in place — pass route_df.copy() if you still need cost-matrix indices (e.g. when iterating per truck)

Debugging

When status != 0: print(solution.get_error_message()) and print(solution.get_infeasible_orders().to_list()) to see which orders are infeasible.

Data types: Use explicit dtypes (float32, int32) for matrices and series to avoid silent errors.

Examples

Escalate

For contribution or build-from-source, see the developer skill.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/nvidia-skills-cuopt-routing-api-python/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

nvidia-skills-cuopt-routing-api-python.ocm.jsonjson
{
  "ocm": "1",
  "id": "nvidia-skills-cuopt-routing-api-python",
  "kind": "skill",
  "name": "cuopt-routing-api-python",
  "description": "Vehicle routing (VRP, TSP, PDP) with cuOpt — Python API only. Use when the user is building or solving routing in Python.",
  "publisher": "nvidia",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "cuopt",
      "routing",
      "vrp",
      "tsp",
      "python",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Vehicle routing (VRP, TSP, PDP) with cuOpt — Python API only. Use when the user is building or solving routing in Python."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/nvidia/skills",
      "path": "skills/cuopt-routing-api-python/SKILL.md",
      "ref": "HEAD",
      "url": "https://www.skills.sh/nvidia/skills/cuopt-routing-api-python",
      "key": "nvidia/skills/skills/cuopt-routing-api-python/SKILL.md"
    },
    "license": "Apache-2.0"
  },
  "instructions": "# cuOpt Routing — Python API\n\nThis skill is **Python only**. Routing has no C API in cuOpt.\n\n## Required questions\n\nAsk these if not already clear:\n\n1. **Problem type** — TSP, VRP, or PDP?\n2. **Locations** — How many? Depot(s)? Cost or distance between pairs (matrix or derived)?\n3. **Orders / tasks** — Which locations must be visited? Demand or service per stop?\n4. **Fleet** — Number of vehicles, capacity per vehicle (and per dimension if multiple), start/end locations?\n5. **Constraints** — Time windows (earliest/latest arrival), service times, precedence (order A before B)?\n\n## Minimal VRP Ex",
  "cost": {
    "context_tokens": 838
  }
}

Fetch it by URL: GET /api/v1/registry/nvidia-skills-cuopt-routing-api-python/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.