Skip to content

Commit

Permalink
prepare for cran resub
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyhanson committed Jul 25, 2022
1 parent 099ee49 commit b947764
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# raptr 0.2.1

- CRAN release.
- Update Gurobi documentation URLs.

# raptr 0.2.0.0

Expand Down
20 changes: 13 additions & 7 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,24 @@ is.GurobiInstalled <- function(verbose = TRUE) {
# define installation instructions
gurobiInstallationInstructions <- paste(
"Follow these instructions to download the Gurobi software suite:\n ",
c("Linux" = "http://bit.ly/1ksXUaQ", "Windows" = "http://bit.ly/1MrjXWc",
"Darwin" = "http://bit.ly/1N0AlT0")[Sys.info()[["sysname"]]])
c(
"Linux" = "https://www.gurobi.com/documentation/9.5/quickstart_linux/software_installation_guid.html",
"Windows" = "https://www.gurobi.com/documentation/9.5/quickstart_windows/software_installation_guid.html",
"Darwin" = "https://www.gurobi.com/documentation/9.5/quickstart_mac/software_installation_guid.html"
)[Sys.info()[["sysname"]]])

rInstallationInstructions1 <- paste(
"Follow these instructions to install the \"gurobi\" R package:\n ",
c("Linux" = "http://bit.ly/1HLCRoE", "Windows" = "http://bit.ly/1MMSZaH",
"Darwin" = "http://bit.ly/1Pr2WRG")[Sys.info()[["sysname"]]])
c(
"Linux" = "https://www.gurobi.com/documentation/6.5/quickstart_linux/r_installing_the_r_package.html",
"Windows" = "https://www.gurobi.com/documentation/6.5/quickstart_windows/r_installing_the_r_package.html",
"Darwin" = "https://www.gurobi.com/documentation/6.5/quickstart_mac/r_installing_the_r_package.html"
)[Sys.info()[["sysname"]]])

licenseInstructions <- paste0("The Gurobi R package requires a Gurobi ",
"license to work:\n visit this web-page for an overview: ",
"http://bit.ly/1OHEQCm\n academics can obtain a license at no cost ",
"here: http://bit.ly/1iYg3LX")
"license to work:\n visit this web-page for an overview: \n ",
"https://www.gurobi.com/products/licensing-options/\n academics can obtain a license at no cost ",
"here:\n https://www.gurobi.com/downloads/end-user-license-agreement-academic/")

# check if gurobi installed
result <- suppressWarnings(system2("gurobi_cl", "-v", stdout = FALSE,
Expand Down
6 changes: 6 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Jeff

# Notes

* CRAN repository db overrides:
X-CRAN-Comment: Archived on 2022-05-04 as requires archived package
'RandomFields'.

**This package has been updated so that it no longer depends on the RandomFields package.**

* checking package dependencies ... NOTE
package suggested but not available for checking: 'gurobi'

Expand Down
16 changes: 7 additions & 9 deletions src/rcpp_rrap_squared_distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,29 @@ std::vector<double> rcpp_rrap_squared_distance(Rcpp::NumericMatrix pu_coordinate
//// Preliminary processing
// declare variables
std::size_t N_pu_INT = pu_coordinates_MTX.rows();
std::size_t N_dp_INT = dp_coordinates_MTX.rows();
std::size_t N_k_INT = pu_coordinates_MTX.cols();
std::size_t N_dp_INT = dp_coordinates_MTX.rows();
double currProb, curr_value;

//// Main processing
std::vector<double> d(N_dp_INT);
Eigen::ArrayXd tmp_AXD(N_pu_INT);
std::vector<size_t> pu_ids(N_pu_INT);

for (std::size_t j=0; j < N_dp_INT; ++j) {
// init
std::iota(pu_ids.begin(), pu_ids.end(), 0);

// calculate distances
tmp_AXD = (pu_coordinates_MTX.rowwise() - dp_coordinates_MTX.row(j)).rowwise().squaredNorm().transpose();

// sort pus in order of distance
std::partial_sort(
pu_ids.begin(), pu_ids.begin()+maximum_r_level, pu_ids.end(),
[&](const std::size_t p1, const std::size_t p2) {
return(tmp_AXD[p1] < tmp_AXD[p2]);
}
);

// calculate expected weighted distances for real pus
currProb=1.0;
curr_value=0.0;
Expand All @@ -53,13 +52,12 @@ std::vector<double> rcpp_rrap_squared_distance(Rcpp::NumericMatrix pu_coordinate
}
// calculate expected weighted distance for failure PU
curr_value+=(currProb*failure_distance);

// update value
d[j] = curr_value;
}

//// Exports
// return proportion held
return(d);
}

0 comments on commit b947764

Please sign in to comment.