Skip to content

ConstraintCommons.jl

ConstraintCommons.jl is an essential package within the Julia Constraints ecosystem designed to facilitate the development and interoperability of constraint programming solutions in Julia. It serves as a foundational layer that provides shared structures, abstract types, functions, and generic methods utilized by both basic feature packages and learning-oriented packages.

Only advanced users or package developers are likely to use it. The package covers parameters, (regular) languages, Core or Base methods extensions, sampling, extrema, and dictionaries.

Parameters

This section of the package list or extract parameters based on the XCSP3-core specifications. Note that, for the foreseeable future, the default constraints specification will follow the XCSP3 format.

# ConstraintCommons.USUAL_CONSTRAINT_PARAMETERSConstant.
julia
const USUAL_CONSTRAINT_PARAMETERS

List of usual constraints parameters (based on XCSP3-core constraints).

julia
const USUAL_CONSTRAINT_PARAMETERS = [
    :bool,
    :dim,
    :id,
    :language,
    :op,
    :pair_vars,
    :val,
    :vals,
]

source


# ConstraintCommons.extract_parametersFunction.
julia
extract_parameters(m::Union{Method, Function}; parameters)

Extracts the intersection between the kargs of m and parameters (defaults to USUAL_CONSTRAINT_PARAMETERS).

source

julia
extract_parameters(s::Symbol, constraints_dict=USUAL_CONSTRAINTS; parameters=ConstraintCommons.USUAL_CONSTRAINT_PARAMETERS)

Return the parameters of the constraint s in constraints_dict.

Arguments

  • s::Symbol: the constraint name.

  • constraints_dict::Dict{Symbol,Constraint}: dictionary of constraints. Default is USUAL_CONSTRAINTS.

  • parameters::Vector{Symbol}: vector of parameters. Default is ConstraintCommons.USUAL_CONSTRAINT_PARAMETERS.

Example

julia
extract_parameters(:all_different)

source


Performances

Bench Evolution ParametersChair Evolution Parameters

Languages

XCSP3 considers two kinds of structure to recognize languages as core constraints: Automata, Multivalued Decision Diagrams (MMDs).

# ConstraintCommons.AbstractMultivaluedDecisionDiagramType.
julia
AbstractMultivaluedDecisionDiagram

An abstract interface for Multivalued Decision Diagrams (MDD) used in Julia Constraints packages. Requirements:

  • accept(a<:AbstractMultivaluedDecisionDiagram, word): return true if a accepts word.

source


# ConstraintCommons.MDDType.
julia
MDD{S,T} <: AbstractMultivaluedDecisionDiagram

A minimal implementation of a multivalued decision diagram structure.

source


# ConstraintCommons.AbstractAutomatonType.
julia
AbstractAutomaton

An abstract interface for automata used in Julia Constraints packages. Requirements:

  • accept(a<:AbstractAutomaton, word): return true if a accepts word.

source


# ConstraintCommons.AutomatonType.
julia
Automaton{S, T, F <: Union{S, Vector{S}, Set{S}}} <: AbstractAutomaton

A minimal implementation of a deterministic automaton structure.

source


Missing docstring.

Missing docstring for Automaton(a::MDD). Check Documenter's build log for details.

# ConstraintCommons.acceptFunction.
julia
accept(a::Union{Automaton, MDD}, w)

Return true if a accepts the word w and false otherwise.

source

julia
ConstraintCommons.accept(fa::FakeAutomaton, word)

Implement the accept methods for FakeAutomaton.

source


# ConstraintCommons.at_endFunction.
julia
at_end(a::Automaton, s)

Internal method used by accept with Automaton.

source


Performances

Bench Evolution Automata
Chair Evolution Automata
Bench Evolution Diagrams
Chair Evolution Diagrams

Extensions

We extended some operations for Nothing and Symbol.

Missing docstring.

Missing docstring for Base.:*. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Base.in(::Any, ::Nothing). Check Documenter's build log for details.

Missing docstring.

Missing docstring for Base.isempty(::Nothing). Check Documenter's build log for details.

Performances

Bench Evolution Nothing
Chair Evolution Nothing
Bench Evolution Symbols
Chair Evolution Symbols

Sampling

During our constraint learning processes, we use sampling to efficiently make partial exploration of search spaces. Follows some sampling utilities.

# ConstraintCommons.oversampleFunction.
julia
oversample(X, f)

Oversample elements of X until the boolean function f has as many true and false configurations.

source


Performances

Bench EvolutionChair Evolution

Extrema

We need to compute the difference between extrema of various kind of collections in several situations.

# ConstraintCommons.δ_extremaFunction.
julia
δ_extrema(X...)

Compute both the difference between the maximum and the minimum of over all the collections of X.

source


Bench EvolutionChair Evolution

Performances

Dictionaries

We provide the everuseful incsert! function for dictionaries.

# ConstraintCommons.incsert!Function.
julia
incsert!(d::Union{AbstractDict, AbstractDictionary}, ind, val = 1)

Increase or insert a counter in a dictionary-based collection. The counter insertion defaults to val = 1.

source


Performances

Bench EvolutionChair Evolution