Skip to content

Commit f1b5a32

Browse files
committed
Updates constraints
1 parent a8d63f3 commit f1b5a32

11 files changed

+703
-728
lines changed

docs/Manifest.toml

+23-21
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ version = "1.1.1"
6767

6868
[[deps.ArrayInterface]]
6969
deps = ["Adapt", "LinearAlgebra"]
70-
git-tree-sha1 = "8c5b39db37c1d0340bf3b14895fba160c2d6cbb5"
70+
git-tree-sha1 = "f54c23a5d304fb87110de62bace7777d59088c34"
7171
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
72-
version = "7.14.0"
72+
version = "7.15.0"
7373

7474
[deps.ArrayInterface.extensions]
7575
ArrayInterfaceBandedMatricesExt = "BandedMatrices"
@@ -80,7 +80,7 @@ version = "7.14.0"
8080
ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore"
8181
ArrayInterfaceReverseDiffExt = "ReverseDiff"
8282
ArrayInterfaceSparseArraysExt = "SparseArrays"
83-
ArrayInterfaceStaticArraysExt = "StaticArrays"
83+
ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore"
8484
ArrayInterfaceTrackerExt = "Tracker"
8585

8686
[deps.ArrayInterface.weakdeps]
@@ -92,7 +92,7 @@ version = "7.14.0"
9292
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
9393
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
9494
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
95-
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
95+
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
9696
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
9797

9898
[[deps.Artifacts]]
@@ -238,19 +238,19 @@ weakdeps = ["InverseFunctions"]
238238

239239
[[deps.ConstraintCommons]]
240240
deps = ["Dictionaries", "TestItems"]
241-
git-tree-sha1 = "ca8e5cfedb33fc75c5ba0a52d3e222d3d3c2b9e9"
241+
git-tree-sha1 = "779227189854f846de5f72b518e50dda14c7886b"
242242
repo-rev = "main"
243243
repo-url = "https://github.com/JuliaConstraints/ConstraintCommons.jl.git"
244244
uuid = "e37357d9-0691-492f-a822-e5ea6a920954"
245-
version = "0.2.2"
245+
version = "0.2.3"
246246

247247
[[deps.ConstraintDomains]]
248-
deps = ["ConstraintCommons", "Dictionaries", "Intervals", "PatternFolds", "StatsBase", "TestItems"]
249-
git-tree-sha1 = "20000526022d536c3c9fcbb3e9d92b6d9eef16c2"
248+
deps = ["ConstraintCommons", "Intervals", "PatternFolds", "StatsBase", "TestItems"]
249+
git-tree-sha1 = "02380c829c947c0579864c51affa1646a170d037"
250250
repo-rev = "main"
251251
repo-url = "https://github.com/JuliaConstraints/ConstraintDomains.jl.git"
252252
uuid = "5800fd60-8556-4464-8d61-84ebf7a0bedb"
253-
version = "0.3.12"
253+
version = "0.3.13"
254254

255255
[[deps.ConstraintLearning]]
256256
deps = ["CompositionalNetworks", "ConstraintDomains", "Constraints", "DataFrames", "Dictionaries", "Evolutionary", "Flux", "LocalSearchSolvers", "Memoization", "PrettyTables", "QUBOConstraints", "TestItems", "ThreadPools"]
@@ -483,19 +483,21 @@ version = "2.23.1"
483483

484484
[[deps.Flux]]
485485
deps = ["Adapt", "ChainRulesCore", "Compat", "Functors", "LinearAlgebra", "MLUtils", "MacroTools", "NNlib", "OneHotArrays", "Optimisers", "Preferences", "ProgressLogging", "Random", "Reexport", "SparseArrays", "SpecialFunctions", "Statistics", "Zygote"]
486-
git-tree-sha1 = "edacf029ed6276301e455e34d7ceeba8cc34078a"
486+
git-tree-sha1 = "3dacce10e977918008944bb223ddec455fab6c16"
487487
uuid = "587475ba-b771-5e3f-ad9e-33799f191a9c"
488-
version = "0.14.16"
488+
version = "0.14.17"
489489

