You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/constraints/constraint_commons.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ at_end
60
60
61
61
## Extensions
62
62
63
-
We extended some operations for `Nothing` and `Symbol`.
63
+
We extend some operations for `Nothing` and `Symbol`.
64
64
65
65
```@docs; canonical=false
66
66
symcon
@@ -89,7 +89,7 @@ consisempty
89
89
90
90
## Sampling
91
91
92
-
During our constraint learning processes, we use sampling to efficiently make partial exploration of search spaces. Follows some sampling utilities.
92
+
During our constraint learning processes, we use sampling to efficiently make partial exploration of search spaces. The following are some examples of sampling utilities.
93
93
94
94
```@docs; canonical=false
95
95
oversample
@@ -112,18 +112,18 @@ We need to compute the difference between extrema of various kind of collections
Copy file name to clipboardExpand all lines: docs/src/constraints/generic_constraints.md
+82-17
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ Note that the *intention* constraint is not directly available through the JC-AP
14
14
15
15
We provide a straightforward example through the `:dist_different` constraint on how to define and add such a constraint in the `USUAL_CONSTRAINTS` collection.
16
16
17
-
Higher level modeling language such as `JuMP` should provide a `Intention` interface.
17
+
Higher level modeling languages such as `JuMP` should provide a `Intention` interface.
18
18
19
19
### Defining an intention constraint in JC-API
20
20
@@ -33,7 +33,7 @@ Ensures that the distances between marks on the ruler are unique.
@@ -44,11 +44,11 @@ Please check the section dedicated to the Golomb Ruler problem to see a use for
44
44
45
45
### APIs
46
46
47
-
Note that the *intension* constraint is not directly available through the JC-API in Constraints.jl. It is designed as such since defining a constraint through a *predicate* is the natural way.
47
+
Note that the *intention* constraint is not directly available through the JC-API in Constraints.jl. It is designed as such since defining a constraint through a *predicate* is the natural way.
48
48
49
49
We provide here a usage example for the `:dist_different` constraint, previously added to the `USUAL_CONSTRAINTS` collection.
50
50
51
-
Higher level modeling language such as `JuMP` should provide an `Intension` interface.
51
+
Higher level modeling language such as `JuMP` should provide an `Intention` interface.
52
52
53
53
::: code-group
54
54
@@ -63,7 +63,7 @@ concept(:dist_different)(x)
63
63
# Defines the DistDifferent constraint
64
64
using Constraints
65
65
66
-
c = x ->xcsp_intension(
66
+
c = x ->xcsp_intention(
67
67
list = x,
68
68
predicate = y ->abs(y[1] - y[2]) ≠abs(y[3] - y[4])
69
69
)
@@ -76,35 +76,100 @@ c([1, 2, 3, 4]) # false
76
76
using CBLS, JuMP
77
77
78
78
model =Model(CBLS.Optimizer)
79
+
80
+
# Using build-in DistDifferent
79
81
@variable(model, 0<= X[1:4] <=10, Int)
80
82
@constraint(model, X inDistDifferent())
83
+
84
+
# Alternatively
85
+
@variable(model, 0<= Y[1:4] <=10, Int)
86
+
@constraint(model, Y inIntention(y ->abs(y[1] - y[2]) ≠abs(y[3] - y[4])))
87
+
81
88
optimize!(model)
82
89
83
90
@infovalue.(X)
84
-
85
-
# Note that this example gives a solution for the constraint within the interval 0:10
These are constraints that are defined by explicitly listing all the tuples of values that satisfy the constraint. They are called extensional because they are defined by the set of values they allow. For example, a binary constraint that specifies that a variable X must be either 1 or 2 and a variable Y must be either 3 or 4 could be defined extensionally by the set of tuples {(1,3), (1,4), (2,3), (2,4)}.
114
+
These are constraints that are defined by explicitly listing all the tuples of values that satisfy the constraint. They are called extensional because they are defined by the set of values they allow. For example, a binary constraint that specifies that a variable ``X`` must be either ``1`` or ``2`` and a variable ``Y`` must be either ``3`` or ``4`` could be defined extensionally by the set of tuples $${(1,3), (1,4), (2,3), (2,4)}.$$
103
115
104
116
These two types of constraints provide a flexible way to define complex relationships between variables in constraint programming.
105
117
106
-
### [XCSP](https://arxiv.org/abs/2009.00514) in Constraints.jl
118
+
::: code-group
119
+
120
+
```julia [JC-API]
121
+
using Constraints
107
122
108
-
```@docs; canonical=false
109
-
xcsp_extension
123
+
concept(:dist_different, x)
124
+
concept(:dist_different)(x)
110
125
```
126
+
127
+
```julia [XCSP]
128
+
# Defines the DistDifferent constraint
129
+
using Constraints
130
+
131
+
c = x ->xcsp_intention(
132
+
list = x,
133
+
predicate = y ->abs(y[1] - y[2]) ≠abs(y[3] - y[4])
134
+
)
135
+
136
+
c([1, 2, 3, 3]) # true
137
+
c([1, 2, 3, 4]) # false
138
+
```
139
+
140
+
```julia [JuMP]
141
+
using CBLS, JuMP
142
+
143
+
model =Model(CBLS.Optimizer)
144
+
145
+
# Using build-in DistDifferent
146
+
@variable(model, 0<= X[1:4] <=10, Int)
147
+
@constraint(model, X inDistDifferent())
148
+
149
+
# Alternatively
150
+
@variable(model, 0<= Y[1:4] <=10, Int)
151
+
@constraint(model, Y inIntention(y ->abs(y[1] - y[2]) ≠abs(y[3] - y[4])))
A range domain allows for minimal storage and more efficient operation on discrete sets defined as `Range` in Julia. It is not recommended for dynamic domains (it will be replaced with `SetDomain` as soon non-extremal element is removed).
72
+
A range domain allows for minimal storage and more efficient operation on discrete sets defined as `Range` in Julia. It is not recommended for dynamic domains (it will be replaced with `SetDomain` as soon as a non-extremal element is removed).
0 commit comments