ensemble_gaussian⚓︎
Gaussian control perturbations: ensemble estimates of the gradient, the Hessian and the sensitivity used by SmcOpt.
GaussianEnsemble
⚓︎
Bases: EnsembleOptimizationBase
Gaussian Ensemble class for ensemble-based optimization.
Methods:
| Name | Description |
|---|---|
gradient |
Ensemble gradient |
hessian |
Ensemble hessian |
calc_ensemble_weights |
Calculate weights used in sequential monte carlo optimization |
__init__(options, simulator, objective)
⚓︎
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
dict
|
Options for the ensemble class
|
required |
simulator
|
callable
|
The forward simulator (e.g. flow) |
required |
objective
|
callable
|
The objective function (e.g. npv) |
required |
calc_ensemble_weights(x, *args, **kwargs)
⚓︎
Calculate weights used in sequential monte carlo optimization. Updated version that accommodates new base class changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Control vector, shape (number of controls, ) |
required |
args
|
tuple
|
Inflation factor, covariance (\(C_x\), shape (number of controls, number of controls)) and survival factor |
()
|
Returns:
| Type | Description |
|---|---|
sens_matrix, best_ens, best_func : tuple
|
The weighted ensemble, the best ensemble member, and the best objective function value |
gradient(x, *args, **kwargs)
⚓︎
Estimate the ensemble gradient (EnOpt) at a given state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Control vector, shape (number of controls, ). |
required |
args
|
tuple
|
First positional argument must be the covariance matrix with shape (number of controls, number of controls). |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Ensemble gradient, shape (number of controls, ). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required inputs are missing or have invalid shapes. |
hessian(x=None, *args, **kwargs)
⚓︎
Ensemble-based Hessian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Control vector, shape (number of controls, ). If None, use the last x used in gradient. If x is not None and it does not match the last x used in gradient, recompute the gradient first. |
None
|
args
|
tuple
|
Additional arguments passed to function |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
hessian |
ndarray
|
Ensemble hessian, shape (number of controls, number of controls) |
References
Zhang, Y., Stordal, A.S. & Lorentzen, R.J. A natural Hessian approximation for ensemble based optimization. Comput Geosci 27, 355–364 (2023). https://doi.org/10.1007/s10596-022-10185-z