{"id":32202753,"url":"https://github.com/lschneiderbauer/heumilkr","last_synced_at":"2025-10-22T04:12:25.824Z","repository":{"id":211791150,"uuid":"729954699","full_name":"lschneiderbauer/heumilkr","owner":"lschneiderbauer","description":"R package implementing the Clarke-Wright algorithm to find a quasi-optimal solution to the Capacitated Vehicle Routing Problem.","archived":false,"fork":false,"pushed_at":"2025-04-24T08:31:31.000Z","size":11241,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-08T15:52:12.572Z","etag":null,"topics":["clarke-wright","cvrp","r"],"latest_commit_sha":null,"homepage":"https://lschneiderbauer.github.io/heumilkr/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lschneiderbauer.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-10T21:17:02.000Z","updated_at":"2025-06-08T08:06:01.000Z","dependencies_parsed_at":"2024-02-03T15:31:12.331Z","dependency_job_id":"f8c94a71-d0f4-415d-b743-3b9f866b5845","html_url":"https://github.com/lschneiderbauer/heumilkr","commit_stats":null,"previous_names":["lschneiderbauer/heumilkr"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/lschneiderbauer/heumilkr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lschneiderbauer%2Fheumilkr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lschneiderbauer%2Fheumilkr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lschneiderbauer%2Fheumilkr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lschneiderbauer%2Fheumilkr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lschneiderbauer","download_url":"https://codeload.github.com/lschneiderbauer/heumilkr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lschneiderbauer%2Fheumilkr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280377398,"owners_count":26320467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clarke-wright","cvrp","r"],"created_at":"2025-10-22T04:12:24.170Z","updated_at":"2025-10-22T04:12:25.814Z","avatar_url":"https://github.com/lschneiderbauer.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\nbibliography: references.bib\nlink-citations: true\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  dpi = 300\n)\n```\n\n# heumilkr\n\n\u003c!-- badges: start --\u003e\n\n[![R-CMD-check](https://github.com/lschneiderbauer/heumilkr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/lschneiderbauer/heumilkr/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/lschneiderbauer/heumilkr/branch/master/graph/badge.svg)](https://app.codecov.io/gh/lschneiderbauer/heumilkr?branch=master) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![CRAN status](https://www.r-pkg.org/badges/version/heumilkr)](https://CRAN.R-project.org/package=heumilkr)\n\n\u003c!-- badges: end --\u003e\n\nThis 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).\n\n## Installation\n\nYou can install the latest CRAN release of heumilkr with:\n\n``` r\ninstall.packages(\"heumilkr\")\n```\n\nAlternatively, you can install the development version of heumilkr from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"lschneiderbauer/heumilkr\")\n```\n\n## Example\n\nThe 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.\n\n```{r example}\nlibrary(heumilkr)\nset.seed(42)\n\n# generating random demand\ndemand \u003c- runif(20, 5, 15)\n\n# generating random site positions\npositions \u003c-\n  data.frame(\n    pos_x = c(0, runif(length(demand), -10, 10)),\n    pos_y = c(0, runif(length(demand), -10, 10))\n  )\n\nsolution \u003c-\n  clarke_wright(\n    demand,\n    dist(positions),\n    # We have an infinite number of vehicles with capacity 33 available,\n    # and two vehicles with capacity 44.\n    data.frame(n = c(NA_integer_, 2L), caps = c(33, 44))\n  )\n\nprint(solution)\n\n# returns the total cost / distance\n# (the quantity that is minimized by CVRP)\nprint(milkr_cost(solution))\n\n# returns the savings resulting from the heuristic optimization procedure\nprint(milkr_saving(solution))\n```\n\nA 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.\n\n```{r example_plot}\nplot(solution)\n```\n\n## Runtime Benchmarks\n\n```{r benchmark_calc, echo=FALSE, message=FALSE, warning=FALSE}\nlibrary(bench) # we load that so that the below gets correctly formatted\nresult \u003c- readRDS(paste0(\"./benchmark/\", readLines(\"./benchmark/last_result.txt\")))\n\ntime \u003c- \\(n) format(result$median[result$n == n])\n\nlibrary(ggplot2)\nlibrary(dplyr)\n```\n\nThe benchmarks were taken on an Intel® Xeon® CPU E3-1231 v3 \\@ 3.40GHz CPU, using the R package [bench](https://bench.r-lib.org/).\n\nThe 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)`$.\n\n```{r benchmark_runtime, echo = FALSE}\nresult |\u003e\n  mutate(\n    ymin = as.numeric(mean - std),\n    ymax = as.numeric(mean + std),\n    median = as.numeric(median)\n  ) |\u003e\n  ggplot(aes(x = n, y = median, ymin = ymin, ymax = ymax)) +\n  scale_x_continuous(\n    name = \"Number of demanding sites\",\n    labels = scales::label_number(\n      scale_cut = scales::cut_long_scale()\n    )\n  ) +\n  scale_y_continuous(\n    name = \"Runtime (in seconds)\",\n    labels = scales::label_number(\n      suffix = \"s\",\n      scale_cut = scales::cut_long_scale()\n    )\n  ) +\n  geom_ribbon(alpha = 0.3, linewidth = 0) +\n  geom_point() +\n  geom_line() +\n  theme_bw()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flschneiderbauer%2Fheumilkr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flschneiderbauer%2Fheumilkr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flschneiderbauer%2Fheumilkr/lists"}