DOF Constraint#
- class blop.ax.dof.DOFConstraint(constraint, **dofs)[source]
Bases:
objectA constraint on DOFs to refine the search space.
Use DOF constraints to exclude regions of the search space that are invalid, unsafe, or uninteresting. Constraints are expressed as inequality expressions involving DOF parameters.
- Parameters:
- constraintstr
The constraint expression to evaluate. Must be a valid inequality using operators like <=, >=, <, >. Variable names in the expression are mapped to DOFs via keyword arguments.
- **dofsDOF
Keyword arguments mapping variables in the constraint to DOFs.
Notes
The variable names used in the constraint expression (e.g., “x”, “y”) are arbitrary and do not need to match the DOF parameter names. They are mapped to DOFs via the keyword arguments for readability.
Examples
Define a constraint that ensures the sum of two DOFs is less than a value:
>>> from blop.ax.dof import DOFConstraint, RangeDOF >>> x_dof = RangeDOF(name="x", bounds=(0, 10), parameter_type="float") >>> y_dof = RangeDOF(name="y", bounds=(0, 10), parameter_type="float") >>> constraint = DOFConstraint("x + y <= 12", x=x_dof, y=y_dof)
- property ax_constraint: str
Convert the constraint to a string that can be used by Ax.
- Returns:
- str
The constraint expression with DOF names substituted.