490490
[deps.Flux.extensions]
491491
FluxAMDGPUExt = "AMDGPU"
492492
FluxCUDAExt = "CUDA"
493493
FluxCUDAcuDNNExt = ["CUDA", "cuDNN"]
494+
FluxEnzymeExt = "Enzyme"
494495
FluxMetalExt = "Metal"
495496

496497
[deps.Flux.weakdeps]
497498
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
498499
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
500+
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
499501
Metal = "dde4c033-4e86-420c-a63e-0dd931031962"
500502
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"
501503

@@ -511,9 +513,9 @@ weakdeps = ["StaticArrays"]
511513

512514
[[deps.Functors]]
513515
deps = ["LinearAlgebra"]
514-
git-tree-sha1 = "8a66c07630d6428eaab3506a0eabfcf4a9edea05"
516+
git-tree-sha1 = "64d8e93700c7a3f28f717d265382d52fac9fa1c1"
515517
uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
516-
version = "0.4.11"
518+
version = "0.4.12"
517519

518520
[[deps.Future]]
519521
deps = ["Random"]
@@ -668,9 +670,9 @@ version = "0.9.22"
668670

669671
[[deps.LLVM]]
670672
deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Preferences", "Printf", "Requires", "Unicode"]
671-
git-tree-sha1 = "020abd49586480c1be84f57da0017b5d3db73f7c"
673+
git-tree-sha1 = "2470e69781ddd70b8878491233cd09bc1bd7fc96"
672674
uuid = "929cbde3-209d-540e-8aea-75f648917ca0"
673-
version = "8.0.0"
675+
version = "8.1.0"
674676

675677
[deps.LLVM.extensions]
676678
BFloat16sExt = "BFloat16s"
@@ -680,9 +682,9 @@ version = "8.0.0"
680682

681683
[[deps.LLVMExtra_jll]]
682684
deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"]
683-
git-tree-sha1 = "c2636c264861edc6d305e6b4d528f09566d24c5e"
685+
git-tree-sha1 = "597d1c758c9ae5d985ba4202386a607c675ee700"
684686
uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab"
685-
version = "0.0.30+0"
687+
version = "0.0.31+0"
686688

687689
[[deps.LaTeXStrings]]
688690
git-tree-sha1 = "50901ebc375ed41dbf8058da26f9de442febbbec"
@@ -803,9 +805,9 @@ version = "0.1.2"
803805

804806
[[deps.MathOptInterface]]
805807
deps = ["BenchmarkTools", "CodecBzip2", "CodecZlib", "DataStructures", "ForwardDiff", "JSON", "LinearAlgebra", "MutableArithmetics", "NaNMath", "OrderedCollections", "PrecompileTools", "Printf", "SparseArrays", "SpecialFunctions", "Test", "Unicode"]
806-
git-tree-sha1 = "91b08d27a27d83cf1e63e50837403e7f53a0fd74"
808+
git-tree-sha1 = "c0fe113e9c72aa0c9a185fd3c5ca1daa51de1486"
807809
uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
808-
version = "1.31.0"
810+
version = "1.31.1"
809811

810812
[[deps.MbedTLS_jll]]
811813
deps = ["Artifacts", "Libdl"]
@@ -852,9 +854,9 @@ version = "2023.1.10"
852854

853855
[[deps.MutableArithmetics]]
854856
deps = ["LinearAlgebra", "SparseArrays", "Test"]
855-
git-tree-sha1 = "898c56fbf8bf71afb0c02146ef26f3a454e88873"
857+
git-tree-sha1 = "d0a6b1096b584a2b88efb70a92f8cb8c881eb38a"
856858
uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
857-
version = "1.4.5"
859+
version = "1.4.6"
858860

859861
[[deps.NLSolversBase]]
860862
deps = ["DiffResults", "Distributed", "FiniteDiff", "ForwardDiff"]

