Skip to content

Commit

Permalink
fix wrong spelling of Clarke (Clark)
Browse files Browse the repository at this point in the history
  • Loading branch information
lschneiderbauer committed Jan 1, 2024
1 parent 8863609 commit 4e6066f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions R/clark_wright.R → R/clarke_wright.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions R/cpp11.R
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion benchmark/benchmark.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions man/clark_wright.Rd → man/clarke_wright.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/clark_wright.cpp → src/clarke_wright.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ list triple_to_list(const std::vector<std::tuple<T1, T2, T3>> vec)
return lst;
}

[[cpp11::register]] list cpp_clark_wright(const std::vector<double> &demand,
[[cpp11::register]] list cpp_clarke_wright(const std::vector<double> &demand,
const std::vector<double> &distances,
const std::vector<int> &n_res,
const std::vector<double> &capacities)
Expand Down
10 changes: 5 additions & 5 deletions src/cpp11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
#include "cpp11/declarations.hpp"
#include <R_ext/Visibility.h>

// clark_wright.cpp
list cpp_clark_wright(const std::vector<double> & demand, const std::vector<double> & distances, const std::vector<int> & n_res, const std::vector<double> & 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<double> & demand, const std::vector<double> & distances, const std::vector<int> & n_res, const std::vector<double> & 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<cpp11::decay_t<const std::vector<double> &>>(demand), cpp11::as_cpp<cpp11::decay_t<const std::vector<double> &>>(distances), cpp11::as_cpp<cpp11::decay_t<const std::vector<int> &>>(n_res), cpp11::as_cpp<cpp11::decay_t<const std::vector<double> &>>(capacities)));
return cpp11::as_sexp(cpp_clarke_wright(cpp11::as_cpp<cpp11::decay_t<const std::vector<double> &>>(demand), cpp11::as_cpp<cpp11::decay_t<const std::vector<double> &>>(distances), cpp11::as_cpp<cpp11::decay_t<const std::vector<int> &>>(n_res), cpp11::as_cpp<cpp11::decay_t<const std::vector<double> &>>(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}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
)
Expand Down

0 comments on commit 4e6066f

Please sign in to comment.