#' Total Operation Time
#'
#' @param solution A list generated by one of the solution functions
#' @param tau The service time per delivery
#'
#' @return A numeric value
#' @export
#'
TOT <- function(solution, tau = 0) {
solution$instance %>%
dplyr::rowwise() %>%
dplyr::mutate(Distance = euclid_norm(c(x-x.centroid, y-y.centroid))) %>%
dplyr::group_by(`Centroid id`) %>%
dplyr::summarise(OT = sum(`Arrival rate`*(Distance + tau))) %>%
dplyr::summarise(TOT = sum(OT)) %>%
as.numeric()
}
#' Operation Time Variance
#'
#' @param solution A list generated by one of the solution functions
#' @param tau The service time per delivery
#'
#' @return A numeric value
#' @export
#'
OTV <- function(solution, tau = 1) {
solution$instance %>%
dplyr::rowwise() %>%
dplyr::mutate(Distance = euclid_norm(c(x-x.centroid, y-y.centroid))) %>%
dplyr::group_by(`Centroid id`) %>%
dplyr::summarise(OT = sum(`Arrival rate`*(Distance + tau))) %>%
dplyr::summarise(OTV = var(OT)) %>%
as.numeric()
}
#' Within-Cluster sum of squares
#'
#' @param solution A list generated by one of the solution functions
#'
#' @return A numeric value
#' @export
#'
WCSS <- function(solution) {
solution$instance %>%
dplyr::rowwise() %>%
dplyr::mutate(Distance = euclid_norm(c(x-x.centroid, y-y.centroid))) %>%
dplyr::ungroup() %>%
dplyr::summarise(WCSS = sum(Distance)) %>%
as.numeric()
}
#' Smallest distance between demand points not in same zone
#'
#' @param solution A solution object from a solve_* function
#'
#' @return A single number that is the smallest distance
#' @export
#'
SAFE <- function(solution) {
safe_dist(
solution$instance %>%
dplyr::mutate(Distance = 99999) %>%
dplyr::select(`Demand point id`, `Centroid id`, Distance, x, y) %>%
data.matrix()
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.