Title: | Heuristic Capacitated Vehicle Routing Problem Solver |
---|---|
Description: | Implements the Clarke-Wright algorithm to find a quasi-optimal solution to the Capacitated Vehicle Routing Problem. See Clarke, G. and Wright, J.R. (1964) <doi:10.1287/opre.12.4.568> for details. The implementation is accompanied by helper functions to inspect its solution. |
Authors: | Lukas Schneiderbauer [aut, cre, cph] |
Maintainer: | Lukas Schneiderbauer <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.0.9000 |
Built: | 2024-10-28 02:49:26 UTC |
Source: | https://github.com/lschneiderbauer/heumilkr |
Finds a quasi-optimal solution to the Capacitated Vehicle Routing Problem (CVRP). It is assumed that all demands will be satisfied by a single source.
clarke_wright(demand, distances, vehicles, restrictions = NULL)
clarke_wright(demand, distances, vehicles, restrictions = NULL)
demand |
A numeric vector consisting of "demands" indexed by sites.
The |
distances |
An object of class |
vehicles |
A
The order of the |
restrictions |
An optional
Each row defines a restriction: vehicle type |
See the original paper, Clarke, G. and Wright, J.R. (1964) doi:10.1287/opre.12.4.568, for a detailed explanation of the Clarke-Wright algorithm.
Returns a "heumilkr_solution
" object, a data.frame()
with one row per
site-run combination bestowed with additional attributes. Its columns
consist of:
site
- The site index (i.e. the index of the demand
vector) associated
to the run.
run
- Identifies the run the site is assigned to.
order
- Integer values providing the visiting order within each run.
vehicle
- The vehicle type index (as provided in vehicles
) associated
to the run.
load
- The actual load in units of demand
on the particular run.
distance
- The travel distance of the particular run.
Unless a site demand exceeds the vehicle capacities it is always assigned to only a single run.
demand <- c(3, 2, 4, 2) positions <- data.frame( pos_x = c(0, 1, -1, 2, 3), pos_y = c(0, 1, 1, 2, 3) ) clarke_wright( demand, dist(positions), data.frame(n = NA_integer_, caps = 6) )
demand <- c(3, 2, 4, 2) positions <- data.frame( pos_x = c(0, 1, -1, 2, 3), pos_y = c(0, 1, 1, 2, 3) ) clarke_wright( demand, dist(positions), data.frame(n = NA_integer_, caps = 6) )
clarke_wright()
to CVRPLIB dataApplying clarke_wright()
to CVRPLIB data
clarke_wright_cvrplib(instance)
clarke_wright_cvrplib(instance)
instance |
A " |
A "heumilkr_solution
" object. See clarke_wright()
.
Other cvrplib:
cvrplib_download()
,
cvrplib_ls()
A collection of CVRP instances by Augerat, 1995, provided courtesy of CVRPLIB. See CVRPLIB for visualizations of the instances and their solutions as well as a multitude of alternative instance data.
cvrplib_A
cvrplib_A
cvrplib_A
A list of CVRP instances as "cvrplib_instance
" objects. The instances
can be directly fed into solver algorithm, e.g. via clarke_wright_cvrplib()
.
http://vrp.atd-lab.inf.puc-rio.br
A collection of CVRP instances by Augerat, 1995, provided courtesy of CVRPLIB. See CVRPLIB for visualizations of the instances and their solutions as well as a multitude of alternative instance data.
cvrplib_B
cvrplib_B
cvrplib_B
A list of CVRP instances as "cvrplib_instance
" objects. The instances
can be directly fed into solver algorithm, e.g. via clarke_wright_cvrplib()
.
http://vrp.atd-lab.inf.puc-rio.br
CVRLIB offers a selection of
CVRP problem instances. This function downloads the instance data and
conveniently makes it available to be fed into solver functions, e.g. with
clarke_wright_cvrplib()
. The primary purpose for those instances is
benchmarking / comparing speed as well as performance of solvers.
cvrplib_download(qualifier)
cvrplib_download(qualifier)
qualifier |
The qualifier of the problem instance. E.g. "tai/tai150d".
This can either be inferred directly from the website or by the output of
|
Returns a "cvrplib_instance
" object which contains CVRPLIB problem
instance data.
Other cvrplib:
clarke_wright_cvrplib()
,
cvrplib_ls()
A collection of CVRP instances by Christofides and Eilon, 1969, provided courtesy of CVRPLIB. See CVRPLIB for visualizations of the instances and their solutions as well as a multitude of alternative instance data.
cvrplib_E
cvrplib_E
cvrplib_E
A list of CVRP instances as "cvrplib_instance
" objects. The instances
can be directly fed into solver algorithm, e.g. via clarke_wright_cvrplib()
.
http://vrp.atd-lab.inf.puc-rio.br
A collection of CVRP instances by Fisher, 1994, provided courtesy of CVRPLIB. See CVRPLIB for visualizations of the instances and their solutions as well as a multitude of alternative instance data.
cvrplib_F
cvrplib_F
cvrplib_F
A list of CVRP instances as "cvrplib_instance
" objects. The instances
can be directly fed into solver algorithm, e.g. via clarke_wright_cvrplib()
.
http://vrp.atd-lab.inf.puc-rio.br
Scrapes the CVRPLIB website to look for available data sets. This function call can take some time.
cvrplib_ls()
cvrplib_ls()
A vector of data set qualifiers which can be used with cvrplib_download()
.
Other cvrplib:
clarke_wright_cvrplib()
,
cvrplib_download()
A collection of CVRP instances by Rochat and Taillard, 1995, provided courtesy of CVRPLIB. See CVRPLIB for visualizations of the instances and their solutions as well as a multitude of alternative instance data.
cvrplib_Tai
cvrplib_Tai
cvrplib_Tai
A list of CVRP instances as "cvrplib_instance
" objects. The instances
can be directly fed into solver algorithm, e.g. via clarke_wright_cvrplib()
.
http://vrp.atd-lab.inf.puc-rio.br
Calculates the total distance associated to a clarke_wright()
result.
This is the measure that the corresponding Capacitated Vehicle Routing
Problem minimizes.
milkr_cost(solution)
milkr_cost(solution)
solution |
A " |
The total traveled distance.
demand <- c(3, 2, 4, 2) positions <- data.frame( pos_x = c(0, 1, -1, 2, 3), pos_y = c(0, 1, 1, 2, 3) ) solution <- clarke_wright( demand, dist(positions), data.frame(n = NA_integer_, caps = 6) ) milkr_cost(solution)
demand <- c(3, 2, 4, 2) positions <- data.frame( pos_x = c(0, 1, -1, 2, 3), pos_y = c(0, 1, 1, 2, 3) ) solution <- clarke_wright( demand, dist(positions), data.frame(n = NA_integer_, caps = 6) ) milkr_cost(solution)
Measures the saving that was achieved by the heuristic optimization
algorithm clarke_wright()
compared to the naive vehicle run assignment,
i.e. one run per site.
milkr_saving(solution, relative = FALSE)
milkr_saving(solution, relative = FALSE)
solution |
A " |
relative |
Should the saving be given as dimensionful value (in units of distance as
provided to |
The savings either as dimensionful value or as percentage relative to the
naive costs, depending on relative
.
demand <- c(3, 2, 4, 2) positions <- data.frame( pos_x = c(0, 1, -1, 2, 3), pos_y = c(0, 1, 1, 2, 3) ) solution <- clarke_wright( demand, dist(positions), data.frame(n = NA_integer_, caps = 6) ) print(milkr_saving(solution)) print(milkr_saving(solution, relative = TRUE))
demand <- c(3, 2, 4, 2) positions <- data.frame( pos_x = c(0, 1, -1, 2, 3), pos_y = c(0, 1, 1, 2, 3) ) solution <- clarke_wright( demand, dist(positions), data.frame(n = NA_integer_, caps = 6) ) print(milkr_saving(solution)) print(milkr_saving(solution, relative = TRUE))