cuopt-routing-api-python — скилл для Claude Code: маршрутизация
Скилл учит агента решать задачи маршрутизации транспорта через Python API cuOpt: TSP, VRP и pickup-delivery. Пригодится, когда маршруты считают в Python.
npx skills add NVIDIA/skills --skill cuopt-routing-api-python -a claude-codeЧто делает cuopt-routing-api-python
Скилл описывает работу с cuOpt только через Python. C API для маршрутизации в cuOpt нет, поэтому если код на другом языке, скилл не поможет. Внутри — минимальный пример VRP на cudf и cuopt.routing, добавление ограничений и проверка решения.
Агент сначала уточняет вводные: тип задачи (TSP, VRP или PDP), число локаций и депо, матрицу стоимостей или расстояний, заказы с их спросом, парк машин с вместимостью и стартовыми точками, ограничения вроде временных окон и приоритетов. Дальше собирает DataModel, задаёт матрицы и решает через routing.Solve с SolverSettings.
Матрицы и серии нужно приводить к явным типам (float32, int32) — иначе ошибки проходят молча. Если статус решения не 0, скилл советует смотреть get_error_message() и список невыполнимых заказов. Отдельная ловушка: compute_waypoint_sequence меняет колонку location в route_df на месте, так что для перебора по машинам передавайте route_df.copy().
Какие задачи решает
- собрать модель VRP с матрицей стоимостей и парком машин
- добавить временные окна и время обслуживания к заказам
- задать вместимость по нескольким измерениям
- связать пары pickup-delivery и порядок заказов
- разобрать, почему решение пустое или заказ невыполним
Примеры запросов агенту
- Реши VRP на 4 локациях и 2 машинах, матрица стоимостей в cudf
- Добавь временные окна и вместимость по весу в модель cuOpt
- Статус решения не 0 — покажи невыполнимые заказы и текст ошибки
Как установить cuopt-routing-api-python
1Через Skills CLI (Vercel)
npx skills add NVIDIA/skills --skill cuopt-routing-api-python -a claude-code2Вручную: положить файлы
~/.claude/skills/cuopt-routing-api-python/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/cuopt-routing-api-python/
1Через Skills CLI (Vercel)
npx skills add NVIDIA/skills --skill cuopt-routing-api-python -a codex2Вручную: положить файлы
.agents/skills/cuopt-routing-api-python/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add NVIDIA/skills --skill cuopt-routing-api-python -a cursor2Вручную: положить файлы
.cursor/skills/cuopt-routing-api-python/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install NVIDIA/skills cuopt-routing-api-python2Вручную: положить файлы
.github/skills/cuopt-routing-api-python/SKILL.md1Через Skills CLI (Vercel)
npx skills add NVIDIA/skills --skill cuopt-routing-api-python -a gemini-cli2Командой платформы
gemini skills install https://github.com/NVIDIA/skills --path skills/cuopt-routing-api-pythonВручную: положить файлы
.devin/skills/cuopt-routing-api-python/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add NVIDIA/skills --skill cuopt-routing-api-python -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Из того же набора178
Похожие
Рядом в теме «ИИ и ML»
Всё по теме «ИИ и ML» →Вопросы о cuopt-routing-api-python
Как установить cuopt-routing-api-python в Claude?
Выполните npx skills add NVIDIA/skills --skill cuopt-routing-api-python -a claude-code. После этого файл скилла лежит в ~/.claude/skills/cuopt-routing-api-python/SKILL.md.
Что делает cuopt-routing-api-python?
Помогает агенту строить и решать задачи маршрутизации транспорта через Python API cuOpt: TSP, VRP и pickup-delivery, с ограничениями по времени и вместимости.
Почему решение пустое или заказ помечен невыполнимым?
Скилл советует расширить временные окна, проверить времена в пути, увеличить парк или вместимость. Если заданы временные окна, нужна матрица времени в пути через add_transit_time_matrix().
Исходный текст
SKILL.md · Apache-2.0
---
name: cuopt-routing-api-python
version: "26.10.00"
description: Vehicle routing (VRP, TSP, PDP) with cuOpt — Python API only. Use when the user is building or solving routing in Python.
license: Apache-2.0
metadata:
author: NVIDIA cuOpt Team
tags:
- cuopt
- routing
- vrp
- tsp
- python
---
# 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
```python
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
```python
# 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
```python
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)
```python
cost_matrix = cost_matrix.astype("float32")
order_locations = cudf.Series([...], dtype="int32")
demand = cudf.Series([...], dtype="int32")
```
## Solver Settings
```python
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
- [examples.md](references/examples.md) — VRP, PDP, multi-depot
- [server_examples.md](references/server_examples.md) — REST client (curl, Python)
- **Reference models:** This skill's `assets/` — [vrp_basic](assets/vrp_basic/), [pdp_basic](assets/pdp_basic/). See [assets/README.md](assets/README.md).
## Escalate
For contribution or build-from-source, see the developer skill.
© NVIDIA cuOpt Team · Apache-2.0 · NVIDIA/skills