Isolate a Materialised min_pmix Function from a Scenario by Name
Source: R/accessors.R
scenario_min_pmix.RdReturns the single-argument min_pmix function materialised on scenario
under name. ssd_define_scenario() resolves each min_pmix reference to a
function once, at construction (so a cluster worker needs no shared
interactive environment), and stores it keyed by name; this accessor isolates
it. Aborts with an informative error when name is not one of the scenario's
min_pmix names.
Arguments
- scenario
An
ssdsims_scenariofromssd_define_scenario().- name
A scalar string naming one of the scenario's
min_pmixentries.
Details
Names - not function values - drive task hashing (TARGETS-DESIGN.md section
1.1): the fit-task path carries the min_pmix name, and this accessor
resolves it back to the function at run time, so the function value never
enters a task identity (no byte-stability concern from byte-compilation or
captured environments).
See also
scenario_dataset() for the dataset counterpart.
Examples
data <- ssd_scenario_data(ssddata::ccme_boron)
scenario <- ssd_define_scenario(data, nsim = 1L, seed = 42L)
scenario_min_pmix(scenario, "ssd_min_pmix")
#> function(n) {
#> chk_whole_number(n)
#> chk_gt(n)
#> max(min(3 / n, 0.5), 0.1)
#> }
#> <bytecode: 0x555bfe5cfee0>
#> <environment: namespace:ssdtools>