Skip to content

Commit 7254f73

Browse files
authored
Merge pull request #50 from JuliaConstraints/revise
Minor revisions
2 parents ccf3d43 + c43c715 commit 7254f73

File tree

8 files changed

+52
-23
lines changed

8 files changed

+52
-23
lines changed

README.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,43 @@
88

99
# Constraints.jl
1010

11-
A back-end package for JuliaConstraints front packages, such as `LocalSearchSolvers.jl`.
11+
A back-end package for JuliaConstraints front packages, such as `LocalSearchSolvers.jl`.
1212

1313
It provides the following features:
14-
- A dictionary to store usual constraint: `usual_constraint`, which contains the following entries
15-
- `:all_different`
16-
- `:dist_different`
17-
- `:eq`, `:all_equal`, `:all_equal_param`
18-
- `:ordered`
19-
- `:always_true` (mainly for testing default `Constraint()` constructor)
14+
- A dictionary to store usual constraint: `usual_constraint`, which contains the following entries (in alphabetical order):
15+
- :`all_different`
16+
- :`all_equal`
17+
- :`at_least`
18+
- :`at_most`
19+
- :`cardinality`
20+
- :`cardinality_closed`
21+
- :`cardinality_open`
22+
- :`channel`
23+
- :`circuit`
24+
- :`conflicts`
25+
- :`count`
26+
- :`cumulative`
27+
- :`decreasing`
28+
- :`dist_different`
29+
- :`element`
30+
- :`exactly`
31+
- :`extension`
32+
- :`increasing`
33+
- :`instantiation`
34+
- :`maximum`
35+
- :`mdd`
36+
- :`minimum`
37+
- :`no_overlap`
38+
- :`no_overlap_no_zero`
39+
- :`no_overlap_with_zero`
40+
- :`nvalues`
41+
- :`ordered`
42+
- :`regular`
43+
- :`strictly_decreasing`
44+
- :`strictly_increasing`
45+
- :`sum`
46+
- :`supports`
47+
2048
- For each constraint `c`, the following properties
2149
- arguments length
2250
- concept (predicate the variables compliance with `c`)

src/constraints/all_different.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!SECTION - all_different
22

33
const description_all_different = """
4-
Global constraint ensuring that all the values of `x` are all different.
4+
Global constraint ensuring that all the values of `x` are all different.
55
"""
66

77
"""

src/constraints/all_equal.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!SECTION - all_equal
22

33
const description_all_equal = """
4-
Global constraint ensuring that all the values of `x` are all equal.
4+
Global constraint ensuring that all the values of `x` are all equal.
55
"""
66

77
concept_all_equal(x, val) = all(y -> y == val, x)

src/constraints/channel.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const description = """
1+
const description_channel = """
22
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.
33
"""
44

@@ -11,7 +11,7 @@ Return `true` if the channel constraint is satisfied, `false` otherwise. The cha
1111
- `list::Union{AbstractVector, Tuple}`: list of values to check.
1212
1313
## Variants
14-
- `:channel`: $description
14+
- `:channel`: $description_channel
1515
```julia
1616
concept(:channel, x; dim=1, id=nothing)
1717
concept(:channel)(x; dim=1, id=nothing)

src/constraints/mdd.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!SECTION - Multi-valued Decision Diagram
22

33
const description_mdd = """
4-
Multi-valued Decision Diagram (MDD) constraint.
5-
6-
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.
4+
Multi-valued Decision Diagram (MDD) constraint.
5+
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.
76
"""
87

98
"""

src/constraints/ordered.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
const description_ordered = """
2-
Global constraint ensuring that all the values of `x` are in an increasing order.
2+
Global constraint ensuring that all the values of `x` are in an increasing order.
33
"""
44

55
const description_increasing = """
6-
Global constraint ensuring that all the values of `x` are in an increasing order.
6+
Global constraint ensuring that all the values of `x` are in an increasing order.
77
"""
88

99
const description_decreasing = """
10-
Global constraint ensuring that all the values of `x` are in a decreasing order.
10+
Global constraint ensuring that all the values of `x` are in a decreasing order.
1111
"""
1212

13-
const description_sctrictly_increasing = """
14-
Global constraint ensuring that all the values of `x` are in a strictly increasing order.
13+
const description_strictly_increasing = """
14+
Global constraint ensuring that all the values of `x` are in a strictly increasing order.
1515
"""
1616

1717
const description_strictly_decreasing = """
18-
Global constraint ensuring that all the values of `x` are in a strictly decreasing order.
18+
Global constraint ensuring that all the values of `x` are in a strictly decreasing order.
1919
"""
2020

2121
"""
@@ -44,7 +44,7 @@ concept(:increasing)(x; op=≤, pair_vars=nothing)
4444
concept(:decreasing, x; op=≥, pair_vars=nothing)
4545
concept(:decreasing)(x; op=≥, pair_vars=nothing)
4646
```
47-
- `:strictly_increasing`: $description_sctrictly_increasing
47+
- `:strictly_increasing`: $description_strictly_increasing
4848
```julia
4949
concept(:strictly_increasing, x; op=<, pair_vars=nothing)
5050
concept(:strictly_increasing)(x; op=<, pair_vars=nothing)

src/constraints/regular.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const description_regular = """
2-
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`.
2+
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`.
33
"""
44

55
"""

src/usual_constraints.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Adding a new constraint is as simple as defining a new function with the same na
99
@usual concept_all_different(x; vals=nothing) = xcsp_all_different(list=x, except=vals)
1010
```
1111
"""
12-
const USUAL_CONSTRAINTS = Dict{Symbol, Constraint}(:always_true => Constraint())
12+
const USUAL_CONSTRAINTS = Dict{Symbol, Constraint}()
1313

1414
"""
1515
describe(constraints::Dict{Symbol,Constraint}=USUAL_CONSTRAINTS; width=150)
@@ -41,6 +41,8 @@ function describe(constraints::Dict{Symbol, Constraint} = USUAL_CONSTRAINTS; wid
4141
)
4242
end
4343

44+
describe(s::Symbol) = USUAL_CONSTRAINTS[s].description
45+
4446
"""
4547
extract_parameters(s::Symbol, constraints_dict=USUAL_CONSTRAINTS; parameters=ConstraintCommons.USUAL_CONSTRAINT_PARAMETERS)
4648

0 commit comments

Comments
 (0)