Runs the iterated local search (ILS) solver on a model, using PyVRP's vendored C++ core.
Usage
vrp_solve(model, stop, seed = 42L, params = ils_params(), display = TRUE)Arguments
- model
A
vrp_model()or an already-assembledvrp_problem_data().- stop
A stopping criterion (see vrpr_stop), e.g.
max_runtime(10).- seed
Integer seed for reproducibility.
- params
Solver parameters (see
ils_params()).- display
Show progress via
{cli}?
Value
A vrpr_result object with the best solution, cost, routes and run
statistics. Use cost(), routes() and summary() to inspect it.
Examples
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_iterations(200), display = FALSE)
cost(res)
#> [1] 105
routes(res)
#> # A tibble: 4 × 10
#> route_id depot position activity client shipment trip vehicle_type
#> <int> <int> <int> <chr> <int> <int> <int> <int>
#> 1 1 1 1 client 4 NA 1 1
#> 2 1 1 2 client 2 NA 1 1
#> 3 1 1 3 client 3 NA 1 1
#> 4 1 1 4 client 1 NA 1 1
#> # ℹ 2 more variables: start_service <dbl>, wait <dbl>