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.
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.
TRUNCATE_BOTH
class-attribute
instance-attribute
Truncate the value \(v_i\) at the lower or upper boundary (\(l_i\), \(u_i\)):
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.
RELATIVE
class-attribute
instance-attribute
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 workflow execution.
Events signal significant occurrences within the optimization process, such as the start or end of an optimization 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).data: A dictionary containing event-specific data, such asResultsobjects.
START_EVALUATION
class-attribute
instance-attribute
Emitted before evaluating new functions.
FINISHED_EVALUATION
class-attribute
instance-attribute
Emitted after finishing the evaluation.
START_OPTIMIZER
class-attribute
instance-attribute
Emitted just before starting an optimizer.
FINISHED_OPTIMIZER
class-attribute
instance-attribute
Emitted immediately after an optimizer finishes.
START_ENSEMBLE_EVALUATOR
class-attribute
instance-attribute
Emitted just before starting an evaluation.
ExitCode
Bases: IntEnum
Enumerates the reasons for terminating an optimization.
TOO_FEW_REALIZATIONS
class-attribute
instance-attribute
Returned when too few realizations are evaluated successfully.
MAX_FUNCTIONS_REACHED
class-attribute
instance-attribute
Returned when the maximum number of function evaluations is reached.
MAX_BATCHES_REACHED
class-attribute
instance-attribute
Returned when the maximum number of evaluation batches is reached.
NESTED_OPTIMIZER_FAILED
class-attribute
instance-attribute
Returned when a nested optimization fails to find an optimal value.
USER_ABORT
class-attribute
instance-attribute
Returned when the optimization is aborted by the user.
OPTIMIZER_FINISHED
class-attribute
instance-attribute
Returned when an optimization 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
The axis index corresponds to the index of the variable.
OBJECTIVE
class-attribute
instance-attribute
The axis index corresponds to the index of the objective function.
LINEAR_CONSTRAINT
class-attribute
instance-attribute
The axis index corresponds to the index of the linear constraint.
NONLINEAR_CONSTRAINT
class-attribute
instance-attribute
The axis index corresponds to the index of the constraint function.
REALIZATION
class-attribute
instance-attribute
The axis index corresponds to the index of the realization.