ortools-routing-modeling
БесплатноБез исполняемых скриптовНе проверенBuild OR-Tools RoutingModel vehicle-routing models with transit matrices, dimensions, capacity constraints, time windows, optional visits, invalid-arc…
от benchflow-ai★ 1 941 звезда на GitHubОб этом скилле
OR-Tools Routing Modeling
Use this skill for vehicle-routing models built with ortools.constraint_solver.pywrapcp.RoutingModel.
Modeling Flow
- Normalize integer data and map external nodes to routing-manager nodes.
- Build transit, cost, and demand matrices or vectors before registering callbacks.
- Add time and capacity dimensions, including vehicle start/end ranges and span limits.
- Add problem-specific visits, time windows, optional-node penalties, and pairing constraints.
- Solve with an internal time limit, extract ordered routes, then audit them independently before reporting.
Data And Indexing
- Convert travel times, service times, demands, and time bounds to integers before registering callbacks or transit matrices. Avoid floats and
NaN; OR-Tools can silently treat bad values as usable arcs. - Assert that matrix dimensions, node counts, vehicle counts, and declared record counts agree before building the model. Shape mistakes often produce plausible but meaningless routes.
- Keep a clear distinction between external node IDs, routing manager node IDs, and internal routing indices. Convert with
manager.NodeToIndex(node)andmanager.IndexToNode(index). - When vehicles need distinct starts or ends but the input has shared depots, copy the depot into one internal start node and one internal end node per vehicle. Prefer these internal depot copies over reusing the same shared depot node for every vehicle, then map the copies back to the shared external depot IDs when reporting.
- A common cloned-depot layout is: solver job nodes first, then one start depot per vehicle, then one end depot per vehicle. External shared depot IDs can be stripped from the job matrix and restored only when reporting.
- Treat negative, missing, or sentinel travel times as invalid arcs. Either forbid them with explicit constraints or give them a prohibitive transit cost and reject any final route that uses them. Choose invalid-arc sentinels large enough to dominate feasible legs, but small enough to avoid integer overflow when service times and route spans are added.
- For static integer data, prefer precomputed
RegisterTransitMatrixandRegisterUnaryTransitVectorcalls over Python callbacks. Routing callbacks are called very often during local search and can consume solve time on large instances.
When an input matrix has one shared start depot and one shared end depot, but the routing model needs one start and end node per vehicle, build an internal matrix with cloned depots:
def clone_depots_matrix(external, job_nodes, num_vehicles, start_depot, end_depot, invalid_cost):
num_jobs = len(job_nodes)
start_nodes = list(range(num_jobs, num_jobs + num_vehicles))
end_nodes = list(range(num_jobs + num_vehicles, num_jobs + 2 * num_vehicles))
matrix = [[invalid_cost] * (num_jobs + 2 * num_vehicles) for _ in range(num_jobs + 2 * num_vehicles)]
for i, ext_i in enumerate(job_nodes):
for j, ext_j in enumerate(job_nodes):
matrix[i][j] = external[ext_i][ext_j]
for end in end_nodes:
matrix[i][end] = external[ext_i][end_depot]
for start in start_nodes:
for j, ext_j in enumerate(job_nodes):
matrix[start][j] = external[start_depot][ext_j]
for vehicle in range(num_vehicles):
matrix[start_nodes[vehicle]][end_nodes[vehicle]] = 0
return matrix, start_nodes, end_nodes
Dimensions
- Put travel time plus service time at the departing node in the time transit. Then
Time.CumulVar(index)is the arrival or service-start time, and departure isarrival + service_time. - Derive the time horizon from the data, including latest time windows, service time, travel time, and slack. Avoid arbitrary horizons that are too tight for waiting/service or so large that invalid-arc penalties become usable.
- Choose
fix_start_cumul_to_zerodeliberately. UseFalsewhen vehicle start times or shifts may vary; use start time windows or allowed start values instead. - Set each vehicle start/end cumul through
routing.Start(vehicle)androuting.End(vehicle), especially when depots are cloned or shared. - If shifts may start from a discrete menu, apply allowed values to each vehicle start cumul after setting its broad time-window range.
- Use span upper bounds for route-duration or shift-length limits.
- For capacity, use a unary demand callback and no slack. With OR-Tools dimensions, the load cumul at a node often represents load before applying that node's demand, so audit route loads from the ordered node sequence when checking or exporting a solution.
Apply ordinary visit time windows directly to the node's time cumul:
for node, (window_low, window_high) in time_windows.items():
index = manager.NodeToIndex(node)
time_dim.CumulVar(index).SetRange(int(window_low), int(window_high))
For top-of-hour shift starts inside an operating window, generate the allowed start values and apply them to eac
Установить ortools-routing-modeling в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл ortools-routing-modeling?
Build OR-Tools RoutingModel vehicle-routing models with transit matrices, dimensions, capacity constraints, time windows, optional visits, invalid-arc handling, search parameters, and route extraction.
Как установить скилл ortools-routing-modeling?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ortools-routing-modeling запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
agent-skill-stack
Find, evaluate, and assemble the smallest compatible set of AI Agent Skills for an end-to-end natural-language goal. Use when a user wants Skills for a…
от GitHubbuild-evidence-map
Build an auditable evidence map for a contested technical choice, research synthesis, proposal review, or consequential decision. Use when Copilot must…
от GitHubpinecone-rag
Build production RAG pipelines and persistent agent memory using Pinecone as the vector database backend. ALWAYS USE THIS SKILL when the user mentions…
от GitHubqdrant-monitoring-debugging
Diagnoses Qdrant production issues using metrics and observability tools. Use when someone reports 'optimizer stuck', 'indexing too slow', 'memory too high'…
от GitHub