docs/make.jl

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ makedocs(;
7777
"Internals" => [
7878
"ConstraintCommons.jl" => "constraints/constraint_commons.md",
7979
"ConstraintDomains.jl" => "constraints/constraint_domains.md",
80+
"Constraints.jl" => "constraints/constraints_jl.md",
8081
],
8182
],
8283
"Learning" => [

docs/src/constraints/comparison_constraints.md

+117
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,123 @@
44
CurrentModule = Constraints
55
```
66

7+
::: code-group
8+
9+
```julia [JC-API]
10+
using Constraints
11+
12+
concept(:all_different, [1,1,1,2]) # false
13+
concept(:all_different, [1,9,3,2]) # true
14+
```
15+
16+
```julia [XCSP]
17+
using Constraints
18+
19+
c = x -> Constraints.xcsp_all_different(
20+
list = x
21+
)
22+
@info c([1, 2, 3, 3]) # false
23+
@info c([1, 2, 3, 4]) # true
24+
```
25+
26+
```julia [JuMP]
27+
using CBLS, JuMP
28+
29+
model = Model(CBLS.Optimizer)
30+
@variable(model, 1X[1:4]4, Int)
31+
@variable(model, 0Y[1:4]2, Int)
32+
@constraint(model, X in AllDifferent())
33+
@constraint(model, Y in AllDifferent(; vals = [0]))
34+
JuMP.optimize!(model)
35+
@info "All Different" value.(X) value.(Y)
36+
37+
# Note that this example gives a solution for the all_different constraint.
38+
```
39+
40+
```julia [MOI]
41+
# TODO: How to handle intention in JuMP/MOI
42+
```
43+
44+
:::
45+
46+
::: code-group
47+
48+
```julia [JC-API]
49+
using Constraints
50+
51+
concept(:all_equal, [1,1,1,2]) #false
52+
concept(:all_equal, [1,1,1,1]) #true
53+
```
54+
55+
```julia [XCSP]
56+
using Constraints
57+
58+
c = x -> Constraints.xcsp_all_equal(
59+
list = x
60+
)
61+
62+
@info c([1, 1, 1, 1]) # false
63+
@info c([1, 2, 3, 4]) # true
64+
```
65+
66+
```julia [JuMP]
67+
using JuMP, CBLS
68+
69+
model = Model(CBLS.Optimizer)
70+
@variable(model, 0X[1:4]4, Int)
71+
@constraint(model, X in AllEqual())
72+
JuMP.optimize!(model)
73+
@info "All Equal" value.(X)
74+
75+
# Note that this example gives a solution for the all_equal constraint.
76+
```
77+
78+
```julia [MOI]
79+
# TODO: How to handle intention in JuMP/MOI
80+
```
81+
82+
:::
83+
84+
::: code-group
85+
86+
```julia [JC-API]
87+
using Constraints
88+
89+
@info concept(:ordered, [1, 2, 3, 4, 4]; op=)
90+
@info concept(:ordered, [1, 2, 3, 3, 5]; op=<)
91+
@info concept(:increasing, [1,2,2,3])
92+
```
93+
94+
```julia [XCSP]
95+
using Constraints
96+
97+
c = x -> Constraints.xcsp_ordered(
98+
list = x,
99+
operator =
100+
)
101+
102+
@info c([1, 1, 1, 1])
103+
@info c([9, 3, 6, 8])
104+
```
105+
106+
```julia [JuMP]
107+
using CBLS, JuMP
108+
109+
model = Model(CBLS.Optimizer)
110+
@variable(model, 1X[1:5]5, Int)
111+
@variable(model, 1Y[1:5]5, Int)
112+
@constraint(model, X in Ordered())
113+
@constraint(model, Y in Ordered(; op = <))
114+
JuMP.optimize!(model)
115+
@info "Ordered" value.(X) value.(Y)
116+
```
117+
118+
```julia [MOI]
119+
# TODO: How to handle intention in JuMP/MOI
120+
```
121+
122+
:::
123+
7124
### Comparison-based Constraints
8125

9126
```@docs; canonical=false

0 commit comments

Comments
 (0)