From 4e6066f004d816903feb09511caec2967330b36b Mon Sep 17 00:00:00 2001 From: Lukas Schneiderbauer Date: Mon, 1 Jan 2024 20:32:19 +0100 Subject: [PATCH] fix wrong spelling of Clarke (Clark) --- NAMESPACE | 2 +- R/{clark_wright.R => clarke_wright.R} | 4 ++-- R/cpp11.R | 4 ++-- benchmark/benchmark.R | 2 +- man/{clark_wright.Rd => clarke_wright.Rd} | 8 ++++---- src/{clark_wright.cpp => clarke_wright.cpp} | 2 +- src/cpp11.cpp | 10 +++++----- .../{test-clark_wright.R => test-clarke_wright.R} | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) rename R/{clark_wright.R => clarke_wright.R} (95%) rename man/{clark_wright.Rd => clarke_wright.Rd} (93%) rename src/{clark_wright.cpp => clarke_wright.cpp} (93%) rename tests/testthat/{test-clark_wright.R => test-clarke_wright.R} (93%) diff --git a/NAMESPACE b/NAMESPACE index ffbac80..798c6c2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,7 +2,7 @@ S3method(autoplot,heumilkr_result) S3method(plot,heumilkr_result) -export(clark_wright) +export(clarke_wright) importFrom(ggplot2,aes) importFrom(ggplot2,autoplot) importFrom(ggplot2,geom_path) diff --git a/R/clark_wright.R b/R/clarke_wright.R similarity index 95% rename from R/clark_wright.R rename to R/clarke_wright.R index 86d91ce..30a8d11 100644 --- a/R/clark_wright.R +++ b/R/clarke_wright.R @@ -43,7 +43,7 @@ #' dist(pos), #' data.frame(n = NA_integer_, caps = 6) #' ) -clark_wright <- function(demand, distances, vehicles) { +clarke_wright <- function(demand, distances, vehicles) { stopifnot(inherits(distances, "dist")) stopifnot(attr(distances, "Size") == length(demand) + 1) stopifnot(is.data.frame(vehicles)) @@ -57,7 +57,7 @@ clark_wright <- function(demand, distances, vehicles) { heumilkr_result( as.data.frame( .Call( - `_heumilkr_cpp_clark_wright`, as.numeric(demand), distances, + `_heumilkr_cpp_clarke_wright`, as.numeric(demand), distances, vehicles$n, vehicles$caps ), col.names = c("run_id", "order", "vehicle_id") diff --git a/R/cpp11.R b/R/cpp11.R index 21c0d08..2c4d4b9 100644 --- a/R/cpp11.R +++ b/R/cpp11.R @@ -1,5 +1,5 @@ # Generated by cpp11: do not edit by hand -cpp_clark_wright <- function(demand, distances, n_res, capacities) { - .Call(`_heumilkr_cpp_clark_wright`, demand, distances, n_res, capacities) +cpp_clarke_wright <- function(demand, distances, n_res, capacities) { + .Call(`_heumilkr_cpp_clarke_wright`, demand, distances, n_res, capacities) } diff --git a/benchmark/benchmark.R b/benchmark/benchmark.R index bcc282a..ff8ceb0 100644 --- a/benchmark/benchmark.R +++ b/benchmark/benchmark.R @@ -26,7 +26,7 @@ result <- distances <- dist(pos[1:(n + 1), ]) bench::mark( - clark_wright(demand, distances, vehicles) + clarke_wright(demand, distances, vehicles) ) |> rowwise() |> mutate( diff --git a/man/clark_wright.Rd b/man/clarke_wright.Rd similarity index 93% rename from man/clark_wright.Rd rename to man/clarke_wright.Rd index 3c4eef5..b5db132 100644 --- a/man/clark_wright.Rd +++ b/man/clarke_wright.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/clark_wright.R -\name{clark_wright} -\alias{clark_wright} +% Please edit documentation in R/clarke_wright.R +\name{clarke_wright} +\alias{clarke_wright} \title{Clark-Wright Algorithm (CVRP solver)} \usage{ -clark_wright(demand, distances, vehicles) +clarke_wright(demand, distances, vehicles) } \arguments{ \item{demand}{A numeric vector consisting of "demands" of sites. The length diff --git a/src/clark_wright.cpp b/src/clarke_wright.cpp similarity index 93% rename from src/clark_wright.cpp rename to src/clarke_wright.cpp index ac8f28a..a2cc9f3 100644 --- a/src/clark_wright.cpp +++ b/src/clarke_wright.cpp @@ -30,7 +30,7 @@ list triple_to_list(const std::vector> vec) return lst; } -[[cpp11::register]] list cpp_clark_wright(const std::vector &demand, +[[cpp11::register]] list cpp_clarke_wright(const std::vector &demand, const std::vector &distances, const std::vector &n_res, const std::vector &capacities) diff --git a/src/cpp11.cpp b/src/cpp11.cpp index 2d42a7b..8167f5b 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -5,17 +5,17 @@ #include "cpp11/declarations.hpp" #include -// clark_wright.cpp -list cpp_clark_wright(const std::vector & demand, const std::vector & distances, const std::vector & n_res, const std::vector & capacities); -extern "C" SEXP _heumilkr_cpp_clark_wright(SEXP demand, SEXP distances, SEXP n_res, SEXP capacities) { +// clarke_wright.cpp +list cpp_clarke_wright(const std::vector & demand, const std::vector & distances, const std::vector & n_res, const std::vector & capacities); +extern "C" SEXP _heumilkr_cpp_clarke_wright(SEXP demand, SEXP distances, SEXP n_res, SEXP capacities) { BEGIN_CPP11 - return cpp11::as_sexp(cpp_clark_wright(cpp11::as_cpp &>>(demand), cpp11::as_cpp &>>(distances), cpp11::as_cpp &>>(n_res), cpp11::as_cpp &>>(capacities))); + return cpp11::as_sexp(cpp_clarke_wright(cpp11::as_cpp &>>(demand), cpp11::as_cpp &>>(distances), cpp11::as_cpp &>>(n_res), cpp11::as_cpp &>>(capacities))); END_CPP11 } extern "C" { static const R_CallMethodDef CallEntries[] = { - {"_heumilkr_cpp_clark_wright", (DL_FUNC) &_heumilkr_cpp_clark_wright, 4}, + {"_heumilkr_cpp_clarke_wright", (DL_FUNC) &_heumilkr_cpp_clarke_wright, 4}, {NULL, NULL, 0} }; } diff --git a/tests/testthat/test-clark_wright.R b/tests/testthat/test-clarke_wright.R similarity index 93% rename from tests/testthat/test-clark_wright.R rename to tests/testthat/test-clarke_wright.R index 682e39a..e0d3aa6 100644 --- a/tests/testthat/test-clark_wright.R +++ b/tests/testthat/test-clarke_wright.R @@ -8,7 +8,7 @@ test_that("runs without error", { ) expect_no_error( - clark_wright( + clarke_wright( demand, dist(pos), data.frame(n = NA_integer_, caps = 99999) @@ -21,7 +21,7 @@ test_that("vehicle with infinite capacity covers everything in a single run", { gen.demand_net(max_sites = 10L), function(demand_net) { res <- - clark_wright( + clarke_wright( demand_net$demand, demand_net$distances, data.frame(n = NA_integer_, caps = 99999) )