From d749c9ae528390d0103454a370eb4a4bde828f4a Mon Sep 17 00:00:00 2001 From: Nicola Di Cicco <93935338+nicoladicicco@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:03:16 +0900 Subject: [PATCH 1/5] remove leading tabs in constraint descriptions --- src/constraints/all_different.jl | 2 +- src/constraints/all_equal.jl | 2 +- src/constraints/mdd.jl | 5 ++--- src/constraints/ordered.jl | 10 +++++----- src/constraints/regular.jl | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/constraints/all_different.jl b/src/constraints/all_different.jl index 5bff73e..3aa195f 100644 --- a/src/constraints/all_different.jl +++ b/src/constraints/all_different.jl @@ -1,7 +1,7 @@ #!SECTION - all_different const description_all_different = """ - Global constraint ensuring that all the values of `x` are all different. +Global constraint ensuring that all the values of `x` are all different. """ """ diff --git a/src/constraints/all_equal.jl b/src/constraints/all_equal.jl index 8c311ad..5509a49 100644 --- a/src/constraints/all_equal.jl +++ b/src/constraints/all_equal.jl @@ -1,7 +1,7 @@ #!SECTION - all_equal const description_all_equal = """ - Global constraint ensuring that all the values of `x` are all equal. +Global constraint ensuring that all the values of `x` are all equal. """ concept_all_equal(x, val) = all(y -> y == val, x) diff --git a/src/constraints/mdd.jl b/src/constraints/mdd.jl index 3ef7085..9677f09 100644 --- a/src/constraints/mdd.jl +++ b/src/constraints/mdd.jl @@ -1,9 +1,8 @@ #!SECTION - Multi-valued Decision Diagram const description_mdd = """ - Multi-valued Decision Diagram (MDD) constraint. - - The MDD constraint is a constraint that can be used to model a wide range of problems. It is a directed graph where each node is labeled with a value and each edge is labeled with a value. The constraint is satisfied if there is a path from the first node to the last node such that the sequence of edge labels is a valid sequence of the value labels. +Multi-valued Decision Diagram (MDD) constraint. +The MDD constraint is a constraint that can be used to model a wide range of problems. It is a directed graph where each node is labeled with a value and each edge is labeled with a value. The constraint is satisfied if there is a path from the first node to the last node such that the sequence of edge labels is a valid sequence of the value labels. """ """ diff --git a/src/constraints/ordered.jl b/src/constraints/ordered.jl index 3842196..6a4148c 100644 --- a/src/constraints/ordered.jl +++ b/src/constraints/ordered.jl @@ -1,21 +1,21 @@ const description_ordered = """ - Global constraint ensuring that all the values of `x` are in an increasing order. +Global constraint ensuring that all the values of `x` are in an increasing order. """ const description_increasing = """ - Global constraint ensuring that all the values of `x` are in an increasing order. +Global constraint ensuring that all the values of `x` are in an increasing order. """ const description_decreasing = """ - Global constraint ensuring that all the values of `x` are in a decreasing order. +Global constraint ensuring that all the values of `x` are in a decreasing order. """ const description_sctrictly_increasing = """ - Global constraint ensuring that all the values of `x` are in a strictly increasing order. +Global constraint ensuring that all the values of `x` are in a strictly increasing order. """ const description_strictly_decreasing = """ - Global constraint ensuring that all the values of `x` are in a strictly decreasing order. +Global constraint ensuring that all the values of `x` are in a strictly decreasing order. """ """ diff --git a/src/constraints/regular.jl b/src/constraints/regular.jl index 71ffafc..7a2b0b1 100644 --- a/src/constraints/regular.jl +++ b/src/constraints/regular.jl @@ -1,5 +1,5 @@ const description_regular = """ - Ensures that a sequence `x` (interpreted as a word) is accepted by the regular language represented by a given automaton. This constraint verifies the compliance of `x` with the language rules encoded within the `automaton` parameter, which must be an instance of `<:AbstractAutomaton`. +Ensures that a sequence `x` (interpreted as a word) is accepted by the regular language represented by a given automaton. This constraint verifies the compliance of `x` with the language rules encoded within the `automaton` parameter, which must be an instance of `<:AbstractAutomaton`. """ """ From 838103129151ccb941c2501a367f8fea3733b940 Mon Sep 17 00:00:00 2001 From: Nicola Di Cicco <93935338+nicoladicicco@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:07:52 +0900 Subject: [PATCH 2/5] fix typo in increasing constraint description resulting in wrong rendering --- src/constraints/ordered.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/constraints/ordered.jl b/src/constraints/ordered.jl index 6a4148c..d5aba48 100644 --- a/src/constraints/ordered.jl +++ b/src/constraints/ordered.jl @@ -10,7 +10,7 @@ const description_decreasing = """ Global constraint ensuring that all the values of `x` are in a decreasing order. """ -const description_sctrictly_increasing = """ +const description_strictly_increasing = """ Global constraint ensuring that all the values of `x` are in a strictly increasing order. """ @@ -44,7 +44,7 @@ concept(:increasing)(x; op=≤, pair_vars=nothing) concept(:decreasing, x; op=≥, pair_vars=nothing) concept(:decreasing)(x; op=≥, pair_vars=nothing) ``` -- `:strictly_increasing`: $description_sctrictly_increasing +- `:strictly_increasing`: $description_strictly_increasing ```julia concept(:strictly_increasing, x; op=<, pair_vars=nothing) concept(:strictly_increasing)(x; op=<, pair_vars=nothing) From fd1ba09ae829979261bfc0dbc429ae0e8dd15383 Mon Sep 17 00:00:00 2001 From: Nicola Di Cicco <93935338+nicoladicicco@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:47:31 +0900 Subject: [PATCH 3/5] update readme with new constraints --- README.md | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f4fc51c..e6011b5 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,43 @@ # Constraints.jl -A back-end package for JuliaConstraints front packages, such as `LocalSearchSolvers.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) +- A dictionary to store usual constraint: `usual_constraint`, which contains the following entries (in alphabetical order): + - :`all_different` + - :`all_equal` + - :`at_least` + - :`at_most` + - :`cardinality` + - :`cardinality_closed` + - :`cardinality_open` + - :`channel` + - :`circuit` + - :`conflicts` + - :`count` + - :`cumulative` + - :`decreasing` + - :`dist_different` + - :`element` + - :`exactly` + - :`extension` + - :`increasing` + - :`instantiation` + - :`maximum` + - :`mdd` + - :`minimum` + - :`no_overlap` + - :`no_overlap_no_zero` + - :`no_overlap_with_zero` + - :`nvalues` + - :`ordered` + - :`regular` + - :`strictly_decreasing` + - :`strictly_increasing` + - :`sum` + - :`supports` + - For each constraint `c`, the following properties - arguments length - concept (predicate the variables compliance with `c`) From c43c7159b9a6a22a2243ac401acf4475e795f80f Mon Sep 17 00:00:00 2001 From: Nicola Di Cicco <93935338+nicoladicicco@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:47:45 +0900 Subject: [PATCH 4/5] fix rendering of constraints in `describe()` --- src/constraints/channel.jl | 4 ++-- src/usual_constraints.jl | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/constraints/channel.jl b/src/constraints/channel.jl index 7af817f..41102b7 100644 --- a/src/constraints/channel.jl +++ b/src/constraints/channel.jl @@ -1,4 +1,4 @@ -const description = """ +const description_channel = """ The channel constraint establishes a bijective correspondence between two sets of variables. This means that each value in the first set of variables corresponds to a unique value in the second set, and vice versa. """ @@ -11,7 +11,7 @@ Return `true` if the channel constraint is satisfied, `false` otherwise. The cha - `list::Union{AbstractVector, Tuple}`: list of values to check. ## Variants -- `:channel`: $description +- `:channel`: $description_channel ```julia concept(:channel, x; dim=1, id=nothing) concept(:channel)(x; dim=1, id=nothing) diff --git a/src/usual_constraints.jl b/src/usual_constraints.jl index 267c514..956d124 100644 --- a/src/usual_constraints.jl +++ b/src/usual_constraints.jl @@ -9,7 +9,7 @@ Adding a new constraint is as simple as defining a new function with the same na @usual concept_all_different(x; vals=nothing) = xcsp_all_different(list=x, except=vals) ``` """ -const USUAL_CONSTRAINTS = Dict{Symbol, Constraint}(:always_true => Constraint()) +const USUAL_CONSTRAINTS = Dict{Symbol, Constraint}() """ describe(constraints::Dict{Symbol,Constraint}=USUAL_CONSTRAINTS; width=150) @@ -41,6 +41,8 @@ function describe(constraints::Dict{Symbol, Constraint} = USUAL_CONSTRAINTS; wid ) end +describe(s::Symbol) = USUAL_CONSTRAINTS[s].description + """ extract_parameters(s::Symbol, constraints_dict=USUAL_CONSTRAINTS; parameters=ConstraintCommons.USUAL_CONSTRAINT_PARAMETERS) From 8aacfd9c4eac5a9a74ab805c6c29c473208a120d Mon Sep 17 00:00:00 2001 From: Jean-Francois Baffier Date: Thu, 15 Aug 2024 12:09:25 +0900 Subject: [PATCH 5/5] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 5dc9f25..45127d2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Constraints" uuid = "30f324ab-b02d-43f0-b619-e131c61659f7" authors = ["Jean-François Baffier"] -version = "0.5.6" +version = "0.5.7" [deps] CompositionalNetworks = "4b67e4b5-442d-4ef5-b760-3f5df3a57537"