Runs multiple solvers (optionally in parallel) and returns the best result
(highest log-likelihood). More flexible than %|% operator.
Details
When parallel = TRUE, solvers are executed using future::future()
and results collected with future::value(). The current future plan
determines how parallelization happens (e.g., plan(multisession) for
multi-process execution).
Failed solvers (those that throw errors) are ignored. If all solvers fail, an error is thrown.
Examples
# Race three methods sequentially
strategy <- race(gradient_ascent(), bfgs(), nelder_mead())
# Race with parallel execution (requires future package)
if (FALSE) { # \dontrun{
future::plan(future::multisession)
strategy <- race(gradient_ascent(), bfgs(), nelder_mead(), parallel = TRUE)
} # }