Learn R Programming

heumilkr (version 0.2.0)

milkr_cost: Vehicle runs cost / distance

Description

Calculates the total distance associated to a clarke_wright() result. This is the measure that the corresponding Capacitated Vehicle Routing Problem minimizes.

Usage

milkr_cost(solution)

Value

The total traveled distance.

Arguments

solution

A "heumilkr_solution" object, typically obtained by clarke_wright().

Examples

Run this code
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)

Run the code above in your browser using DataLab