ors_optimization: Openrouteservice Optimization

View source: R/optimization.R

ors_optimizationR Documentation

Openrouteservice Optimization

Description

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().

Usage

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
)

Arguments

jobs

data.frame describing the places to visit

vehicles

data.frame describing the available vehicles

matrix

Optional two-dimensional array describing a custom travel-time matrix

...

Optional parameters as described here

api_key

Character scalar containing openrouteservice API key

output

Output format. By default the response is being parsed to a list-based R object

id

An integer used as unique identifier

location

Coordinates array

location_index

Index of relevant row and column in custom matrix

service

Job service duration (defaults to 0)

amount

An array of integers describing multidimensional quantities

skills

An array of integers defining skills

priority

An integer in the [0, 10] range describing priority level (defaults to 0)

time_windows

An array of time_window objects describing valid slots for job service start

profile

routing profile (defaults to car)

start

coordinates array

start_index

index of relevant row and column in custom matrix

end

coordinates array

end_index

index of relevant row and column in custom matrix

capacity

an array of integers describing multidimensional quantities

time_window

a time_window object describing working hours

Value

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.

Author(s)

Andrzej Oleś andrzej.oles@gmail.com

Examples

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)

openrouteservice documentation built on Oct. 21, 2024, 9:06 a.m.