Skip to main content

Soft Constraints

The (assert-soft formula [:weight numeral] [:id id]) command asserts a weighted soft constraint. The weight must be a positive natural number, but is optional. If omitted, the weight is set to 1.

Floating point and integer weights can be mixed; internally weights are converted into rational numbers.

You can use identifiers to group soft constraints. You can also repeat the same soft constraint. Every repetition counts independently. In the example we add the soft constraint a twice and force it to be false. The penalty for group x is therefore 2. The penalty for group y is because there is only one soft constraint that is impossible to satisfy.