A 'tidyverse'-style interface to high-performance vehicle routing problem (VRP) solving. Vendors the C++ core of the 'PyVRP' solver (< https://github.com/PyVRP/PyVRP>) and rewires it through 'cpp11', with no 'Python' runtime dependency. Supports the capacitated VRP, time windows, multiple depots, heterogeneous fleets, prize-collecting and multi-trip variants, driven by an iterated local search metaheuristic.
A production-grade vehicle routing problem (VRP) solver for R.
vrpr brings the state-of-the-art PyVRP solver to R. It vendors PyVRP's high-performance C++ core and rewires it with cpp11, wrapped in an idiomatic, tidyverse-style API: a pipe-friendly model builder, data in tibbles, and logging via cli — with no Python runtime dependency.
It fills a real gap in the R ecosystem: there are ompr, ROI, lpSolve, igraph and dodgr,
but no modern, strong, friendly solver for production vehicle routing.

tools/benchmark/).Install the released version from CRAN:
install.packages("vrpr")
Or the development version from GitHub:
# install.packages("pak")
pak::pak("StrategicProjects/vrpr")
A C++20 toolchain is required to build from source (R >= 4.3).
library(vrpr)
clients <- tibble::tibble(
x = c(10, 25, 40, 15), y = c(5, 30, 12, 22),
demand = c(10, 15, 8, 12)
)
res <- vrp_model() |>
add_depot(x = 0, y = 0) |>
add_clients(clients) |>
add_vehicle_type(num_available = 3, capacity = 50) |>
vrp_solve(stop = max_runtime(2))
cost(res) # objective cost
routes(res) # tibble: route_id, depot, position, client, vehicle_type, ...
summary(res) # one-row summary
plot(res) # the routes, with {ggplot2}
| Variant | How |
|---|---|
| Time windows (VRPTW) | add tw_early, tw_late, service to clients |
| Heterogeneous fleet | call add_vehicle_type() several times with different capacities/costs |
| Multiple depots (MDVRP) | several add_depot() + add_vehicle_type(depot = i) |
| Prize-collecting | required = FALSE + prize on clients; add_client_group() for exclusive sets |
| Pickup & delivery / backhaul | add a pickup column to clients |
| Paired pickup-and-delivery (PDP) | add_shipments() with pickup/delivery points |
| Multi-trip | add_vehicle_type(reload_depots = i, max_reloads = k) |
See the Getting started guide and the Articles for worked examples of each.
By default vrpr uses the rounded Euclidean distance between coordinates, and travel time equals
distance. For real road networks, pass your own matrices (e.g. from OSRM, osrm, osmnx, or any
routing engine) to vrp_solve() or vrp_problem_data():
# dist: n x n metres, time: n x n seconds, for depots, then clients
# (then shipment pickup/delivery pairs), in the order they were added.
res <- vrp_model() |>
add_depot(x = 0, y = 0) |>
add_clients(clients) |>
add_vehicle_type(num_available = 3, capacity = 50) |>
vrp_solve(stop = max_runtime(2), distance = dist, duration = time)
Matrices may be asymmetric and must be integer-valued (round to metres/seconds first). With explicit
matrices, the coordinates are only used by plot().
m <- read_vrplib(system.file("extdata", "sample-n6-k2.vrp", package = "vrpr"))
m <- read_solomon(system.file("extdata", "sample-solomon.txt", package = "vrpr"))
res <- m |> vrp_solve(stop = max_runtime(5))
vrpr is a thin, idiomatic R skin over PyVRP's C++ engine:
vrp_solve().IteratedLocalSearch.src/vendor/pyvrp/, version pinned in tools/PYVRP_VERSION) — the
hot compute: problem data, cost evaluation, solutions and the local-search operators.The light R loop drives the heavy C++ search, so you get PyVRP-grade performance with a pure-R, Python-free workflow.
MIT. Derived from PyVRP (© PyVRP contributors, Thibaut Vidal, ORTEC), whose copyright is preserved;
see inst/COPYRIGHTS.