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 defaultConstraint()
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 instantiatingc
, it will check the existence of a composition related toc
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_different
— Constant_all_different
Global constraint ensuring that all the values of a given configuration are unique.
Constraints.all_equal
— Constantall_equal
Global constraint ensuring that all the values of x
are all equal.
Constraints.all_equal_param
— Constantall_equal_param
Global constraint ensuring that all the values of x
are all equal to a given parameter param
.
Constraints.dist_different
— Constantdist_different
Local constraint ensuring that concept(dist_different, x) = |x[1] - x[2]| ≠ |x[3] - x[4]|)
.
Constraints.eq
— Constanteq
Equality between two variables.
Constraints.ordered
— Constantordered(x)
Global constraint ensuring that all the values of x
are ordered.
Constraints.usual_constraints
— Constantusual_constraints::Dict
Dictionary that contains all the usual constraints defined in Constraint.jl.
Constraints.usual_symmetries
— Constantsymmetries
A Dictionary that contains the function to apply for each symmetry to avoid searching a whole space.
Constraints.Constraint
— TypeConstraint
Parametric stucture with the following fields.
concept
: a Boolean function that, given an assignmentx
, outputstrue
ifx
satisfies the constraint, andfalse
otherwise.error
: a positive function that works as preferences over invalid assignements. Return0.0
if the constraint is satisfied, and a strictly positive real otherwise.
Constraints.args_length
— Methodargs_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.concept
— Methodconcept(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_f
— Methoderror_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_length
— Methodparams_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.
Constraints.symmetries
— Methodsymmetries(c::Constraint)
Return the list of symmetries of c
.