Outcome Constraint#
- class blop.ax.objective.OutcomeConstraint(constraint, **outcomes)[source]
Bases:
objectA constraint on an outcome of a suggestion.
Outcome constraints guide the optimizer to prefer solutions that satisfy certain conditions on the measured outcomes. This is a soft constraint, meaning that the constraint may be violated during exploration but will be increasingly satisfied as optimization progresses.
- Parameters:
- constraintstr
The constraint expression to evaluate. Must be a valid inequality using operators like <=, >=, <, >. Variable names in the expression are mapped to outcomes via keyword arguments.
- **outcomesObjective | IMetric
Keyword arguments mapping variables in the expression to objectives or metrics.
Notes
The variable names used in the constraint expression (e.g., “temp”, “i”, “w”) are arbitrary and do not need to match the objective names. They are mapped to objectives via the keyword arguments for readability.
Outcome constraints differ from DOF constraints in that they constrain the measured outcomes rather than the input parameters.
Examples
Constrain an objective to be below a threshold:
>>> from blop.ax.objective import Objective, OutcomeConstraint >>> temp_obj = Objective(name="temperature", minimize=True) >>> constraint = OutcomeConstraint("temp <= 100", temp=temp_obj) >>> print(constraint) temperature <= 100
For complete examples with multiple constraints, see Set outcome constraints.
- property ax_constraint: str
Convert the constraint to a string that can be used by Ax.
- Returns:
- str
The constraint expression with objective names substituted.