Constraints.jl

A back-end package for JuliaConstraints front packages, such as LocalSearchSolvers.jl.

It provides the following features:

  • A dictionary to store usual constraint: usual_constraint, which contains the following entries
    • :all_different
    • :dist_different
    • :eq, :all_equal, :all_equal_param
    • :ordered
    • :always_true (mainly for testing default Constraint() constructor)
  • For each constraint c, the following properties
    • arguments length
    • concept (predicate the variables compliance with c)
    • error (a function that evaluate how much c is violated)
    • parameters length
    • known symmetries of c
  • A learning function using CompositionalNetworks.jl. If no error function is given when instantiating c, it will check the existence of a composition related to c and set the error to it.

Follow the list of the constraints currently stored in usual_constraint. Note that if the constraint is named _my_constraint, it can be accessed as usual_constraint[:my_constraint].

Constraints.all_differentConstant
_all_different

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

Constraints.all_equalConstant
all_equal

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

Constraints.all_equal_paramConstant
all_equal_param

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

Constraints.dist_differentConstant
dist_different

Local constraint ensuring that concept(dist_different, x) = |x[1] - x[2]| ≠ |x[3] - x[4]|).

Constraints.orderedConstant
ordered(x)

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

Constraints.usual_symmetriesConstant
symmetries

A Dictionary that contains the function to apply for each symmetry to avoid searching a whole space.

Constraints.ConstraintType
Constraint

Parametric stucture with the following fields.

  • concept: a Boolean function that, given an assignment x, outputs true if x satisfies the constraint, and false otherwise.
  • error: a positive function that works as preferences over invalid assignements. Return 0.0 if the constraint is satisfied, and a strictly positive real otherwise.
Constraints.args_lengthMethod
args_length(c::Constraint)

Return the expected length restriction of the arguments in a constraint c. The value nothing indicates that any strictly positive number of value is accepted.

Constraints.conceptMethod
concept(c::Constraint)

Return the concept (function) of constraint c. concept(c::Constraint, x...; param = nothing) Apply the concept of c to values x and optionally param.

Constraints.error_fMethod
error_f(c::Constraint)

Return the error function of constraint c. error_f(c::Constraint, x; param = nothing) Apply the error function of c to values x and optionally param.

Constraints.params_lengthMethod
params_length(c::Constraint)

Return the expected length restriction of the arguments in a constraint c. The value nothing indicates that any strictly positive number of parameters is accepted.