Skip to content

Commit

Permalink
Merge pull request #13 from joaquimg/jg/abstract
Browse files Browse the repository at this point in the history
Add abstract types
  • Loading branch information
joaquimg authored Oct 17, 2020
2 parents f6991f3 + cf0e6ae commit beb8533
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name = "QuadraticToBinary"
uuid = "014a38d5-7acb-4e20-b6c0-4fe5c2344fd1"
authors = ["Joaquim Garcia <[email protected]>"]
version = "0.2.2"

version = "0.2.3"

[deps]
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
Expand Down
28 changes: 21 additions & 7 deletions src/moi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

2 comments on commit beb8533

@joaquimg
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/23130

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.3 -m "<description of version>" beb8533772fee06f2d549c79519420838688fc83
git push origin v0.2.3

Please sign in to comment.