Skip to content

Enumerations

ropt.enums

Enumerations used within the ropt library.

VariableType

Bases: IntEnum

Enumerates the types of optimization variables.

Specified in VariablesConfig, this information allows optimization backends to adapt their behavior.

REAL class-attribute instance-attribute

REAL = 1

Continuous variables represented by real values.

INTEGER class-attribute instance-attribute

INTEGER = 2

Discrete variables represented by integer values.

BoundaryType

Bases: IntEnum

Enumerates strategies for handling variable boundary violations.

When variables are perturbed during optimization, their values might fall outside the defined lower and upper bounds. This enumeration defines different methods to adjust these perturbed values back within the valid range. The chosen strategy is configured in the GradientConfig.

NONE class-attribute instance-attribute

NONE = 1

Do not modify the value.

TRUNCATE_BOTH class-attribute instance-attribute

TRUNCATE_BOTH = 2

Truncate the value \(v_i\) at the lower or upper boundary (\(l_i\), \(u_i\)):

\[ \hat{v_i} = \begin{cases} l_i & \text{if $v_i < l_i$}, \\ b_i & \text{if $v_i > b_i$}, \\ v_i & \text{otherwise} \end{cases} \]

MIRROR_BOTH class-attribute instance-attribute

MIRROR_BOTH = 3

Mirror the value \(v_i\) at the lower or upper boundary (\(l_i\), \(u_i\)):

\[ \hat{v_i} = \begin{cases} 2l_i - v_i & \text{if $v_i < l_i$}, \\ 2b_i - v_i & \text{if $v_i > b_i$}, \\ v_i & \text{otherwise} \end{cases} \]

PerturbationType

Bases: IntEnum

Enumerates methods for scaling perturbation samples.

Before a generated perturbation sample is added to a variable's current value (during gradient estimation, for example), it can be scaled. This enumeration defines the available scaling methods, configured in the GradientConfig.

ABSOLUTE class-attribute instance-attribute

ABSOLUTE = 1

Use the perturbation value as is.

RELATIVE class-attribute instance-attribute

RELATIVE = 2

Multiply the perturbation value \(p_i\) by the range defined by the bounds of the variables \(c_i\): \(\hat{p}_i = (c_{i,\text{max}} - c_{i,\text{min}}) \times p_i\). The bounds will generally be defined in the configuration for the variables (see VariablesConfig).

EventType

Bases: IntEnum

Enumerates the types of events emitted during optimization plan execution.

Events signal significant occurrences within the optimization process, such as the start or end of a plan step or an evaluation. Callbacks can be registered to listen for specific event types.

When an event occurs, registered callbacks receive an Event object containing:

  • event_type: The type of the event (a value from this enumeration).
  • config: The configuration object associated with the source.
  • source: The unique ID (UUID) of the plan component that emitted the event.
  • data: A dictionary containing event-specific data, such as Results objects.

Refer to the documentation of individual event types and plan components for details on the specific data they provide.

START_EVALUATION class-attribute instance-attribute

START_EVALUATION = 1

Emitted before evaluating new functions.

FINISHED_EVALUATION class-attribute instance-attribute

FINISHED_EVALUATION = 2

Emitted after finishing the evaluation.

START_OPTIMIZER_STEP class-attribute instance-attribute

START_OPTIMIZER_STEP = 3

Emitted just before starting an optimizer step.

FINISHED_OPTIMIZER_STEP class-attribute instance-attribute

FINISHED_OPTIMIZER_STEP = 4

Emitted immediately after an optimizer step finishes.

START_ENSEMBLE_EVALUATOR_STEP class-attribute instance-attribute

START_ENSEMBLE_EVALUATOR_STEP = 5

Emitted just before starting an evaluation step.

FINISHED_ENSEMBLE_EVALUATOR_STEP class-attribute instance-attribute

FINISHED_ENSEMBLE_EVALUATOR_STEP = 6

Emitted immediately after an evaluation step finishes.

ExitCode

Bases: IntEnum

Enumerates the reasons for terminating an optimization.

UNKNOWN class-attribute instance-attribute

UNKNOWN = 0

Unknown cause of termination.

TOO_FEW_REALIZATIONS class-attribute instance-attribute

TOO_FEW_REALIZATIONS = 1

Returned when too few realizations are evaluated successfully.

MAX_FUNCTIONS_REACHED class-attribute instance-attribute

MAX_FUNCTIONS_REACHED = 2

Returned when the maximum number of function evaluations is reached.

MAX_BATCHES_REACHED class-attribute instance-attribute

MAX_BATCHES_REACHED = 3

Returned when the maximum number of evaluation batches is reached.

NESTED_OPTIMIZER_FAILED class-attribute instance-attribute

NESTED_OPTIMIZER_FAILED = 4

Returned when a nested optimization fails to find an optimal value.

USER_ABORT class-attribute instance-attribute

USER_ABORT = 5

Returned when the optimization is aborted by the user.

OPTIMIZER_STEP_FINISHED class-attribute instance-attribute

OPTIMIZER_STEP_FINISHED = 6

Returned when an optimization step terminates normally.

EVALUATOR_STEP_FINISHED class-attribute instance-attribute

EVALUATOR_STEP_FINISHED = 7

Returned when an evaluation step terminates normally.

AxisName

Bases: StrEnum

Enumerates the semantic meaning of axes in data arrays.

The optimization workflow includes variables, objectives, constraints, realizations, and the optimizer. Each of these components can have multiple instances, leading to multidimensional data arrays. In particular, the Results objects store optimization data (like variable values, objective function values, constraint values, etc.) in multidimensional NumPy arrays.

The AxisName enumeration provides standardized labels to identify what each dimension (axis) of these arrays represents. For example, an array might have dimensions corresponding to different realizations, different objective functions, or different variables.

This information is stored as metadata within the Results object and can be accessed using methods like get_axes on result fields. It is used internally, for instance, during data export to correctly label axes or retrieve associated names (like variable names) from the configuration.

VARIABLE class-attribute instance-attribute

VARIABLE = 'variable'

The axis index corresponds to the index of the variable.

OBJECTIVE class-attribute instance-attribute

OBJECTIVE = 'objective'

The axis index corresponds to the index of the objective function.

LINEAR_CONSTRAINT class-attribute instance-attribute

LINEAR_CONSTRAINT = 'linear_constraint'

The axis index corresponds to the index of the linear constraint.

NONLINEAR_CONSTRAINT class-attribute instance-attribute

NONLINEAR_CONSTRAINT = 'nonlinear_constraint'

The axis index corresponds to the index of the constraint function.

REALIZATION class-attribute instance-attribute

REALIZATION = 'realization'

The axis index corresponds to the index of the realization.

PERTURBATION class-attribute instance-attribute

PERTURBATION = 'perturbation'

The axis index corresponds to the index of the perturbation.