Binary Constraint
Overview
Binary Constraints in Verteego enable direct comparison or interaction between two columns within a dataset, which can be either variable or static. This type of constraint is applied on a row-by-row basis, making it suitable for conditions where variables within the same dataset must maintain a specific relationship to one another.
Application
Binary Constraints are commonly used to enforce relationships such as ensuring one value remains greater than or less than another (e.g., a product’s price must always be higher than a competitor’s price).
Parameters
where: An optional dictionary of key-value pairs that filters rows based on specified conditions. For instance, setting
where={"month": [1, 2, 3], "year": 2022}
would apply the constraint only to rows from the first quarter of 2022, ignoring all others.left_column: Specifies the column containing the variable or static number to be constrained.
left_column_weight: Optional. A column containing weights to be applied to values in the
left_column
.operator: Defines the relationship between the left and right column values. Options are
equal
,lesser
(less than or equal to), andgreater
(greater than or equal to).right_column: Specifies the column against which the
left_column
is being constrained.right_column_weight: Similar to
left_column_weight
, for applying weights to theright_column
.delta: An optional numerical value that offsets the constraint, adding flexibility to the condition (e.g.,
price must be greater than competition_price + 1
).relax: Indicates whether the constraint can be relaxed (with a penalty that gets reported). Defaults to
false
.
Examples
Below are examples of YAML configurations for binary constraints:
Setting a Minimum Price Above Competition:
Setting a Maximum Price Below an Upper Limit:
Best Practices
When implementing Binary Constraints, it is crucial to:
Select relevant columns for the left and right sides of the equation to ensure meaningful comparisons.
Use appropriate weights and deltas to refine the conditions under which constraints apply.
Consider using the
relax
parameter for scenarios where strict adherence to constraints might not always be possible or desirable, allowing for more flexible optimization solutions.
Last updated