Ensemble Evaluator
ropt.core.EnsembleEvaluator
Construct functions and gradients from an ensemble of functions.
The EnsembleEvaluator class is responsible for calculating functions and
gradients from an ensemble of functions. It leverages the settings defined
in an EnOptContext context object to guide
the calculations.
The core functionality relies on an evaluator callable, (usually provided by
an Evaluator object), which is used to
evaluate the individual functions within the ensemble. The evaluator
provides the raw function values, which are then processed by the
EnsembleEvaluator to produce the final function and gradient estimates.
__init__
Initialize the EnsembleEvaluator.
This method sets up the EnsembleEvaluator with the necessary
configuration, evaluator, and plugins.
The context object contains all the settings required for the ensemble
evaluation, such as the number of realizations, the function estimators,
and the gradient settings. The evaluator callable is usually provide
by a Evaluator object. The
plugin_manager is used to load the realization filters, function
estimators, and samplers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
EnOptContext
|
The optimization context object. |
required |
evaluator
|
EvaluatorCallback
|
The callable for evaluating individual functions. |
required |
calculate
calculate(
variables: NDArray[float64],
*,
compute_functions: bool,
compute_gradients: bool,
) -> tuple[Results, ...]
Evaluate the given variable vectors.
This method calculates functions, gradients, or both, based on the provided variable vectors and the specified flags.
The variables argument can be a single vector or a matrix where each
row is a variable vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
NDArray[float64]
|
The variable vectors to evaluate. |
required |
compute_functions
|
bool
|
Whether to calculate functions. |
required |
compute_gradients
|
bool
|
Whether to calculate gradients. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Results, ...]
|
The results for function evaluations and/or gradient evaluations. |