From 1c251e3ee8691c954ebf49af54ed9d8c772543b1 Mon Sep 17 00:00:00 2001 From: Azzaare Date: Mon, 21 Oct 2024 10:39:47 +0900 Subject: [PATCH 1/2] Add a check! function --- .github/workflows/CI.yml | 10 ++++++++-- Project.toml | 2 +- src/ConstraintExplorer.jl | 21 +++++++++++++++++++-- src/MOI_wrapper.jl | 5 +++++ test/Aqua.jl | 8 ++++---- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b3d27c9..30594d8 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,10 +1,16 @@ name: CI on: + pull_request: + branches: + - main + - dev + paths-ignore: + - "docs/**" push: branches: - main - tags: ["*"] - pull_request: + paths-ignore: + - "docs/**" workflow_dispatch: concurrency: # Skip intermediate builds: always. diff --git a/Project.toml b/Project.toml index ae113f2..3014410 100644 --- a/Project.toml +++ b/Project.toml @@ -17,7 +17,7 @@ TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe" [compat] Aqua = "0.8" ConstraintCommons = "0.2" -ConstraintDomains = "0.3.14" +ConstraintDomains = "0.3.15" Constraints = "0.5" ExplicitImports = "1" Intervals = "1" diff --git a/src/ConstraintExplorer.jl b/src/ConstraintExplorer.jl index d3b799b..dc59ad8 100644 --- a/src/ConstraintExplorer.jl +++ b/src/ConstraintExplorer.jl @@ -4,7 +4,7 @@ module ConstraintExplorer import ConstraintCommons import ConstraintDomains: AbstractDomain, RangeDomain import ConstraintDomains: intersect_domains, domain -import ConstraintDomains: Explorer, ExploreSettings, ExplorerState, explore! +import ConstraintDomains: Explorer, ExploreSettings, ExplorerState, explore!, _check! import Constraints: concept, USUAL_CONSTRAINTS import JuMP import MathOptInterface as MOI @@ -56,7 +56,7 @@ export Regular export Sum #Exports: Explorer -export configurations, solutions, non_solutions +export configurations, solutions, non_solutions, check! #SECTION - Includes include("MOI_wrapper.jl") @@ -103,6 +103,23 @@ include("constraints/sum.jl") X, X̅ = configurations(explorer) @info "All Different" X X̅ + + x = first(X) + + checker = Model(ConstraintExplorer.Optimizer) + + @variable(checker, 1≤X[1:4]≤4, Int) + + @constraint(checker, X in AllDifferent()) + @constraint(checker, X in DistDifferent()) + + check!(checker, [x]) + + Y, Y̅ = configurations(checker) + + @test x ∈ Y + @test length(Y) == 1 + @test isempty(Y̅) end #SECTION - Main function (optional) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 9bfb6c8..1269d9b 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -121,3 +121,8 @@ solutions(model) = model.moi_backend.optimizer.model.explorer.state.solutions non_solutions(model) = model.moi_backend.optimizer.model.explorer.state.non_solutions configurations(model) = solutions(model), non_solutions(model) + +function check!(model, configurations) + checker = model.moi_backend.optimizer.model.explorer + return _check!(checker, configurations) +end diff --git a/test/Aqua.jl b/test/Aqua.jl index c92b60e..f6346c5 100644 --- a/test/Aqua.jl +++ b/test/Aqua.jl @@ -2,14 +2,14 @@ # TODO: Fix the broken tests and remove the `broken = true` flag Aqua.test_all( ConstraintExplorer; - ambiguities = (broken = true,), + ambiguities = (broken = false,), deps_compat = true, piracies = (broken = false,), ) - @testset "Ambiguities: ConstraintExplorer" begin - Aqua.test_ambiguities(ConstraintExplorer;) - end + # @testset "Ambiguities: ConstraintExplorer" begin + # Aqua.test_ambiguities(ConstraintExplorer;) + # end @testset "Piracies: ConstraintExplorer" begin Aqua.test_piracies(ConstraintExplorer;) From 812a75015c66c87c9ff6634f051a4abf19103ba5 Mon Sep 17 00:00:00 2001 From: Jean-Francois Baffier Date: Mon, 21 Oct 2024 10:52:59 +0900 Subject: [PATCH 2/2] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 3014410..2e30cfd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ConstraintExplorer" uuid = "798c8aff-73f8-4b88-855c-426d3d936206" authors = ["Jean-François BAFFIER (@Azzaare)"] -version = "0.0.1" +version = "0.0.2" [deps] ConstraintCommons = "e37357d9-0691-492f-a822-e5ea6a920954"