From 327c9f3362989665e15fdccdb07655e028ceeccf Mon Sep 17 00:00:00 2001 From: Joaquim Garcia Date: Sat, 17 Oct 2020 01:45:54 -0300 Subject: [PATCH 1/2] add abstract typing --- src/moi.jl | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/moi.jl b/src/moi.jl index 04dbbe5..bccfa22 100644 --- a/src/moi.jl +++ b/src/moi.jl @@ -1454,10 +1454,10 @@ function MOI.get( return MOI.get(model.optimizer, attr, x) end -struct VariablePrecision end -struct GlobalVariablePrecision end -struct FallbackUpperBound end -struct FallbackLowerBound end +struct VariablePrecision <: MOI.AbstractVariableAttribute end +struct GlobalVariablePrecision <: MOI.AbstractOptimizerAttribute end +struct FallbackUpperBound <: MOI.AbstractOptimizerAttribute end +struct FallbackLowerBound <: MOI.AbstractOptimizerAttribute end function MOI.set( model::Optimizer, @@ -1520,10 +1520,24 @@ function MOI.get(model::Optimizer, ::MOI.NumberOfConstraints{F, S}) where {F, S} return length(MOI.get(model, MOI.ListOfConstraintIndices{F,S}())) end - -function MOI.get(::Optimizer, ::MOI.ListOfConstraints) +function MOI.get(model::Optimizer, ::MOI.ListOfConstraints) constraints = Set{Tuple{DataType, DataType}}() - error("TODO") + inner_ctrs = MOI.get(model.optimizer, MOI.ListOfConstraints()) + for (F, S) in inner_ctrs + if F <: Union{MOI.ScalarAffineFunction, MOI.VectorQuadraticFunction} + if MOI.get(model, MOI.NumberOfConstraints{F, S}()) > 0 + push!(constraints, (F,S)) + end + if MOI.get(model, MOI.NumberOfConstraints{quadratic_type(F), S}()) > 0 + push!(constraints, (quadratic_type(F),S)) + end + else + push!(constraints, (F,S)) + end + end + # error("TODO") + # deal with deleted parameters + collect(constraints) end function ordered_term_indices(t::MOI.ScalarQuadraticTerm) From cf0e6ae8b455f68e48961efabb1611a0a9daf527 Mon Sep 17 00:00:00 2001 From: Joaquim Garcia Date: Sat, 17 Oct 2020 02:02:08 -0300 Subject: [PATCH 2/2] bump version --- Project.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 80d6c54..db1032b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,8 +1,7 @@ name = "QuadraticToBinary" uuid = "014a38d5-7acb-4e20-b6c0-4fe5c2344fd1" authors = ["Joaquim Garcia "] -version = "0.2.2" - +version = "0.2.3" [deps] MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"