From 6fcee9c5862c884cf1ecc2ed6cbd3e8911627f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 9 Oct 2024 15:27:48 +0200 Subject: [PATCH 1/3] Use MOI.AllDifferent --- docs/src/mappings/cplexcp.md | 2 +- docs/src/mappings/minizinc.md | 2 +- docs/src/mappings/numberjack.md | 2 +- docs/src/mappings/sas.md | 4 ++-- docs/src/reference/sets.md | 1 - .../Constraint/AllDifferent/ad_to_neq.jl | 8 +++---- .../perm_to_alldiff_indexing.jl | 12 +++++----- .../salldiff_to_alldiff_inverse.jl | 12 +++++----- src/Test/test_alldifferent.jl | 8 +++---- src/Test/test_antidomain.jl | 8 +++---- src/Test/test_domain.jl | 10 ++++----- src/sets.jl | 22 +------------------ src/sets_count.jl | 2 +- .../Constraint/AllDifferent/ad_to_neq.jl | 8 +++---- .../perm_to_alldiff_indexing.jl | 10 ++++----- .../salldiff_to_alldiff_inverse.jl | 10 ++++----- test/Bridges/models.jl | 4 ++-- test/sets.jl | 4 ++-- 18 files changed, 54 insertions(+), 75 deletions(-) diff --git a/docs/src/mappings/cplexcp.md b/docs/src/mappings/cplexcp.md index 75930459..4867e77a 100644 --- a/docs/src/mappings/cplexcp.md +++ b/docs/src/mappings/cplexcp.md @@ -35,7 +35,7 @@ Constraints removed/renamed between OPL 3 and OPL 6: * [`sequence`](https://lost-contact.mit.edu/afs/pdc.kth.se/roots/ilse/v0.7/pdc/vol/cplex/12.5/amd64_co5/doc/html/en-US/OPL_Studio/oplmigration/topics/opl_mig_prev_3x4x_3xCP_constr_seq.html): what the heck!? * [`circuit`](https://lost-contact.mit.edu/afs/pdc.kth.se/roots/ilse/v0.7/pdc/vol/cplex/12.5/amd64_co5/doc/html/en-US/OPL_Studio/oplmigration/topics/opl_mig_prev_3x4x_3xCP_constr_circuit.html): `CP.Walk` (Eulerian circuit) -* [`alldifferent`](https://lost-contact.mit.edu/afs/pdc.kth.se/roots/ilse/v0.7/pdc/vol/cplex/12.5/amd64_co5/doc/html/en-US/OPL_Studio/oplmigration/topics/opl_mig_prev_3x4x_3xCP_constr_alldiff.html): `CP.AllDifferent` +* [`alldifferent`](https://lost-contact.mit.edu/afs/pdc.kth.se/roots/ilse/v0.7/pdc/vol/cplex/12.5/amd64_co5/doc/html/en-US/OPL_Studio/oplmigration/topics/opl_mig_prev_3x4x_3xCP_constr_alldiff.html): `MOI.AllDifferent` * [`atleast`](https://lost-contact.mit.edu/afs/pdc.kth.se/roots/ilse/v0.7/pdc/vol/cplex/12.5/amd64_co5/doc/html/en-US/OPL_Studio/oplmigration/topics/opl_mig_prev_3x4x_3xCP_constr_atleast.html): `CP.Count` and `MOI.GreaterThan` * [`atleastatmost`](https://lost-contact.mit.edu/afs/pdc.kth.se/roots/ilse/v0.7/pdc/vol/cplex/12.5/amd64_co5/doc/html/en-US/OPL_Studio/oplmigration/topics/opl_mig_prev_3x4x_3xCP_constr_atleastmost.html): `CP.Count`, `MOI.GreaterThan`, and `MOI.LessThan` * [`atmost`](https://lost-contact.mit.edu/afs/pdc.kth.se/roots/ilse/v0.7/pdc/vol/cplex/12.5/amd64_co5/doc/html/en-US/OPL_Studio/oplmigration/topics/opl_mig_prev_3x4x_3xCP_constr_atmost.html): `CP.Count` and `MOI.LessThan` diff --git a/docs/src/mappings/minizinc.md b/docs/src/mappings/minizinc.md index 93253626..b35be65d 100644 --- a/docs/src/mappings/minizinc.md +++ b/docs/src/mappings/minizinc.md @@ -9,7 +9,7 @@ MiniZinc has a similar goal to this project: a common modelling interface for ma * Multivalued: `CP.VectorDomain` * [`table`](https://github.com/MiniZinc/libminizinc/blob/master/share/minizinc/std/table.mzn): [one binary variable per possible combination](https://github.com/MiniZinc/libminizinc/blob/master/share/minizinc/linear/fzn_table_int.mzn) * All different: - * Base: `CP.AllDifferent` + * Base: `MOI.AllDifferent` * [`all_different`](https://github.com/MiniZinc/libminizinc/blob/master/share/minizinc/std/all_different.mzn): mapped onto [a MILP-like model](https://github.com/MiniZinc/libminizinc/blob/master/share/minizinc/std/fzn_all_different_int.mzn). * [`all_different_reif`](https://github.com/MiniZinc/libminizinc/blob/master/share/minizinc/std/all_different.mzn): similar, [with an equivalence](https://github.com/MiniZinc/libminizinc/blob/master/share/minizinc/std/fzn_all_different_int_reif.mzn). * These constraints are available in two includes: `all_different.mzn` and `alldifferent.mzn`. diff --git a/docs/src/mappings/numberjack.md b/docs/src/mappings/numberjack.md index 613cac3f..fbfbd5da 100644 --- a/docs/src/mappings/numberjack.md +++ b/docs/src/mappings/numberjack.md @@ -2,7 +2,7 @@ Numberjack has a very similar goal to this project: a common modelling interface for many underlying solvers. List of supported global constraints: https://github.com/eomahony/Numberjack/blob/master/doc/source/globalcons.rst. List of other constraints: https://github.com/eomahony/Numberjack/blob/master/doc/source/constraints.rst -* `Numberjack.AllDiff`: `AllDifferent` +* `Numberjack.AllDiff`: `MOI.AllDifferent` * `Numberjack.AllDiffExcept0`: `AllDifferentExceptConstants` * `Numberjack.Sum`: MOI (linear expressions * `Numberjack.Product`: MOI (quadratic expressions) diff --git a/docs/src/mappings/sas.md b/docs/src/mappings/sas.md index 357ef4ae..d0995fe7 100644 --- a/docs/src/mappings/sas.md +++ b/docs/src/mappings/sas.md @@ -2,7 +2,7 @@ Based on [the current docs](https://documentation.sas.com/doc/en/pgmsascdc/v_014/casmopt/casmopt_clpsolver_toc.htm), SAS' constraint-programming interface is still burgeoning: -- [ALLDIFF](https://documentation.sas.com/doc/en/pgmsascdc/v_014/casmopt/casmopt_clpsolver_syntax06.htm): `CP.AllDifferent` +- [ALLDIFF](https://documentation.sas.com/doc/en/pgmsascdc/v_014/casmopt/casmopt_clpsolver_syntax06.htm): `MOI.AllDifferent` - [CUMULATIVE](https://documentation.sas.com/doc/en/pgmsascdc/v_014/casmopt/casmopt_clpsolver_syntax07.htm): `CP.CumulativeResource` - [ELEMENT](https://documentation.sas.com/doc/en/pgmsascdc/v_014/casmopt/casmopt_clpsolver_syntax08.htm) - [GCC](https://documentation.sas.com/doc/en/pgmsascdc/v_014/casmopt/casmopt_clpsolver_syntax09.htm) @@ -13,7 +13,7 @@ Based on [the current docs](https://documentation.sas.com/doc/en/pgmsascdc/v_014 There are more features in [the scheduling module](https://documentation.sas.com/doc/en/pgmsascdc/v_014/orcpug/orcpug_clp_syntax.htm): - [ACTIVITY](https://documentation.sas.com/doc/en/pgmsascdc/v_014/orcpug/orcpug_clp_syntax03.htm): TODO -- [ALLDIFF](https://documentation.sas.com/doc/en/pgmsascdc/v_014/orcpug/orcpug_clp_syntax04.htm): `CP.AllDifferent` +- [ALLDIFF](https://documentation.sas.com/doc/en/pgmsascdc/v_014/orcpug/orcpug_clp_syntax04.htm): `MOI.AllDifferent` - [CUMULATIVE](https://documentation.sas.com/doc/en/pgmsascdc/v_014/orcpug/orcpug_clp_syntax06.htm): `CP.CumulativeResource` - [ARRAY](https://documentation.sas.com/doc/en/pgmsascdc/v_014/orcpug/orcpug_clp_syntax05.htm) - [ELEMENT](https://documentation.sas.com/doc/en/pgmsascdc/v_014/orcpug/orcpug_clp_syntax07.htm) diff --git a/docs/src/reference/sets.md b/docs/src/reference/sets.md index fcdfe447..b2b29f0f 100644 --- a/docs/src/reference/sets.md +++ b/docs/src/reference/sets.md @@ -27,7 +27,6 @@ ElementVariableArray ```@docs AllEqual -AllDifferent AllDifferentExceptConstants AllDifferentExceptConstant SymmetricAllDifferent diff --git a/src/Bridges/Constraint/AllDifferent/ad_to_neq.jl b/src/Bridges/Constraint/AllDifferent/ad_to_neq.jl index 6aa91984..e444279f 100644 --- a/src/Bridges/Constraint/AllDifferent/ad_to_neq.jl +++ b/src/Bridges/Constraint/AllDifferent/ad_to_neq.jl @@ -1,5 +1,5 @@ """ -Bridges `CP.AllDifferent` to a series of `CP.DifferentFrom`. +Bridges `MOI.AllDifferent` to a series of `CP.DifferentFrom`. """ struct AllDifferent2DifferentFromBridge{T} <: MOIBC.AbstractBridge # An upper-triangular matrix (i.e. nothing if i < j, constraint if i >= j). @@ -16,7 +16,7 @@ function MOIBC.bridge_constraint( ::Type{AllDifferent2DifferentFromBridge{T}}, model, f::MOI.VectorOfVariables, - s::CP.AllDifferent, + s::MOI.AllDifferent, ) where {T} return MOIBC.bridge_constraint( AllDifferent2DifferentFromBridge{T}, @@ -30,7 +30,7 @@ function MOIBC.bridge_constraint( ::Type{AllDifferent2DifferentFromBridge{T}}, model, f::MOI.VectorAffineFunction{T}, - s::CP.AllDifferent, + s::MOI.AllDifferent, ) where {T} f_scalars = MOIU.scalarize(f) dim = MOI.output_dimension(f) @@ -59,7 +59,7 @@ end function MOI.supports_constraint( ::Type{AllDifferent2DifferentFromBridge{T}}, ::Union{Type{MOI.VectorOfVariables}, Type{MOI.VectorAffineFunction{T}}}, - ::Type{CP.AllDifferent}, + ::Type{MOI.AllDifferent}, ) where {T} return true end diff --git a/src/Bridges/Constraint/SortPermutation/perm_to_alldiff_indexing.jl b/src/Bridges/Constraint/SortPermutation/perm_to_alldiff_indexing.jl index 6ecd19c8..8e2e90e8 100644 --- a/src/Bridges/Constraint/SortPermutation/perm_to_alldiff_indexing.jl +++ b/src/Bridges/Constraint/SortPermutation/perm_to_alldiff_indexing.jl @@ -1,9 +1,9 @@ """ -Bridges `CP.SortPermutation` to `CP.AllDifferent` and +Bridges `CP.SortPermutation` to `MOI.AllDifferent` and `CP.ElementVariableArray`. """ struct SortPermutation2AllDifferentBridge{T} <: MOIBC.AbstractBridge - con_alldiff::MOI.ConstraintIndex{MOI.VectorAffineFunction{T}, CP.AllDifferent} + con_alldiff::MOI.ConstraintIndex{MOI.VectorAffineFunction{T}, MOI.AllDifferent} cons_value::Vector{MOI.ConstraintIndex{MOI.VectorAffineFunction{T}, CP.ElementVariableArray}} cons_sort::Vector{MOI.ConstraintIndex{MOI.ScalarAffineFunction{T}, MOI.GreaterThan{T}}} end @@ -50,7 +50,7 @@ function MOIBC.bridge_constraint( con_alldiff = MOI.add_constraint( model, MOIU.vectorize(indices), - CP.AllDifferent(dim) + MOI.AllDifferent(dim) ) # Relate the three sets of variables by indexing. @@ -86,7 +86,7 @@ end function MOIB.added_constraint_types(::Type{SortPermutation2AllDifferentBridge{T}}) where {T} return [ - (MOI.VectorAffineFunction{T}, CP.AllDifferent), + (MOI.VectorAffineFunction{T}, MOI.AllDifferent), (MOI.ScalarAffineFunction{T}, CP.ElementVariableArray), (MOI.ScalarAffineFunction{T}, MOI.LessThan{T}), ] @@ -95,7 +95,7 @@ end function MOI.get( ::SortPermutation2AllDifferentBridge{T}, ::MOI.NumberOfConstraints{ - MOI.VectorAffineFunction{T}, CP.AllDifferent, + MOI.VectorAffineFunction{T}, MOI.AllDifferent, }, ) where {T} return 1 @@ -122,7 +122,7 @@ end function MOI.get( b::SortPermutation2AllDifferentBridge{T}, ::MOI.ListOfConstraintIndices{ - MOI.VectorAffineFunction{T}, CP.AllDifferent, + MOI.VectorAffineFunction{T}, MOI.AllDifferent, }, ) where {T} return [b.con_alldiff] diff --git a/src/Bridges/Constraint/SymmetricAllDifferent/salldiff_to_alldiff_inverse.jl b/src/Bridges/Constraint/SymmetricAllDifferent/salldiff_to_alldiff_inverse.jl index 8977bf6f..070c5995 100644 --- a/src/Bridges/Constraint/SymmetricAllDifferent/salldiff_to_alldiff_inverse.jl +++ b/src/Bridges/Constraint/SymmetricAllDifferent/salldiff_to_alldiff_inverse.jl @@ -1,8 +1,8 @@ """ -Bridges `CP.SymmetricAllDifferent` to `CP.AllDifferent` and `CP.Inverse`. +Bridges `CP.SymmetricAllDifferent` to `MOI.AllDifferent` and `CP.Inverse`. """ struct SymmetricAllDifferent2AllDifferentInverseBridge{T} <: MOIBC.AbstractBridge - con_all_diff::MOI.ConstraintIndex{MOI.VectorAffineFunction{T}, CP.AllDifferent} + con_all_diff::MOI.ConstraintIndex{MOI.VectorAffineFunction{T}, MOI.AllDifferent} con_inverse::MOI.ConstraintIndex{MOI.VectorAffineFunction{T}, CP.Inverse} end @@ -32,7 +32,7 @@ function MOIBC.bridge_constraint( con_all_diff = MOI.add_constraint( model, f, - CP.AllDifferent(dim) + MOI.AllDifferent(dim) ) con_inverse = MOI.add_constraint( @@ -58,7 +58,7 @@ end function MOIB.added_constraint_types(::Type{SymmetricAllDifferent2AllDifferentInverseBridge{T}}) where {T} return [ - (MOI.VectorAffineFunction{T}, CP.AllDifferent), + (MOI.VectorAffineFunction{T}, MOI.AllDifferent), (MOI.VectorAffineFunction{T}, CP.Inverse), ] end @@ -66,7 +66,7 @@ end function MOI.get( ::SymmetricAllDifferent2AllDifferentInverseBridge{T}, ::MOI.NumberOfConstraints{ - MOI.VectorAffineFunction{T}, CP.AllDifferent, + MOI.VectorAffineFunction{T}, MOI.AllDifferent, }, ) where {T} return 1 @@ -84,7 +84,7 @@ end function MOI.get( b::SymmetricAllDifferent2AllDifferentInverseBridge{T}, ::MOI.ListOfConstraintIndices{ - MOI.VectorAffineFunction{T}, CP.AllDifferent, + MOI.VectorAffineFunction{T}, MOI.AllDifferent, }, ) where {T} return [b.con_all_diff] diff --git a/src/Test/test_alldifferent.jl b/src/Test/test_alldifferent.jl index afe9a66f..2b524920 100644 --- a/src/Test/test_alldifferent.jl +++ b/src/Test/test_alldifferent.jl @@ -5,7 +5,7 @@ function test_alldifferent_vectorofvariables( # @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.Integer) # x1, x2 # @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.EqualTo{T}) # c1 # @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.Interval{T}) # c2 - @MOIT.requires MOI.supports_constraint(model, MOI.VectorOfVariables, CP.AllDifferent) # c3 + @MOIT.requires MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.AllDifferent) # c3 x1, _ = MOI.add_constrained_variable(model, MOI.Integer()) x2, _ = MOI.add_constrained_variable(model, MOI.Integer()) @@ -13,7 +13,7 @@ function test_alldifferent_vectorofvariables( c1 = MOI.add_constraint(model, x1, MOI.EqualTo(T(1))) c2 = MOI.add_constraint(model, x2, MOI.Interval(T(1), T(2))) - c3 = MOI.add_constraint(model, MOI.VectorOfVariables([x1, x2]), CP.AllDifferent(2)) + c3 = MOI.add_constraint(model, MOI.VectorOfVariables([x1, x2]), MOI.AllDifferent(2)) @test MOI.is_valid(model, x1) @test MOI.is_valid(model, x2) @@ -51,7 +51,7 @@ function test_alldifferent_vectoraffinefunction( ) where {T <: Real} @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.Integer) # x1, x2 @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.Interval{Int}) # c1, c2 - @MOIT.requires MOI.supports_constraint(model, MOI.VectorAffineFunction{Int}, CP.AllDifferent) # c3 + @MOIT.requires MOI.supports_constraint(model, MOI.VectorAffineFunction{Int}, MOI.AllDifferent) # c3 @MOIT.requires MOI.supports_constraint(model, MOI.ScalarAffineFunction{Int}, MOI.EqualTo{Int}) # c4 x1, _ = MOI.add_constrained_variable(model, MOI.Integer()) @@ -60,7 +60,7 @@ function test_alldifferent_vectoraffinefunction( c1 = MOI.add_constraint(model, x1, MOI.Interval(T(1), T(2))) c2 = MOI.add_constraint(model, x2, MOI.Interval(T(1), T(2))) - c3 = MOI.add_constraint(model, MOIU.vectorize(one(T) .* [x1, x2]), CP.AllDifferent(2)) + c3 = MOI.add_constraint(model, MOIU.vectorize(one(T) .* [x1, x2]), MOI.AllDifferent(2)) c4 = MOI.add_constraint(model, one(T) * x1, MOI.EqualTo(1)) @test MOI.is_valid(model, x1) diff --git a/src/Test/test_antidomain.jl b/src/Test/test_antidomain.jl index b928c6e3..e60c3d83 100644 --- a/src/Test/test_antidomain.jl +++ b/src/Test/test_antidomain.jl @@ -6,7 +6,7 @@ function test_antidomain_singlevariable( @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.EqualTo{T}) # c1 @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.GreaterThan{T}) # c2 @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.LessThan{T}) # c3 - @MOIT.requires MOI.supports_constraint(model, MOI.VectorOfVariables, CP.AllDifferent) # c4 + @MOIT.requires MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.AllDifferent) # c4 @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, CP.AntiDomain{T}) # c5 x1, _ = MOI.add_constrained_variable(model, MOI.Integer()) @@ -15,7 +15,7 @@ function test_antidomain_singlevariable( c1 = MOI.add_constraint(model, x1, MOI.EqualTo(T(1))) c2 = MOI.add_constraint(model, x2, MOI.GreaterThan(T(1))) c3 = MOI.add_constraint(model, x2, MOI.LessThan(T(3))) - c4 = MOI.add_constraint(model, MOI.VectorOfVariables([x1, x2]), CP.AllDifferent(2)) + c4 = MOI.add_constraint(model, MOI.VectorOfVariables([x1, x2]), MOI.AllDifferent(2)) c5 = MOI.add_constraint(model, x2, CP.AntiDomain(Set(T[3]))) @@ -59,7 +59,7 @@ function test_antidomain_scalaraffinefunction( @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.EqualTo{Int}) # c1 @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.GreaterThan{Int}) # c2 @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.LessThan{Int}) # c3 - @MOIT.requires MOI.supports_constraint(model, MOI.ScalarAffineFunction{Int}, CP.AllDifferent) # c4 + @MOIT.requires MOI.supports_constraint(model, MOI.ScalarAffineFunction{Int}, MOI.AllDifferent) # c4 @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, CP.AntiDomain{Int}) # c5 x1, _ = MOI.add_constrained_variable(model, MOI.Integer()) @@ -68,7 +68,7 @@ function test_antidomain_scalaraffinefunction( c1 = MOI.add_constraint(model, x1, MOI.EqualTo(T(1))) c2 = MOI.add_constraint(model, x2, MOI.GreaterThan(T(1))) c3 = MOI.add_constraint(model, x2, MOI.LessThan(T(3))) - c4 = MOI.add_constraint(model, MOIU.vectorize(one(T) .* [x1, x2]), CP.AllDifferent(2)) + c4 = MOI.add_constraint(model, MOIU.vectorize(one(T) .* [x1, x2]), MOI.AllDifferent(2)) c5 = MOI.add_constraint( model, diff --git a/src/Test/test_domain.jl b/src/Test/test_domain.jl index 20394806..390404dc 100644 --- a/src/Test/test_domain.jl +++ b/src/Test/test_domain.jl @@ -6,12 +6,12 @@ function test_domain_singlevariable( @show MOI.supports_add_constrained_variable(model, MOI.Integer) # x1, x2 @show MOI.supports_constraint(model, MOI.VariableIndex, MOI.Integer) # x1, x2 @show MOI.supports_constraint(model, MOI.VariableIndex, CP.Domain{T}) # c1, c2 - @show MOI.supports_constraint(model, MOI.VectorOfVariables, CP.AllDifferent) # c3 + @show MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.AllDifferent) # c3 @show MOI.supports_constraint(model, MOI.VariableIndex, MOI.EqualTo{T}) # c4 @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.Integer) # x1, x2 @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, CP.Domain{T}) # c1, c2 - @MOIT.requires MOI.supports_constraint(model, MOI.VectorOfVariables, CP.AllDifferent) # c3 + @MOIT.requires MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.AllDifferent) # c3 @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.EqualTo{T}) # c4 x1, _ = MOI.add_constrained_variable(model, MOI.Integer()) @@ -20,7 +20,7 @@ function test_domain_singlevariable( c1 = MOI.add_constraint(model, x1, CP.Domain(Set([1, 2]))) c2 = MOI.add_constraint(model, x2, CP.Domain(Set([1, 2]))) - c3 = MOI.add_constraint(model, MOIU.vectorize([x1, x2]), CP.AllDifferent(2)) + c3 = MOI.add_constraint(model, MOIU.vectorize([x1, x2]), MOI.AllDifferent(2)) c4 = MOI.add_constraint(model, x1, MOI.EqualTo(1)) @test MOI.is_valid(model, x1) @@ -59,7 +59,7 @@ function test_domain_scalaraffinefunction( ) where {T <: Real} @MOIT.requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.Integer) # x1, x2 @MOIT.requires MOI.supports_constraint(model, MOI.ScalarAffineFunction{T}, CP.Domain{T}) # c1, c2 - @MOIT.requires MOI.supports_constraint(model, MOI.VectorAffineFunction{T}, CP.AllDifferent) # c3 + @MOIT.requires MOI.supports_constraint(model, MOI.VectorAffineFunction{T}, MOI.AllDifferent) # c3 @MOIT.requires MOI.supports_constraint(model, MOI.ScalarAffineFunction{T}, MOI.EqualTo{T}) # c4 x1, _ = MOI.add_constrained_variable(model, MOI.Integer()) @@ -79,7 +79,7 @@ function test_domain_scalaraffinefunction( c3 = MOI.add_constraint( model, MOIU.vectorize(one(T) .* [x1, x2]), - CP.AllDifferent(2), + MOI.AllDifferent(2), ) c4 = MOI.add_constraint( model, diff --git a/src/sets.jl b/src/sets.jl index ee45d71e..770dfd1d 100644 --- a/src/sets.jl +++ b/src/sets.jl @@ -15,26 +15,6 @@ struct AllEqual <: MOI.AbstractVectorSet dimension::Int end -""" - AllDifferent(dimension::Int) - -The set corresponding to an all-different constraint. - -All expressions of a vector-valued function are enforced to take distinct -values in the solution: for all pairs of expressions, their values must -differ. - -This constraint is sometimes called `distinct`. - -## Example - - [x, y, z] in AllDifferent(3) - # enforces `x != y` AND `x != z` AND `y != z`. -""" -struct AllDifferent <: MOI.AbstractVectorSet - dimension::Int -end - # https://sofdem.github.io/gccat/gccat/Calldifferent_cst.html should be modelled # with AllDifferent, because it is just shifting all expressions by constants, # i.e. scalar affine expressions. @@ -400,7 +380,7 @@ MOI.dimension(set::Inverse) = 2 * set.dimension # isbits types, nothing to copy function copy( - set::Union{AllEqual, AllDifferent, SymmetricAllDifferent, Membership, Inverse, SlidingSum,}, + set::Union{AllEqual, SymmetricAllDifferent, Membership, Inverse, SlidingSum,}, ) return set end diff --git a/src/sets_count.jl b/src/sets_count.jl index 74ffe000..bd968e14 100644 --- a/src/sets_count.jl +++ b/src/sets_count.jl @@ -259,7 +259,7 @@ MOI.dimension(set::CountCompare) = 2 * set.dimension + 1 The first variable in the set is forced to be the number of distinct values in the rest of the expressions. -This is a relaxed version of `AllDifferent`; it encodes an `AllDifferent` +This is a relaxed version of `MOI.AllDifferent`; it encodes an `MOI.AllDifferent` constraint when the first variable is the number of variables in the set. Also called `nvalues`. diff --git a/test/Bridges/Constraint/AllDifferent/ad_to_neq.jl b/test/Bridges/Constraint/AllDifferent/ad_to_neq.jl index 9ce29b1d..b2f63e05 100644 --- a/test/Bridges/Constraint/AllDifferent/ad_to_neq.jl +++ b/test/Bridges/Constraint/AllDifferent/ad_to_neq.jl @@ -13,7 +13,7 @@ @test MOIB.supports_bridging_constraint( model, MOI.VectorAffineFunction{T}, - CP.AllDifferent, + MOI.AllDifferent, ) if T == Int @@ -29,17 +29,17 @@ else @assert false end - c = MOI.add_constraint(model, fct, CP.AllDifferent(dim)) + c = MOI.add_constraint(model, fct, MOI.AllDifferent(dim)) for i in 1:dim @test MOI.is_valid(model, x[i]) end @test MOI.is_valid(model, c) - bridge = MOIBC.bridges(model)[MOI.ConstraintIndex{MOI.VectorOfVariables, CP.AllDifferent}(-1)] + bridge = MOIBC.bridges(model)[MOI.ConstraintIndex{MOI.VectorOfVariables, MOI.AllDifferent}(-1)] @testset "Bridge properties" begin - @test MOIBC.concrete_bridge_type(typeof(bridge), MOI.VectorOfVariables, CP.AllDifferent) == typeof(bridge) + @test MOIBC.concrete_bridge_type(typeof(bridge), MOI.VectorOfVariables, MOI.AllDifferent) == typeof(bridge) @test MOIB.added_constrained_variable_types(typeof(bridge)) == Tuple{Type}[] @test MOIB.added_constraint_types(typeof(bridge)) == [(MOI.ScalarAffineFunction{T}, CP.DifferentFrom{T})] diff --git a/test/Bridges/Constraint/SortPermutation/perm_to_alldiff_indexing.jl b/test/Bridges/Constraint/SortPermutation/perm_to_alldiff_indexing.jl index 881fb3b0..bcae99b3 100644 --- a/test/Bridges/Constraint/SortPermutation/perm_to_alldiff_indexing.jl +++ b/test/Bridges/Constraint/SortPermutation/perm_to_alldiff_indexing.jl @@ -9,7 +9,7 @@ @test MOI.supports_constraint( model, MOI.VectorAffineFunction{T}, - CP.AllDifferent, + MOI.AllDifferent, ) @test MOI.supports_constraint( model, @@ -49,17 +49,17 @@ @test MOIBC.concrete_bridge_type(typeof(bridge), MOI.VectorOfVariables, CP.MinimumAmong) == typeof(bridge) @test MOIB.added_constrained_variable_types(typeof(bridge)) == Tuple{Type}[] @test MOIB.added_constraint_types(typeof(bridge)) == [ - (MOI.VectorAffineFunction{T}, CP.AllDifferent), + (MOI.VectorAffineFunction{T}, MOI.AllDifferent), (MOI.ScalarAffineFunction{T}, CP.ElementVariableArray), (MOI.ScalarAffineFunction{T}, MOI.LessThan{T}), ] @test MOI.get(bridge, MOI.NumberOfVariables()) == 0 - @test MOI.get(bridge, MOI.NumberOfConstraints{MOI.VectorAffineFunction{T}, CP.AllDifferent}()) == 1 + @test MOI.get(bridge, MOI.NumberOfConstraints{MOI.VectorAffineFunction{T}, MOI.AllDifferent}()) == 1 @test MOI.get(bridge, MOI.NumberOfConstraints{MOI.ScalarAffineFunction{T}, CP.ElementVariableArray}()) == array_dim @test MOI.get(bridge, MOI.NumberOfConstraints{MOI.ScalarAffineFunction{T}, MOI.LessThan{T}}()) == array_dim - 1 - @test MOI.get(bridge, MOI.ListOfConstraintIndices{MOI.VectorAffineFunction{T}, CP.AllDifferent}()) == [bridge.con_alldiff] + @test MOI.get(bridge, MOI.ListOfConstraintIndices{MOI.VectorAffineFunction{T}, MOI.AllDifferent}()) == [bridge.con_alldiff] @test MOI.get(bridge, MOI.ListOfConstraintIndices{MOI.ScalarAffineFunction{T}, CP.ElementVariableArray}()) == bridge.cons_value @test MOI.get(bridge, MOI.ListOfConstraintIndices{MOI.ScalarAffineFunction{T}, MOI.LessThan{T}}()) == bridge.cons_sort end @@ -69,7 +69,7 @@ s = MOI.get(model, MOI.ConstraintSet(), bridge.con_alldiff) f = MOI.get(model, MOI.ConstraintFunction(), bridge.con_alldiff) - @test typeof(s) == CP.AllDifferent + @test typeof(s) == MOI.AllDifferent @test length(f.terms) == array_dim @test f.constants == zeros(T, array_dim) diff --git a/test/Bridges/Constraint/SymmetricAllDifferent/salldiff_to_alldiff_inverse.jl b/test/Bridges/Constraint/SymmetricAllDifferent/salldiff_to_alldiff_inverse.jl index da1c06c9..7dce4af3 100644 --- a/test/Bridges/Constraint/SymmetricAllDifferent/salldiff_to_alldiff_inverse.jl +++ b/test/Bridges/Constraint/SymmetricAllDifferent/salldiff_to_alldiff_inverse.jl @@ -8,7 +8,7 @@ @test MOI.supports_constraint( model, MOI.VectorAffineFunction{T}, - CP.AllDifferent, + MOI.AllDifferent, ) @test MOI.supports_constraint( model, @@ -47,15 +47,15 @@ @test MOIBC.concrete_bridge_type(typeof(bridge), MOI.VariableIndex, CP.SymmetricAllDifferent) == typeof(bridge) @test MOIB.added_constrained_variable_types(typeof(bridge)) == Tuple{Type}[] @test MOIB.added_constraint_types(typeof(bridge)) == [ - (MOI.VectorAffineFunction{T}, CP.AllDifferent), + (MOI.VectorAffineFunction{T}, MOI.AllDifferent), (MOI.VectorAffineFunction{T}, CP.Inverse), ] @test MOI.get(bridge, MOI.NumberOfVariables()) == 0 - @test MOI.get(bridge, MOI.NumberOfConstraints{MOI.VectorAffineFunction{T}, CP.AllDifferent}()) == 1 + @test MOI.get(bridge, MOI.NumberOfConstraints{MOI.VectorAffineFunction{T}, MOI.AllDifferent}()) == 1 @test MOI.get(bridge, MOI.NumberOfConstraints{MOI.VectorAffineFunction{T}, CP.Inverse}()) == 1 - @test MOI.get(bridge, MOI.ListOfConstraintIndices{MOI.VectorAffineFunction{T}, CP.AllDifferent}()) == [bridge.con_all_diff] + @test MOI.get(bridge, MOI.ListOfConstraintIndices{MOI.VectorAffineFunction{T}, MOI.AllDifferent}()) == [bridge.con_all_diff] @test MOI.get(bridge, MOI.ListOfConstraintIndices{MOI.VectorAffineFunction{T}, CP.Inverse}()) == [bridge.con_inverse] end @@ -63,7 +63,7 @@ @test MOI.is_valid(model, bridge.con_all_diff) f = MOI.get(model, MOI.ConstraintFunction(), bridge.con_all_diff) @test length(f.terms) == dim - @test MOI.get(model, MOI.ConstraintSet(), bridge.con_all_diff) == CP.AllDifferent(dim) + @test MOI.get(model, MOI.ConstraintSet(), bridge.con_all_diff) == MOI.AllDifferent(dim) for i in 1:dim t = f.terms[i] diff --git a/test/Bridges/models.jl b/test/Bridges/models.jl index a7e6db8a..6072e516 100644 --- a/test/Bridges/models.jl +++ b/test/Bridges/models.jl @@ -273,7 +273,7 @@ MOIU.@model( MOI.NormNuclearCone, MOI.PositiveSemidefiniteConeTriangle, MOI.ExponentialCone, - CP.AllDifferent, + MOI.AllDifferent, CP.ElementVariableArray, ), (MOI.PowerCone, MOI.DualPowerCone), @@ -306,7 +306,7 @@ MOIU.@model( MOI.NormNuclearCone, MOI.PositiveSemidefiniteConeTriangle, MOI.ExponentialCone, - CP.AllDifferent, + MOI.AllDifferent, CP.Inverse, ), (MOI.PowerCone, MOI.DualPowerCone), diff --git a/test/sets.jl b/test/sets.jl index e3ce0165..da0487a4 100644 --- a/test/sets.jl +++ b/test/sets.jl @@ -24,7 +24,7 @@ # Just a dimension. @testset "$(S)" for S in [ CP.AllEqual, - CP.AllDifferent, + MOI.AllDifferent, CP.SymmetricAllDifferent, CP.Membership, CP.ElementVariableArray, @@ -54,7 +54,7 @@ if S in [ CP.AllEqual, - CP.AllDifferent, + MOI.AllDifferent, CP.SymmetricAllDifferent, CP.Membership, CP.Contiguity, From e8d2b0b050a9ae28292cd32e0c2e03b372fce470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 9 Oct 2024 16:29:18 +0200 Subject: [PATCH 2/3] Remove coverall --- .github/workflows/GitHubCI.yml | 4 ---- README.md | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/GitHubCI.yml b/.github/workflows/GitHubCI.yml index c4610b6b..941a2604 100644 --- a/.github/workflows/GitHubCI.yml +++ b/.github/workflows/GitHubCI.yml @@ -91,7 +91,3 @@ jobs: - uses: codecov/codecov-action@v4 with: file: lcov.info - - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: lcov.info diff --git a/README.md b/README.md index d673d5e3..460d9c77 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ [![DOI](https://zenodo.org/badge/240344723.svg)](https://zenodo.org/badge/latestdoi/240344723) [![Continuous integration](https://github.com/JuliaConstraints/ConstraintProgrammingExtensions.jl/actions/workflows/GitHubCI.yml/badge.svg)](https://github.com/JuliaConstraints/ConstraintProgrammingExtensions.jl/actions/workflows/GitHubCI.yml/) -[![Coverage Status](https://coveralls.io/repos/JuliaConstraints/ConstraintProgrammingExtensions.jl/badge.svg?branch=master)](https://coveralls.io/r/JuliaConstraints/ConstraintProgrammingExtensions.jl?branch=master) -[![codecov](https://codecov.io/gh/JuliaConstraints/ConstraintProgrammingExtensions.jl/graph/badge.svg?token=watKBcsP59)](https://codecov.io/gh/JuliaConstraints/ConstraintProgrammingExtensions.jl) +[![Coverage Status](https://codecov.io/gh/JuliaConstraints/ConstraintProgrammingExtensions.jl/graph/badge.svg?token=watKBcsP59)](https://codecov.io/gh/JuliaConstraints/ConstraintProgrammingExtensions.jl) This package provides extensions to [MathOptInterface](https://github.com/jump-dev/MathOptInterface.jl) From 7d131514f2b04d1ea246f55700233b664b649c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 9 Oct 2024 16:29:41 +0200 Subject: [PATCH 3/3] Remove appveyor and travis --- .appveyor.yml | 36 ------------------------------------ .travis.yml | 20 -------------------- 2 files changed, 56 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .travis.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 97a9d9cc..00000000 --- a/.appveyor.yml +++ /dev/null @@ -1,36 +0,0 @@ -environment: - matrix: - - julia_version: 1.0 - - julia_version: 1.3 - - julia_version: 1.4 - - julia_version: nightly - -platform: - - x86 # 32-bit - - x64 # 64-bit - -matrix: - allow_failures: - - julia_version: nightly - -branches: - only: - - master - - /release-.*/ - -notifications: - - provider: Email - on_build_success: false - on_build_failure: false - on_build_status_changed: false - -install: - - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) - -build_script: - - echo "%JL_BUILD_SCRIPT%" - - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" - -test_script: - - echo "%JL_TEST_SCRIPT%" - - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 58c54a76..00000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: julia - -os: - - osx - - linux - -julia: - - 1.0 - - 1.3 - - 1.4 - - nightly - -notifications: - email: false - -allow_failures: - - julia: nightly - -codecov: true -coveralls: true