Enumerations
ropt.enums
Enumerations used in the configuration, event and result APIs.
A member of a string-valued enumeration is a str, so wherever one is accepted
its value may be written instead:
VariableType,
BoundaryType,
PerturbationType and
AxisName.
VariableType
Bases: StrEnum
Enumerates the types of optimization variables.
Specified in VariablesConfig, this
information allows optimization backends to adapt their behavior.
BoundaryType
Bases: StrEnum
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
class-attribute
instance-attribute
Truncate the value \(v_i\) at the lower or upper boundary (\(l_i\), \(u_i\)):
PerturbationType
Bases: StrEnum
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).
EnOptEventType
Bases: IntEnum
Enumerates the types of events emitted during a run.
See Handling Results for when each event type fires and what data it carries.
START_EVALUATION
class-attribute
instance-attribute
Emitted before a batch of function or gradient evaluations.
FINISHED_EVALUATION
class-attribute
instance-attribute
Emitted after that batch completes; carries the results produced.
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 before an evaluation without an optimizer begins.
ExitCode
Bases: IntEnum
Enumerates the reasons a task ends.
An optimization either stops or is aborted. It stops when a
condition on the optimization is met — the optimizer converged, a budget
ran out, a handler decided the results were good enough — so it ends at a
point that satisfied a stated criterion, and its result carries the code. A
task of any kind is aborted when something ends it regardless of its state,
and it then raises AbortedError, which
carries the code.
Each member carries a short description in
message, for reporting.
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.
STOPPED
class-attribute
instance-attribute
Returned when an event handler asked the optimization to stop.
A graceful end at an evaluation boundary, on a criterion the caller supplied. A result callback is such a handler.
FINISHED
class-attribute
instance-attribute
Returned when the optimizer ended the optimization.
EXECUTOR_SHUT_DOWN
class-attribute
instance-attribute
Carried by AbortedError when the executor could no longer run the work.
Not a failure: in practice the interpreter was shutting down and the worker
pool was gone, so the task is released rather than left waiting. An executor
that breaks raises ExecutionError
instead.
ABORTED
class-attribute
instance-attribute
Carried by AbortedError when the task was aborted from outside, without
regard to where it had got to.
This is what closing a session, or a KeyboardInterrupt passing through a
task, gives a task still under way.
ABORTED_ON_ERROR
class-attribute
instance-attribute
Carried by AbortedError when another task raised, and this one was
aborted with it.
USER_ABORT
class-attribute
instance-attribute
Carried by AbortedError when Session.abort
aborted the task.
Set apart from ABORTED so that an abort
that was asked for can be told from one the library performed itself.
AxisName
Bases: StrEnum
Enumerates the semantic meaning of axes in data arrays.
Labels what each dimension of a Results field's
multidimensional array represents, and is used to look up axis labels via
get_axes. See
Working with Results
for a full table of fields and their axes.
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.