Back to home page

EIC code displayed by LXR

 
 

    


Warning, /AID2E-framework/docs/user-guide/optimizers.md is written in an unsupported language. File is not indexed.

0001 # Optimizers
0002 
0003 ## Overview
0004 
0005 `aid2e.optimizers` exposes a shared optimizer interface and two concrete backends: Ax for Bayesian optimization and PyMOO for evolutionary optimization. The package also exports the shared search-space and trial data structures, plus the Pareto utility used by the base implementation.
0006 
0007 ### Choosing a Backend
0008 
0009 - Use **Ax** for Bayesian single- or multi-objective optimization with native support for the constraint forms described below.
0010 - Use **PyMOO** for evolutionary single- or multi-objective optimization with generation-sized candidate batches. PyMOO does not currently enforce design constraints during candidate generation.
0011 
0012 ## Configuration
0013 
0014 The optimizer is selected in the top-level `optimizer` configuration.
0015 
0016 Ax configuration:
0017 
0018 ```yaml
0019 optimizer:
0020   name: ax
0021   type: bayesian
0022   parameters:
0023     initialization_strategy: sobol
0024     generator: BOTORCH_MODULAR
0025     n_initial_samples: 20
0026     n_iterations: 100
0027     batch_size: 4
0028     seed: 42
0029 ```
0030 
0031 PyMOO configuration:
0032 
0033 ```yaml
0034 optimizer:
0035   name: pymoo
0036   type: evolutionary
0037   parameters:
0038     algorithm: nsga2
0039     pop_size: 20
0040     n_offsprings: 20
0041     n_iterations: 5
0042     seed: 42
0043 ```
0044 
0045 ### Optimization Budget and Outputs
0046 
0047 For Ax, `n_iterations` is the total candidate-evaluation budget, including the `n_initial_samples` initialization evaluations, and `batch_size` controls how many candidates are submitted together; it does not multiply the budget. For PyMOO, `n_iterations` is the number of generations; `pop_size` controls the initial generation and `n_offsprings` normally controls later generations.
0048 
0049 The CLI saves `optimization_results.json` and `pareto_front.json` after each completed batch. See [run records](cli.md#run-records) for their contents.
0050 
0051 Ax initialization strategies are:
0052 
0053 - `sobol`: Low-discrepancy sampling designed to cover the search space evenly.
0054 - `uniform`: Independent pseudorandom sampling over each parameter range.
0055 - `center`: One search-space center point followed by Sobol initialization when additional initial samples are requested.
0056 
0057 If the installed Ax version has no uniform generator, `uniform` falls back to Sobol.
0058 
0059 ## Shared Behavior
0060 
0061 All optimizer backends use the same search-space representation, trial lifecycle, result format, and failure accounting. Backend implementations add candidate generation and state management without changing these shared contracts.
0062 
0063 Trials record parameters, objective values, status, and metadata. Results include all recorded trials. The Pareto front includes only completed trials with metrics and respects each objective's `minimize` or `maximize` direction. Failed trials have no objective values; penalized trials have user-configured values that influence optimization.
0064 
0065 Objective `<name>_err` values are saved with results, but the current Ax backend attaches observations with zero standard error. PyMOO selects candidates using objective means only.
0066 
0067 ### Failed and Penalized Trials
0068 
0069 `problem.evaluation_config.trial_failure_policy` controls workflow evaluation failures and defaults to `fail`:
0070 
0071 - `fail` calls the backend's `mark_trial_failed()` without objective values. Failed trials remain in optimizer history, are excluded from Pareto calculations, and are included in subsequently saved results.
0072 - `penalty` requires a `penalty_objectives` value for every declared objective. The optimizer receives those values through `update_with_results()`, and the completed trial retains `penalized: true` and the failure `reason` in metadata. Choose poor values for each objective's direction; the framework does not derive them automatically.
0073 
0074 Both outcomes count toward `max_failed_trials`, which defaults to `0`. The optimization stops when the number of failed evaluations exceeds that configured limit, so the first failure stops the run unless a larger limit is configured.
0075 
0076 ## Ax Backend
0077 
0078 Ax provides Bayesian single- and multi-objective optimization. The backend maps AID2E search spaces and objectives into an Ax experiment, then records each Ax trial in the shared optimizer history.
0079 
0080 ### Configuration
0081 
0082 `AxOptimizerConfig` is the backend config model for the Ax implementation. It is registered under the `ax` name in the optimizer config registry.
0083 
0084 Supported fields are:
0085 
0086 - `initialization_strategy`: `sobol`, `uniform`, or `center`
0087 - `generator`: currently validated to `BOTORCH_MODULAR`
0088 - `generator_kwargs`: runtime kwargs passed to the Ax generator spec
0089 - `generator_gen_kwargs`: generation-time kwargs passed through to Ax
0090 - `objective_thresholds`: optional multi-objective thresholds by metric name
0091 - `n_initial_samples`
0092 - `n_iterations`
0093 - `batch_size`
0094 - `seed`
0095 
0096 `generator_kwargs` accepts supported class names as strings, including model and acquisition choices. `BOTORCH_MODULAR` uses Ax defaults unless those choices are supplied explicitly; defaults can depend on the problem and Ax version. The retired `surrogate_model` and `acquisition_function` fields are rejected; use `generator_kwargs` instead.
0097 
0098 See [Ax symbol resolution](notes/optimizers.md#ax-symbol-resolution) for supported class names and surrogate specifications.
0099 
0100 ### Search-space and constraint mapping
0101 
0102 Ax converts range parameters to floating-point ranges and choice parameters to string choices. See [constraint enforcement](#constraint-enforcement) for supported rules.
0103 
0104 Each objective follows its direction from `problem.objectives`. For multi-objective optimization, `objective_thresholds` defines the hypervolume reference point; these thresholds are not feasibility constraints.
0105 
0106 ## PyMOO Backend
0107 
0108 PyMOO provides evolutionary single- and multi-objective optimization through an external-evaluation ask/tell loop. AID2E schedules each generated population and returns the completed objective values to PyMOO as one generation.
0109 
0110 ### Configuration
0111 
0112 `PyMOOOptimizerConfig` is registered under the `pymoo` name in the optimizer registry. It currently supports:
0113 
0114 - `algorithm`: optional explicit algorithm selection
0115 - `pop_size`
0116 - `n_offsprings`
0117 - `crossover_prob`
0118 - `crossover_eta`
0119 - `mutation_eta`
0120 - `n_iterations`
0121 - `n_partitions`
0122 - `seed`
0123 - `verbose`
0124 
0125 If `algorithm` is omitted, `resolve_algorithm()` selects `ga` for single-objective problems and `nsga2` otherwise. Explicit algorithms must match the objective count:
0126 
0127 - `ga` only for single-objective problems
0128 - `nsga2`, `nsga3`, and `moead` only for multi-objective problems
0129 
0130 ### Evaluation budget
0131 
0132 The actual batch size is determined by the PyMOO algorithm: `pop_size` for the initial generation and normally `n_offsprings` for later generations, with `n_offsprings` defaulting to `pop_size`.
0133 
0134 For normal full GA, NSGA-II, and NSGA-III generations, the expected number of candidate evaluations is:
0135 
0136 ```text
0137 pop_size + (n_iterations - 1) * n_offsprings
0138 ```
0139 
0140 When `n_offsprings` is omitted, this becomes `n_iterations * pop_size`. MOEA/D uses its reference-direction population and does not consume the configured `n_offsprings` value in the current backend.
0141 
0142 ### Algorithm mapping
0143 
0144 `SBX`, polynomial mutation, and random sampling are used as the default operators. `nsga3` and `moead` build reference directions from `n_partitions` or `pop_size` as appropriate.
0145 
0146 ## Constraint Enforcement
0147 
0148 Use fully qualified parameter names such as `group.x` in `design_space.parameter_constraints`. Configuration validation checks syntax and parameter names; it does not establish support in the selected optimizer.
0149 
0150 Ax supports sums and differences of distinct parameters with unit coefficients and nonnegative bounds, using `<=`, `<`, `>=`, and `>`. Weighted terms, products, powers, and negative bounds may be skipped or translated incorrectly. Strict inequalities use a machine-epsilon adjustment. PyMOO currently does not enforce design constraints during candidate generation.
0151 
0152 See the [configuration guide](configuration.md#constraint-handling) for YAML, explicit candidate checks with `SearchSpace.validate()`, and conversion details.
0153 
0154 ## Developer Notes
0155 
0156 See [optimizer notes](notes/optimizers.md) for shared abstractions, candidate lifecycles, state handling, and extension points.