Constraints

In the LocalSearchSolvers.jl framework, a constraint can be define using either a concept (a predicate over a set of variables) or an error function. Additionally some constraints are already defined in Constraints.jl.

As the recommended usage is through the CBLS.jl package and the JuMP.jl interface, we provide the related documentation here.

Predicates and Error Functions

CBLS.Predicate — Type
Predicate{F <: Function} <: JuMP.AbstractVectorSet

Assuming X is a (collection of) variables, concept a boolean function over X, and that a model is defined. In JuMP syntax we can create a constraint based on concept as follows.

@constraint(model, X in Predicate(concept))
CBLS.Error — Type
Error{F <: Function} <: JuMP.AbstractVectorSet

The solver will compute a straightforward error function based on the concept. To run the solver efficiently, it is possible to provide an error function err instead of concept. err must return a nonnegative real number.

@constraint(model, X in Error(err))

Finally, one can compute the error function from a concept automatically using Interpretable Compositional Networks (ICN). Automatic computation through the CompositionalNetworks.jl package will soon be added within the JuMP syntax. In the mean time, please use this dependency directly.

Usual Constraints

Some usual constraints are already available directly through JuMP syntax. Do not hesitate to file an issue to include more usual constraints.

CBLS.AllDifferent — Type

Global constraint ensuring that all the values of a given configuration are unique.

@constraint(model, X in AllDifferent())
CBLS.AllEqual — Type

Global constraint ensuring that all the values of X are all equal.

@constraint(model, X in AllEqual())
CBLS.AllEqualParam — Type

Global constraint ensuring that all the values of X are all equal to a given parameter param.

@constraint(model, X in AllEqualParam(param))
CBLS.AlwaysTrue — Type

Always return true. Mainly used for testing purpose.

@constraint(model, X in AlwaysTrue())
CBLS.DistDifferent — Type

Local constraint ensuring that, given a vector X of size 4, |X[1] - X[2]| ≠ |X[3] - X[4]|).

@constraint(model, X in DistDifferent())
CBLS.Eq — Type

Equality between two variables.

@constraint(model, X in Eq())
CBLS.Ordered — Type

Global constraint ensuring that all the values of x are ordered.

@constraint(model, X in Ordered())