parallel_generation
- pyoptex.utils.runtime.parallel_generation(fn, *args, ncores=None, parallel_arg_name=None, **kwargs)[source]
Allows parallel generation of the design. For example, the generation using the CODEX algorithm will parallelize the nreps argument over ncores cores. The generation using the split-plot or fixed structure algorithms will parallelize the n_tries argument over ncores cores.
If ncores is not specified, the number of cores will be set to the number of available cores on the machine.
Parameters
- fncallable
The function to parallelize.
- *argstuple
The arguments to pass to the function.
- ncoresint, optional
The number of cores to use. If not specified, the number of available cores on the machine will be used.
- parallel_arg_namestr, optional
The name of the argument to parallelize. If not specified, the function will look for an argument named nreps, n_reps, ntries, or n_tries.
- **kwargsdict
The keyword arguments to pass to the function.
Returns
- Ypd.DataFrame
The best design found.
- state
State The state of the best design.
Examples
Instead of calling
>>> Y, state = create_cost_optimal_codex_design( >>> params, nsims=nsims, nreps=nreps >>> )
You call
>>> from pyoptex.utils.runtime import parallel_generation >>> Y, state = parallel_generation(create_cost_optimal_codex_design, params, nsims=nsims, nreps=nreps)
which will parallelize the number of repetitions over the specified or available number of cores.