heumilkr
R package implementing the Clarke-Wright algorithm to find a quasi-optimal solution to the Capacitated Vehicle Routing Problem.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (17.5%) to scientific vocabulary
Keywords
clarke-wright
cvrp
r
Last synced: 10 months ago
·
JSON representation
Repository
R package implementing the Clarke-Wright algorithm to find a quasi-optimal solution to the Capacitated Vehicle Routing Problem.
Basic Info
- Host: GitHub
- Owner: lschneiderbauer
- License: gpl-3.0
- Language: R
- Default Branch: master
- Homepage: https://lschneiderbauer.github.io/heumilkr/
- Size: 10.7 MB
Statistics
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
- Releases: 2
Topics
clarke-wright
cvrp
r
Created over 2 years ago
· Last pushed about 1 year ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
bibliography: references.bib
link-citations: true
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dpi = 300
)
```
# heumilkr
[](https://github.com/lschneiderbauer/heumilkr/actions/workflows/R-CMD-check.yaml) [](https://app.codecov.io/gh/lschneiderbauer/heumilkr?branch=master) [](https://lifecycle.r-lib.org/articles/stages.html#experimental) [](https://CRAN.R-project.org/package=heumilkr)
This R package provides an implementation of the Clarke-Wright algorithm [@clarke1964] to find a quasi-optimal solution to the [Capacitated Vehicle Routing Problem](https://en.wikipedia.org/wiki/Vehicle_routing_problem).
## Installation
You can install the latest CRAN release of heumilkr with:
``` r
install.packages("heumilkr")
```
Alternatively, you can install the development version of heumilkr from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("lschneiderbauer/heumilkr")
```
## Example
The following example generates random demands at random locations, defines two vehicle types, applies the Clarke-Wright algorithm to generate quasi-optimal vehicle runs, and shows the resulting vehicle run solution.
```{r example}
library(heumilkr)
set.seed(42)
# generating random demand
demand <- runif(20, 5, 15)
# generating random site positions
positions <-
data.frame(
pos_x = c(0, runif(length(demand), -10, 10)),
pos_y = c(0, runif(length(demand), -10, 10))
)
solution <-
clarke_wright(
demand,
dist(positions),
# We have an infinite number of vehicles with capacity 33 available,
# and two vehicles with capacity 44.
data.frame(n = c(NA_integer_, 2L), caps = c(33, 44))
)
print(solution)
# returns the total cost / distance
# (the quantity that is minimized by CVRP)
print(milkr_cost(solution))
# returns the savings resulting from the heuristic optimization procedure
print(milkr_saving(solution))
```
A plotting function (using [ggplot](https://ggplot2.tidyverse.org/)) for the result is built in. The individual runs are distinguished by color. The demanding site locations are marked with round circles while the (single) supplying site is depicted as a square. The line types (solid/dashed/...) are associated to different vehicle types.
```{r example_plot}
plot(solution)
```
## Runtime Benchmarks
```{r benchmark_calc, echo=FALSE, message=FALSE, warning=FALSE}
library(bench) # we load that so that the below gets correctly formatted
result <- readRDS(paste0("./benchmark/", readLines("./benchmark/last_result.txt")))
time <- \(n) format(result$median[result$n == n])
library(ggplot2)
library(dplyr)
```
The benchmarks were taken on an Intel® Xeon® CPU E3-1231 v3 \@ 3.40GHz CPU, using the R package [bench](https://bench.r-lib.org/).
The following graph shows the run time behavior as the number of sites $n$ increase. The curve exhibits near-cubic behavior in $n$. For $n = 110$ the performance is still relatively reasonable with a run time of $\sim `r time(110)`$.
```{r benchmark_runtime, echo = FALSE}
result |>
mutate(
ymin = as.numeric(mean - std),
ymax = as.numeric(mean + std),
median = as.numeric(median)
) |>
ggplot(aes(x = n, y = median, ymin = ymin, ymax = ymax)) +
scale_x_continuous(
name = "Number of demanding sites",
labels = scales::label_number(
scale_cut = scales::cut_long_scale()
)
) +
scale_y_continuous(
name = "Runtime (in seconds)",
labels = scales::label_number(
suffix = "s",
scale_cut = scales::cut_long_scale()
)
) +
geom_ribbon(alpha = 0.3, linewidth = 0) +
geom_point() +
geom_line() +
theme_bw()
```
Owner
- Name: Lukas Schneiderbauer
- Login: lschneiderbauer
- Kind: user
- Location: Vienna, Austria
- Repositories: 8
- Profile: https://github.com/lschneiderbauer
GitHub Events
Total
- Create event: 1
- Release event: 1
- Issues event: 8
- Watch event: 1
- Issue comment event: 5
- Push event: 24
Last Year
- Create event: 1
- Release event: 1
- Issues event: 8
- Watch event: 1
- Issue comment event: 5
- Push event: 24
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 5
- Total pull requests: 1
- Average time to close issues: 5 months
- Average time to close pull requests: 6 months
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 0.4
- Average comments per pull request: 3.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 1
- Average time to close issues: about 2 months
- Average time to close pull requests: 6 months
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 0.5
- Average comments per pull request: 3.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- lschneiderbauer (7)
Pull Request Authors
- lschneiderbauer (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 204 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
cran.r-project.org: heumilkr
Heuristic Capacitated Vehicle Routing Problem Solver
- Homepage: https://github.com/lschneiderbauer/heumilkr
- Documentation: http://cran.r-project.org/web/packages/heumilkr/heumilkr.pdf
- License: GPL (≥ 3)
-
Latest release: 0.3.0
published about 1 year ago
Rankings
Dependent packages count: 28.5%
Dependent repos count: 36.5%
Average: 50.0%
Downloads: 85.1%
Maintainers (1)
Last synced:
10 months ago
Dependencies
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pr-commands.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/pr-fetch v2 composite
- r-lib/actions/pr-push v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v3 composite
- actions/upload-artifact v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION
cran
- testthat >= 3.0.0 suggests
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.4.1 composite
- actions/checkout v3 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite