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 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 asResults
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
Emitted before evaluating new functions.
FINISHED_EVALUATION
class-attribute
instance-attribute
Emitted after finishing the evaluation.
START_OPTIMIZER_STEP
class-attribute
instance-attribute
Emitted just before starting an optimizer step.
FINISHED_OPTIMIZER_STEP
class-attribute
instance-attribute
Emitted immediately after an optimizer step finishes.
START_ENSEMBLE_EVALUATOR_STEP
class-attribute
instance-attribute
Emitted just before starting an evaluation step.
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_STEP_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.