Skip to content

Commit

Permalink
add cores as an option for hpc
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtuck committed Oct 8, 2024
1 parent 6fde691 commit f3f1ff4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/time-warping.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#' box filter. Defaults to `25L`. This is used only when `smooth_data = TRUE`.
#' @param parallel A boolean specifying whether to run calculations in parallel.
#' Defaults to `FALSE`.
#' @param cores number of cores in parallel (default=-1, means all cores)
#' @param optim_method A string specifying the algorithm used for optimization.
#' Choices are `"DP"`, `"DPo"`, and `"RBFGS"`. Defaults to `"DP"`.
#' @param max_iter An integer value specifying the maximum number of iterations.
Expand Down Expand Up @@ -81,14 +82,18 @@ time_warping <- function(f,
smooth_data = FALSE,
sparam = 25L,
parallel = FALSE,
cores = -1,
optim_method = c("DP", "DPo", "DP2", "RBFGS"),
max_iter = 20L) {
penalty_method <- rlang::arg_match(penalty_method)
centroid_type <- rlang::arg_match(centroid_type)
optim_method <- rlang::arg_match(optim_method)

if (parallel) {
cores <- max(parallel::detectCores() - 1, 1)
if (cores == -1){
cores <- max(parallel::detectCores() - 1, 1)
}

cl <- parallel::makeCluster(cores)
doParallel::registerDoParallel(cl)
} else
Expand Down
3 changes: 3 additions & 0 deletions man/time_warping.Rd

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

0 comments on commit f3f1ff4

Please sign in to comment.