Evaluation Classes
The ropt.evaluation module defines the data structures exchanged between ropt
and user-provided evaluation functions: an input context describing which rows
must be evaluated, an output container for the objective and constraint values,
and the protocol that user callables must follow.
For detailed usage, including examples of handling inactive rows and partial
failures, see Writing Evaluation Callbacks.
For higher-level Evaluator classes used by the workflow components, see
Evaluators.
ropt.evaluation.EvaluationBatchContext
dataclass
Per-batch metadata passed to evaluator functions.
See Writing Evaluation Callbacks for usage details and examples.
Attributes:
| Name | Type | Description |
|---|---|---|
context |
EnOptContext
|
The |
active |
NDArray[bool_]
|
Boolean array indicating which rows require evaluation. |
realizations |
NDArray[intc]
|
Realization index for each row. |
perturbations |
NDArray[intc] | None
|
Perturbation index for each row (< 0 means unperturbed). |
batch_id |
int
|
Integer identifying the current evaluation batch. |
metadata |
dict[str, Any] | None
|
The metadata the run was started with, if any. |
get_active_evaluations
Return only the rows of array where active is True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
NDArray[T]
|
A 1-D or 2-D array with one entry/row per variable vector. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[T]
|
The subset of rows corresponding to active evaluations. |
insert_inactive_results
Expand a filtered array back to full size, filling inactive rows.
Inserts fill_value at positions where active is False, restoring
the array to its original number of rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
NDArray[T]
|
The filtered array (output of |
required |
fill_value
|
float
|
The value to insert for inactive entries. |
0.0
|
Returns:
| Type | Description |
|---|---|
NDArray[T]
|
An expanded array matching the original number of rows. |
ropt.evaluation.EvaluationBatchResult
dataclass
Results of a function evaluation batch.
Stores objective values (and optional constraint values) for a batch of
variable vectors. Inactive rows should be set to zero; failed active rows
should be set to numpy.nan.
See Writing Evaluation Callbacks for
batch_id management and other conventions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objectives
|
NDArray[float64]
|
Objective values, shape |
required |
constraints
|
NDArray[float64] | None
|
Optional constraint values, shape |
None
|
batch_id
|
int
|
Integer identifying this evaluation batch. |
0
|
metadata
|
dict[str, NDArray[Any]]
|
Optional dict of per-row metadata (not used internally by |
dict()
|
ropt.evaluation.EvaluationBatchCallback
Bases: Protocol
Defines the call signature for batch evaluation callbacks.
__call__
Evaluate the given variables within the provided context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
NDArray[float64]
|
The variables to pass to the evaluation function. |
required |
context
|
EvaluationBatchContext
|
The evaluator context to pass. |
required |
Returns:
| Type | Description |
|---|---|
EvaluationBatchResult
|
The results of the evaluation. |