![]() |
0.1.33
|
Classes | |
| class | _CallbackState |
| Carries a Python exception raised inside a callback back to the caller. More... | |
| class | PyHeliosAdam |
| AdamW settings. More... | |
| class | PyHeliosBayesianOptimization |
| Bayesian optimization settings. More... | |
| class | PyHeliosBOBYQA |
| BOBYQA settings. More... | |
| class | PyHeliosCMAES |
| CMA-ES settings. More... | |
| class | PyHeliosGeneticAlgorithm |
| Genetic algorithm settings, with the variant members flattened. More... | |
| class | PyHeliosLBFGS |
| L-BFGS settings. More... | |
| class | PyHeliosParameterSpec |
| One optimizable parameter, flattened for the C ABI. More... | |
| class | PyHeliosSLSQP |
| SLSQP settings. More... | |
| class | UParameterOptimization |
| Opaque structure for ParameterOptimization C++ class. More... | |
Functions | |
| _check_error (result, func, args) | |
| Automatic error checking for all parameter optimization functions. | |
| bool | isParameterOptimizationAvailable () |
| Check if ParameterOptimization functions are available in this build. | |
| None | _require_available () |
| Raise an actionable error if the plugin was not built into the library. | |
| "ctypes._CFuncPtr" | _make_objective_trampoline (Callable[[Dict[str, float]], float] objective, Sequence[str] names, _CallbackState state) |
| Wrap a Python objective as a C callback. | |
| "ctypes._CFuncPtr" | _make_gradient_trampoline (Callable[[Dict[str, float]], Dict[str, float]] gradient, Sequence[str] names, _CallbackState state) |
| Wrap a Python gradient function as a C callback. | |
| None | _write_gradient_dict (result, Sequence[str] names, out_ptr, int offset, str label) |
| Validate a {name: partial derivative} mapping and write it out positionally. | |
| "ctypes._CFuncPtr" | _make_constrained_trampoline (Callable[[Dict[str, float]], object] simulation, Sequence[str] names, int constraint_count, _CallbackState state) |
| Wrap a Python constrained simulation as a C callback. | |
| None | _reraise (_CallbackState state) |
| Re-raise the exception a callback stashed, preserving its traceback. | |
| Tuple[ctypes.Array, list] | _build_parameter_array (List[dict] parameters) |
| Build the C parameter array. | |
| None | destroyParameterOptimization (opt) |
| Destroy a ParameterOptimization instance. | |
| bool | isAlgorithmAvailable (str algorithm_name) |
| Check whether an algorithm can run in this build. | |
| None | setGeneticAlgorithm (opt, PyHeliosGeneticAlgorithm settings) |
| Select the genetic algorithm. | |
| None | setBayesianOptimization (opt, PyHeliosBayesianOptimization settings) |
| Select Bayesian optimization. | |
| None | setCMAES (opt, PyHeliosCMAES settings) |
| Select CMA-ES. | |
| None | setAdam (opt, PyHeliosAdam settings) |
| Select AdamW. | |
| None | setLBFGS (opt, PyHeliosLBFGS settings) |
| Select L-BFGS. | |
| None | setBOBYQA (opt, PyHeliosBOBYQA settings) |
| Select BOBYQA. | |
| None | setSLSQP (opt, PyHeliosSLSQP settings) |
| Select SLSQP. | |
| _fetch_preset (str function_name, struct_type) | |
| Read a settings preset from the native library. | |
| PyHeliosGeneticAlgorithm | getGeneticAlgorithmDefaults () |
| Get the plugin's default genetic algorithm settings. | |
| PyHeliosGeneticAlgorithm | getGeneticAlgorithmExplore () |
| Get the exploration-biased genetic algorithm preset. | |
| PyHeliosGeneticAlgorithm | getGeneticAlgorithmExploit () |
| Get the exploitation-biased genetic algorithm preset. | |
| PyHeliosBayesianOptimization | getBayesianDefaults () |
| Get the plugin's default Bayesian optimization settings. | |
| PyHeliosBayesianOptimization | getBayesianExplore () |
| Get the exploration-biased Bayesian optimization preset. | |
| PyHeliosBayesianOptimization | getBayesianExploit () |
| Get the exploitation-biased Bayesian optimization preset. | |
| PyHeliosCMAES | getCMAESDefaults () |
| Get the plugin's default CMA-ES settings. | |
| PyHeliosCMAES | getCMAESExplore () |
| Get the exploration-biased CMA-ES preset. | |
| PyHeliosCMAES | getCMAESExploit () |
| Get the exploitation-biased CMA-ES preset. | |
| PyHeliosLBFGS | getLBFGSDefaults () |
| Get the plugin's default L-BFGS settings. | |
| PyHeliosAdam | getAdamDefaults () |
| Get the plugin's default Adam settings. | |
| PyHeliosBOBYQA | getBOBYQADefaults () |
| Get the plugin's default BOBYQA settings. | |
| PyHeliosSLSQP | getSLSQPDefaults () |
| Get the plugin's default SLSQP settings. | |
| None | setPrintProgress (opt, bool enable) |
| Enable or disable the plugin's progress printout. | |
| None | setResultFile (opt, Optional[str] path) |
| Set the file the final result is written to (.csv or .txt). | |
| None | setProgressFile (opt, Optional[str] path) |
| Set the file per-generation progress is written to (.csv or .txt). | |
| None | setInputFile (opt, Optional[str] path) |
| Set a file to read the initial parameter set from. | |
| Tuple[Dict[str, float], float] | _finish_run (int rc, _CallbackState state, Sequence[str] names, ctypes.Array out_values, ctypes.c_float out_fitness) |
| Translate a native return code into a result or an exception. | |
| Tuple[Dict[str, float], float] | runOptimization (opt, List[dict] parameters, Callable[[Dict[str, float]], float] objective) |
| Run a derivative-free optimization. | |
| Tuple[Dict[str, float], float] | runOptimizationWithGradient (opt, List[dict] parameters, Callable[[Dict[str, float]], float] objective, Callable[[Dict[str, float]], Dict[str, float]] gradient) |
| Run an optimization with a user-supplied gradient. | |
| Tuple[Dict[str, float], float] | runOptimizationWithFDGradient (opt, List[dict] parameters, Callable[[Dict[str, float]], float] objective, float fd_step=0.0) |
| Run an optimization with gradients estimated by finite differences. | |
| Tuple[Dict[str, float], float] | runOptimizationConstrained (opt, List[dict] parameters, Callable[[Dict[str, float]], object] simulation, int constraint_count) |
| Run a constrained optimization: minimize f(x) subject to c_i(x) <= 0. | |
| mock_createParameterOptimization (*args, **kwargs) | |
| mock_runParameterOptimization (*args, **kwargs) | |
Variables | |
| int | PARAMOPT_OK = 0 |
| int | PARAMOPT_ERROR = -1 |
| int | PARAMOPT_CALLBACK_FAILED = -2 |
| int | PARAM_FLOAT = 0 |
| int | PARAM_INTEGER = 1 |
| int | PARAM_CATEGORICAL = 2 |
| int | CROSSOVER_BLX_ALPHA = 0 |
| int | CROSSOVER_BLX_PCA = 1 |
| int | MUTATION_PER_GENE = 0 |
| int | MUTATION_ISOTROPIC = 1 |
| int | MUTATION_HYBRID = 2 |
| ObjectiveCallback | |
| GradientCallback | |
| ConstrainedCallback | |
| argtypes | |
| restype | |
| errcheck | |
| _fn | |
| bool | _PARAMETEROPTIMIZATION_FUNCTIONS_AVAILABLE |
| createParameterOptimization () = mock_createParameterOptimization | |
| Create a ParameterOptimization instance. | |
| runOptimization = mock_runParameterOptimization | |
| runOptimizationWithGradient = mock_runParameterOptimization | |
| runOptimizationWithFDGradient = mock_runParameterOptimization | |
| runOptimizationConstrained = mock_runParameterOptimization | |
|
protected |
Build the C parameter array.
Returns the array along with a keepalive list holding every buffer the array points into. The array stores borrowed pointers, so those buffers must outlive the native call – see the keepalive note in the run functions.
Definition at line 658 of file UParameterOptimizationWrapper.py.
|
protected |
Automatic error checking for all parameter optimization functions.
Definition at line 54 of file UParameterOptimizationWrapper.py.
|
protected |
Read a settings preset from the native library.
Definition at line 771 of file UParameterOptimizationWrapper.py.
|
protected |
Translate a native return code into a result or an exception.
Definition at line 878 of file UParameterOptimizationWrapper.py.
|
protected |
Wrap a Python constrained simulation as a C callback.
Definition at line 561 of file UParameterOptimizationWrapper.py.
|
protected |
Wrap a Python gradient function as a C callback.
Definition at line 471 of file UParameterOptimizationWrapper.py.
|
protected |
Wrap a Python objective as a C callback.
Definition at line 436 of file UParameterOptimizationWrapper.py.
|
protected |
Raise an actionable error if the plugin was not built into the library.
Definition at line 397 of file UParameterOptimizationWrapper.py.
|
protected |
Re-raise the exception a callback stashed, preserving its traceback.
Definition at line 634 of file UParameterOptimizationWrapper.py.
|
protected |
Validate a {name: partial derivative} mapping and write it out positionally.
Shared by the objective and every constraint of a constrained simulation, so all of them report a missing or unknown parameter the same way. offset is the starting index in a flat row-major buffer.
Definition at line 529 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.destroyParameterOptimization | ( | opt | ) |
Destroy a ParameterOptimization instance.
Definition at line 698 of file UParameterOptimizationWrapper.py.
| PyHeliosAdam pyhelios.wrappers.UParameterOptimizationWrapper.getAdamDefaults | ( | ) |
Get the plugin's default Adam settings.
Definition at line 829 of file UParameterOptimizationWrapper.py.
| PyHeliosBayesianOptimization pyhelios.wrappers.UParameterOptimizationWrapper.getBayesianDefaults | ( | ) |
Get the plugin's default Bayesian optimization settings.
Definition at line 794 of file UParameterOptimizationWrapper.py.
| PyHeliosBayesianOptimization pyhelios.wrappers.UParameterOptimizationWrapper.getBayesianExploit | ( | ) |
Get the exploitation-biased Bayesian optimization preset.
Definition at line 804 of file UParameterOptimizationWrapper.py.
| PyHeliosBayesianOptimization pyhelios.wrappers.UParameterOptimizationWrapper.getBayesianExplore | ( | ) |
Get the exploration-biased Bayesian optimization preset.
Definition at line 799 of file UParameterOptimizationWrapper.py.
| PyHeliosBOBYQA pyhelios.wrappers.UParameterOptimizationWrapper.getBOBYQADefaults | ( | ) |
Get the plugin's default BOBYQA settings.
Definition at line 834 of file UParameterOptimizationWrapper.py.
| PyHeliosCMAES pyhelios.wrappers.UParameterOptimizationWrapper.getCMAESDefaults | ( | ) |
Get the plugin's default CMA-ES settings.
Definition at line 809 of file UParameterOptimizationWrapper.py.
| PyHeliosCMAES pyhelios.wrappers.UParameterOptimizationWrapper.getCMAESExploit | ( | ) |
Get the exploitation-biased CMA-ES preset.
Definition at line 819 of file UParameterOptimizationWrapper.py.
| PyHeliosCMAES pyhelios.wrappers.UParameterOptimizationWrapper.getCMAESExplore | ( | ) |
Get the exploration-biased CMA-ES preset.
Definition at line 814 of file UParameterOptimizationWrapper.py.
| PyHeliosGeneticAlgorithm pyhelios.wrappers.UParameterOptimizationWrapper.getGeneticAlgorithmDefaults | ( | ) |
Get the plugin's default genetic algorithm settings.
Definition at line 779 of file UParameterOptimizationWrapper.py.
| PyHeliosGeneticAlgorithm pyhelios.wrappers.UParameterOptimizationWrapper.getGeneticAlgorithmExploit | ( | ) |
Get the exploitation-biased genetic algorithm preset.
Definition at line 789 of file UParameterOptimizationWrapper.py.
| PyHeliosGeneticAlgorithm pyhelios.wrappers.UParameterOptimizationWrapper.getGeneticAlgorithmExplore | ( | ) |
Get the exploration-biased genetic algorithm preset.
Definition at line 784 of file UParameterOptimizationWrapper.py.
| PyHeliosLBFGS pyhelios.wrappers.UParameterOptimizationWrapper.getLBFGSDefaults | ( | ) |
Get the plugin's default L-BFGS settings.
Definition at line 824 of file UParameterOptimizationWrapper.py.
| PyHeliosSLSQP pyhelios.wrappers.UParameterOptimizationWrapper.getSLSQPDefaults | ( | ) |
Get the plugin's default SLSQP settings.
Definition at line 839 of file UParameterOptimizationWrapper.py.
| bool pyhelios.wrappers.UParameterOptimizationWrapper.isAlgorithmAvailable | ( | str | algorithm_name | ) |
Check whether an algorithm can run in this build.
L-BFGS, BOBYQA and SLSQP depend on NLopt, and L-BFGS additionally on the LGPL Luksan solvers that implement it.
| algorithm_name | One of "GA", "BO", "CMAES", "LBFGS", "ADAM", "BOBYQA", "SLSQP" |
Definition at line 712 of file UParameterOptimizationWrapper.py.
| bool pyhelios.wrappers.UParameterOptimizationWrapper.isParameterOptimizationAvailable | ( | ) |
Check if ParameterOptimization functions are available in this build.
Definition at line 390 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.mock_createParameterOptimization | ( | * | args, |
| ** | kwargs ) |
Definition at line 1054 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.mock_runParameterOptimization | ( | * | args, |
| ** | kwargs ) |
Definition at line 1060 of file UParameterOptimizationWrapper.py.
| Tuple[Dict[str, float], float] pyhelios.wrappers.UParameterOptimizationWrapper.runOptimization | ( | opt, | |
| List[dict] | parameters, | ||
| Callable[[Dict[str, float]], float] | objective ) |
Run a derivative-free optimization.
| opt | ParameterOptimization instance pointer |
| parameters | Parameter specs as dicts with keys name/value/min/max/type/categories |
| objective | Callable receiving {name: value} and returning a scalar cost |
Definition at line 903 of file UParameterOptimizationWrapper.py.
| Tuple[Dict[str, float], float] pyhelios.wrappers.UParameterOptimizationWrapper.runOptimizationConstrained | ( | opt, | |
| List[dict] | parameters, | ||
| Callable[[Dict[str, float]], object] | simulation, | ||
| int | constraint_count ) |
Run a constrained optimization: minimize f(x) subject to c_i(x) <= 0.
Requires SLSQP, enforced by the plugin.
| opt | ParameterOptimization instance pointer |
| parameters | Parameter specs as dicts |
| simulation | Callable receiving {name: value} and returning a ConstrainedResult |
| constraint_count | Number of constraints; fixed for the whole run |
Definition at line 1022 of file UParameterOptimizationWrapper.py.
| Tuple[Dict[str, float], float] pyhelios.wrappers.UParameterOptimizationWrapper.runOptimizationWithFDGradient | ( | opt, | |
| List[dict] | parameters, | ||
| Callable[[Dict[str, float]], float] | objective, | ||
| float | fd_step = 0.0 ) |
Run an optimization with gradients estimated by finite differences.
| opt | ParameterOptimization instance pointer |
| parameters | Parameter specs as dicts |
| objective | Callable receiving {name: value} and returning a scalar cost |
| fd_step | Relative perturbation factor; values <= 0 select the plugin default |
Definition at line 983 of file UParameterOptimizationWrapper.py.
| Tuple[Dict[str, float], float] pyhelios.wrappers.UParameterOptimizationWrapper.runOptimizationWithGradient | ( | opt, | |
| List[dict] | parameters, | ||
| Callable[[Dict[str, float]], float] | objective, | ||
| Callable[[Dict[str, float]], Dict[str, float]] | gradient ) |
Run an optimization with a user-supplied gradient.
| opt | ParameterOptimization instance pointer |
| parameters | Parameter specs as dicts |
| objective | Callable receiving {name: value} and returning a scalar cost |
| gradient | Callable receiving {name: value} and returning {name: partial derivative} |
Definition at line 944 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setAdam | ( | opt, | |
| PyHeliosAdam | settings ) |
Select AdamW.
Definition at line 741 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setBayesianOptimization | ( | opt, | |
| PyHeliosBayesianOptimization | settings ) |
Select Bayesian optimization.
Definition at line 729 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setBOBYQA | ( | opt, | |
| PyHeliosBOBYQA | settings ) |
Select BOBYQA.
Definition at line 753 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setCMAES | ( | opt, | |
| PyHeliosCMAES | settings ) |
Select CMA-ES.
Definition at line 735 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setGeneticAlgorithm | ( | opt, | |
| PyHeliosGeneticAlgorithm | settings ) |
Select the genetic algorithm.
Definition at line 723 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setInputFile | ( | opt, | |
| Optional[str] | path ) |
Set a file to read the initial parameter set from.
Definition at line 866 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setLBFGS | ( | opt, | |
| PyHeliosLBFGS | settings ) |
Select L-BFGS.
Definition at line 747 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setPrintProgress | ( | opt, | |
| bool | enable ) |
Enable or disable the plugin's progress printout.
Definition at line 848 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setProgressFile | ( | opt, | |
| Optional[str] | path ) |
Set the file per-generation progress is written to (.csv or .txt).
Definition at line 860 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setResultFile | ( | opt, | |
| Optional[str] | path ) |
Set the file the final result is written to (.csv or .txt).
Definition at line 854 of file UParameterOptimizationWrapper.py.
| None pyhelios.wrappers.UParameterOptimizationWrapper.setSLSQP | ( | opt, | |
| PyHeliosSLSQP | settings ) |
Select SLSQP.
Definition at line 759 of file UParameterOptimizationWrapper.py.
|
protected |
Definition at line 305 of file UParameterOptimizationWrapper.py.
|
protected |
Definition at line 380 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.argtypes |
Definition at line 240 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.ConstrainedCallback |
Definition at line 221 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.createParameterOptimization = mock_createParameterOptimization |
Create a ParameterOptimization instance.
Definition at line 1067 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.CROSSOVER_BLX_ALPHA = 0 |
Definition at line 43 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.CROSSOVER_BLX_PCA = 1 |
Definition at line 44 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.errcheck |
Definition at line 242 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.GradientCallback |
Definition at line 212 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.MUTATION_HYBRID = 2 |
Definition at line 47 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.MUTATION_ISOTROPIC = 1 |
Definition at line 46 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.MUTATION_PER_GENE = 0 |
Definition at line 45 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.ObjectiveCallback |
Definition at line 204 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.PARAM_CATEGORICAL = 2 |
Definition at line 39 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.PARAM_FLOAT = 0 |
Definition at line 37 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.PARAM_INTEGER = 1 |
Definition at line 38 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.PARAMOPT_CALLBACK_FAILED = -2 |
Definition at line 34 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.PARAMOPT_ERROR = -1 |
Definition at line 33 of file UParameterOptimizationWrapper.py.
| int pyhelios.wrappers.UParameterOptimizationWrapper.PARAMOPT_OK = 0 |
Definition at line 32 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.restype |
Definition at line 241 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.runOptimization = mock_runParameterOptimization |
Definition at line 1068 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.runOptimizationConstrained = mock_runParameterOptimization |
Definition at line 1071 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.runOptimizationWithFDGradient = mock_runParameterOptimization |
Definition at line 1070 of file UParameterOptimizationWrapper.py.
| pyhelios.wrappers.UParameterOptimizationWrapper.runOptimizationWithGradient = mock_runParameterOptimization |
Definition at line 1069 of file UParameterOptimizationWrapper.py.