Skip to contents

Executes a parameter sweep using the future framework for parallelization. This works with any future backend (local, PBS, SLURM, etc.).

Usage

run_sweep_future(
  param_grid,
  run_func,
  ...,
  future_backend = "multisession",
  workers = NULL,
  resources = list(),
  chunk_size = NULL,
  verbose = TRUE
)

Arguments

param_grid

Data frame. Parameter grid to sweep.

run_func

Function. Function to run for each parameter combination. Should accept a single row of param_grid and return a data frame.

...

Additional arguments passed to run_func.

future_backend

Character. Backend to use (see setup_future_backend).

workers

Integer. Number of workers for local backends.

resources

List. HPC resources for batchtools backends.

chunk_size

Integer. Number of tasks per future (for load balancing).

verbose

Logical. Print progress information.

Value

Data frame with combined results from all parameter combinations.

Examples

if (FALSE) { # \dontrun{
# Define a simple run function
my_run_func <- function(p) {
  Sys.sleep(1)  # Simulate work
  data.frame(run_id = p$run_id, result = p$x^2)
}

# Create parameter grid
param_grid <- data.frame(run_id = 1:10, x = 1:10)

# Run with local parallelization
results <- run_sweep_future(
  param_grid, my_run_func,
  future_backend = "multisession",
  workers = 2
)

# Run with PBS
results <- run_sweep_future(
  param_grid, my_run_func,
  future_backend = "batchtools_torque",
  resources = list(walltime = "01:00:00")
)
} # }