Constraints API

The Constraints API provides the constraint programming functionality for move filtering.

CP Variables

IntVariable

JuLS.IntVariableType
struct IntVariable <: CPVariable

A "simple" integer variable, whose domain can be any set of integers. The constraints that affect this variable are stored in the on_domain_change array.

source

BoolVariable

JuLS.BoolVariableType
struct BoolVariable <: AbstractVar

A "simple" boolean variable. The constraints that affect this variable are stored in the on_domain_change array.

source

CP Constraints

Basic Constraints

JuLS.NotEqualType
struct NotEqual <: CPConstraint

CPConstraint x != y between two CPVariables x and y.

source
JuLS.SumLessThanType
struct SumLessThan <: CPConstraint

CPConstraint ∑(x_i ∀ i ∈ |x|) ≤ upper

Filtering: The goal is to enforce the constraint: ∑(x_i ∀ i ∈ |x|) ≤ upper

We can rewrite as: xi + ∑(xj ∀ j != i) ≤ upper → xi ≤ - ∑(xj ∀ j != i) + upper

Therefore, the tighest bound on xi (maximum value xi can take) is: xi = - ∑(xj ∀ j != i) + upper

We know that:

    • ∑(xj ∀ j != i) ≤ - ∑(min(xj) ∀ j != i)
    • ∑(min(xj) ∀ j != i) = min(xi) - ∑(min(x_i) ∀ i ∈ |x|)

Rewrite:

  • ∑(xj ∀ j != i) ≤ min(xi) - ∑(min(xi) ∀ i ∈ |x|) xi - upper ≤ min(xi) - ∑(min(xi) ∀ i ∈ |x|)

xi ≤ min(xi) - ∑(min(x_i) ∀ i ∈ |x|) + upper This means that we can prune all values greater than - ∑(min(xj) ∀ j != i) + upper from xi's domain

source

Integration with DAG

CP constraints are automatically generated from DAG invariants when using_cp = true.