Skip to content

Commit

Permalink
Updates constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
Azzaare committed Aug 7, 2024
1 parent a8d63f3 commit f1b5a32
Show file tree
Hide file tree
Showing 11 changed files with 703 additions and 728 deletions.
44 changes: 23 additions & 21 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ version = "1.1.1"

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

[deps.ArrayInterface.extensions]
ArrayInterfaceBandedMatricesExt = "BandedMatrices"
Expand All @@ -80,7 +80,7 @@ version = "7.14.0"
ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore"
ArrayInterfaceReverseDiffExt = "ReverseDiff"
ArrayInterfaceSparseArraysExt = "SparseArrays"
ArrayInterfaceStaticArraysExt = "StaticArrays"
ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore"
ArrayInterfaceTrackerExt = "Tracker"

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

[[deps.Artifacts]]
Expand Down Expand Up @@ -238,19 +238,19 @@ weakdeps = ["InverseFunctions"]

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

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

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

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

[deps.Flux.extensions]
FluxAMDGPUExt = "AMDGPU"
FluxCUDAExt = "CUDA"
FluxCUDAcuDNNExt = ["CUDA", "cuDNN"]
FluxEnzymeExt = "Enzyme"
FluxMetalExt = "Metal"

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

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

[[deps.Functors]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "8a66c07630d6428eaab3506a0eabfcf4a9edea05"
git-tree-sha1 = "64d8e93700c7a3f28f717d265382d52fac9fa1c1"
uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
version = "0.4.11"
version = "0.4.12"

[[deps.Future]]
deps = ["Random"]
Expand Down Expand Up @@ -668,9 +670,9 @@ version = "0.9.22"

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

[deps.LLVM.extensions]
BFloat16sExt = "BFloat16s"
Expand All @@ -680,9 +682,9 @@ version = "8.0.0"

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

[[deps.LaTeXStrings]]
git-tree-sha1 = "50901ebc375ed41dbf8058da26f9de442febbbec"
Expand Down Expand Up @@ -803,9 +805,9 @@ version = "0.1.2"

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

[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down Expand Up @@ -852,9 +854,9 @@ version = "2023.1.10"

[[deps.MutableArithmetics]]
deps = ["LinearAlgebra", "SparseArrays", "Test"]
git-tree-sha1 = "898c56fbf8bf71afb0c02146ef26f3a454e88873"
git-tree-sha1 = "d0a6b1096b584a2b88efb70a92f8cb8c881eb38a"
uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
version = "1.4.5"
version = "1.4.6"

[[deps.NLSolversBase]]
deps = ["DiffResults", "Distributed", "FiniteDiff", "ForwardDiff"]
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ makedocs(;
"Internals" => [
"ConstraintCommons.jl" => "constraints/constraint_commons.md",
"ConstraintDomains.jl" => "constraints/constraint_domains.md",
"Constraints.jl" => "constraints/constraints_jl.md",
],
],
"Learning" => [
Expand Down
117 changes: 117 additions & 0 deletions docs/src/constraints/comparison_constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,123 @@
CurrentModule = Constraints
```

::: code-group

```julia [JC-API]
using Constraints

concept(:all_different, [1,1,1,2]) # false
concept(:all_different, [1,9,3,2]) # true
```

```julia [XCSP]
using Constraints

c = x -> Constraints.xcsp_all_different(
list = x
)
@info c([1, 2, 3, 3]) # false
@info c([1, 2, 3, 4]) # true
```

```julia [JuMP]
using CBLS, JuMP

model = Model(CBLS.Optimizer)
@variable(model, 1X[1:4]4, Int)
@variable(model, 0Y[1:4]2, Int)
@constraint(model, X in AllDifferent())
@constraint(model, Y in AllDifferent(; vals = [0]))
JuMP.optimize!(model)
@info "All Different" value.(X) value.(Y)

# Note that this example gives a solution for the all_different constraint.
```

```julia [MOI]
# TODO: How to handle intention in JuMP/MOI
```

:::

::: code-group

```julia [JC-API]
using Constraints

concept(:all_equal, [1,1,1,2]) #false
concept(:all_equal, [1,1,1,1]) #true
```

```julia [XCSP]
using Constraints

c = x -> Constraints.xcsp_all_equal(
list = x
)

@info c([1, 1, 1, 1]) # false
@info c([1, 2, 3, 4]) # true
```

```julia [JuMP]
using JuMP, CBLS

model = Model(CBLS.Optimizer)
@variable(model, 0X[1:4]4, Int)
@constraint(model, X in AllEqual())
JuMP.optimize!(model)
@info "All Equal" value.(X)

# Note that this example gives a solution for the all_equal constraint.
```

```julia [MOI]
# TODO: How to handle intention in JuMP/MOI
```

:::

::: code-group

```julia [JC-API]
using Constraints

@info concept(:ordered, [1, 2, 3, 4, 4]; op=)
@info concept(:ordered, [1, 2, 3, 3, 5]; op=<)
@info concept(:increasing, [1,2,2,3])
```

```julia [XCSP]
using Constraints

c = x -> Constraints.xcsp_ordered(
list = x,
operator =
)

@info c([1, 1, 1, 1])
@info c([9, 3, 6, 8])
```

```julia [JuMP]
using CBLS, JuMP

model = Model(CBLS.Optimizer)
@variable(model, 1X[1:5]5, Int)
@variable(model, 1Y[1:5]5, Int)
@constraint(model, X in Ordered())
@constraint(model, Y in Ordered(; op = <))
JuMP.optimize!(model)
@info "Ordered" value.(X) value.(Y)
```

```julia [MOI]
# TODO: How to handle intention in JuMP/MOI
```

:::

### Comparison-based Constraints

```@docs; canonical=false
Expand Down
Loading

0 comments on commit f1b5a32

Please sign in to comment.