Skip to content

Evaluators

ropt.plugins.evaluator.base.EvaluatorPlugin

Bases: Plugin

Abstract base class for evaluator plugins.

This class defines the interface for plugins responsible for creating Evaluator instances within an optimization workflow.

create abstractmethod classmethod

create(name: str, **kwargs: Any) -> Evaluator

Create an Evaluator instance.

This abstract class method serves as a factory for creating concrete Evaluator objects. Plugin implementations must override this method to return an instance of their specific Evaluator subclass.

The PluginManager calls this method when an evaluator provided by this plugin is requested.

The name argument specifies the requested evaluator, potentially in the format "plugin-name/method-name" or just "method-name". Implementations can use this name to vary the created evaluator if the plugin supports multiple evaluator types.

Parameters:

Name Type Description Default
name str

The requested evaluator name (potentially plugin-specific).

required
kwargs Any

Additional arguments for custom configuration.

{}

Returns:

Type Description
Evaluator

An initialized instance of an Evaluator subclass.

ropt.plugins.evaluator.base.Evaluator

Bases: ABC

Abstract base class for evaluator components within an optimization workflow.

Subclasses must implement the abstract eval method, which is responsible for performing the actual evaluation of variables using an EvaluatorContext and returning an EvaluatorResult.

Evaluator instances are typically created using the create_evaluator function.

eval abstractmethod

eval(
    variables: NDArray[float64], context: EvaluatorContext
) -> EvaluatorResult

Evaluate objective and constraint functions for given variables.

This method defines function evaluator callback, which calculates objective and constraint functions for a set of variable vectors, potentially for a subset of realizations and perturbations.

Parameters:

Name Type Description Default
variables NDArray[float64]

The matrix of variables to evaluate. Each row represents a variable vector.

required
context EvaluatorContext

The evaluation context, providing additional information about the evaluation.

required

Returns:

Type Description
EvaluatorResult

An evaluation results object containing the calculated values.

Reusing Objectives and Constraints

When defining multiple objectives, there may be a need to reuse the same objective or constraint value multiple times. For instance, a total objective could consist of the mean of the objectives for each realization, plus the standard deviation of the same values. This can be implemented by defining two objectives: the first calculated as the mean of the realizations, and the second using a function estimator to compute the standard deviations. The optimizer is unaware that both objectives use the same set of realizations. To prevent redundant calculations, the evaluator should compute the results of the realizations once and return them for both objectives.