Optimize a fleet of vehicles on a number of jobs. For more information, see the Vroom project API documentation.
The helper functions jobs()
and vehicles()
create
data.frames which can be used as arguments to ors_optimization()
.
ors_optimization(
jobs,
vehicles,
matrix = NULL,
...,
api_key = ors_api_key(),
output = c("parsed", "text")
)
jobs(
id,
location,
location_index,
service,
amount,
skills,
priority,
time_windows
)
vehicles(
id,
profile,
start,
start_index,
end,
end_index,
capacity,
skills,
time_window
)
data.frame
describing the places to visit
data.frame
describing the available vehicles
Optional two-dimensional array describing a custom travel-time matrix
Optional parameters as described here
Character scalar containing openrouteservice API key
Output format. By default the response is being parsed to a list-based R object
An integer used as unique identifier
Coordinates array
Index of relevant row and column in custom matrix
Job service duration (defaults to 0)
An array of integers describing multidimensional quantities
An array of integers defining skills
An integer in the [0, 10] range describing priority level (defaults to 0)
An array of time_window objects describing valid slots for job service start
routing profile (defaults to car)
coordinates array
index of relevant row and column in custom matrix
coordinates array
index of relevant row and column in custom matrix
an array of integers describing multidimensional quantities
a time_window object describing working hours
Solution computed by the optimization endpoint formatted as described here and structured according to output
:
for "text"
, a character vector of length 1 re-encoded to UTF-8.
for "parsed"
, a parsed R object.
home_base <- c(2.35044, 48.71764)
vehicles <- vehicles(
id = 1:2,
profile = "driving-car",
start = home_base,
end = home_base,
capacity = 4,
skills = list(c(1, 14), c(2, 14)),
time_window = c(28800, 43200)
)
locations <- list(
c(1.98935, 48.701),
c(2.03655, 48.61128),
c(2.39719, 49.07611),
c(2.41808, 49.22619),
c(2.28325, 48.5958),
c(2.89357, 48.90736)
)
jobs <- jobs(
id = 1:6,
service = 300,
amount = 1,
location = locations,
skills = list(1, 1, 2, 2, 14, 14)
)
ors_optimization(jobs, vehicles)
#> <ors_optimization>
#> List of 4
#> $ code : int 0
#> $ summary :List of 13
#> ..$ cost : int 20526
#> ..$ routes : int 2
#> ..$ unassigned : int 0
#> ..$ delivery : int 6
#> ..$ amount : int 6
#> ..$ pickup : int 0
#> .. [list output truncated]
#> $ unassigned: list()
#> $ routes :List of 2
#> ..$ :List of 12
#> .. ..$ vehicle : int 1
#> .. ..$ cost : int 7726
#> .. ..$ delivery : int 3
#> .. ..$ amount : int 3
#> .. ..$ pickup : int 0
#> .. ..$ setup : int 0
#> .. .. [list output truncated]
#> ..$ :List of 12
#> .. ..$ vehicle : int 2
#> .. ..$ cost : int 12800
#> .. ..$ delivery : int 3
#> .. ..$ amount : int 3
#> .. ..$ pickup : int 0
#> .. ..$ setup : int 0
#> .. .. [list output truncated]