Skip to content

Commit

Permalink
first updates to README
Browse files Browse the repository at this point in the history
  • Loading branch information
lschneiderbauer committed Jan 1, 2024
1 parent bc995d0 commit 70a0a78
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 7 deletions.
33 changes: 29 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
out.width = "100%",
dpi = 300
)
```

Expand All @@ -22,7 +23,8 @@ knitr::opts_chunk$set(
[![CRAN status](https://www.r-pkg.org/badges/version/heumilkr)](https://CRAN.R-project.org/package=heumilkr)
<!-- badges: end -->

The goal of heumilkr is to ...
heumilkr provides an implementation of the Clark-Wright algorithm to find a quasi-optimal solution to the [Capacity Vehicle Routing Problem](https://en.wikipedia.org/wiki/Vehicle_routing_problem).


## Installation

Expand All @@ -35,9 +37,32 @@ devtools::install_github("lschneiderbauer/heumilkr")

## Example

This is a basic example which shows you how to solve a common problem:
The following example generates random demands at random locations, applies the Clark-Wright algorithm to generate quasi-optimal vehicle runs and shows the resulting runs.

```{r example}
library(heumilkr)
## basic example code
set.seed(42)
demand <- runif(20, 5, 15)
pos <-
data.frame(
pos_x = c(0, runif(length(demand), -10, 10)),
pos_y = c(0, runif(length(demand), -10, 10))
)
res <-
clark_wright(
demand,
dist(pos),
data.frame(n = NA_integer_, caps = 33)
)
print(res)
```

A plotting function (using ggplot) 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.

```{r example_plot}
plot(res)
```
59 changes: 56 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](h
status](https://www.r-pkg.org/badges/version/heumilkr)](https://CRAN.R-project.org/package=heumilkr)
<!-- badges: end -->

The goal of heumilkr is to …
heumilkr provides an implementation of the Clark-Wright algorithm to
find a quasi-optimal solution to the [Capacity Vehicle Routing
Problem](https://en.wikipedia.org/wiki/Vehicle_routing_problem).

## Installation

Expand All @@ -28,9 +30,60 @@ devtools::install_github("lschneiderbauer/heumilkr")

## Example

This is a basic example which shows you how to solve a common problem:
The following example generates random demands at random locations,
applies the Clark-Wright algorithm to generate quasi-optimal vehicle
runs and shows the resulting runs.

``` r
library(heumilkr)
## basic example code

set.seed(42)
demand <- runif(20, 5, 15)

pos <-
data.frame(
pos_x = c(0, runif(length(demand), -10, 10)),
pos_y = c(0, runif(length(demand), -10, 10))
)

res <-
clark_wright(
demand,
dist(pos),
data.frame(n = NA_integer_, caps = 33)
)

print(res)
#> run_id order vehicle_id
#> 1 0 0 0
#> 2 1 0 0
#> 3 0 2 0
#> 4 2 1 0
#> 5 1 1 0
#> 6 3 6 0
#> 7 3 8 0
#> 8 3 4 0
#> 9 3 7 0
#> 10 3 3 0
#> 11 3 1 0
#> 12 3 2 0
#> 13 4 0 0
#> 14 3 5 0
#> 15 4 2 0
#> 16 2 0 0
#> 17 4 3 0
#> 18 4 1 0
#> 19 0 1 0
#> 20 3 0 0
```

A plotting function (using ggplot) 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.

``` r
plot(res)
```

<img src="man/figures/README-example_plot-1.png" width="100%" />

0 comments on commit 70a0a78

Please sign in to comment.