Skip to content

Commit

Permalink
Merge pull request #699 from guimarqu/master
Browse files Browse the repository at this point in the history
overload MOI.set & supports for ConstraintAttribute in bridgeoptimizer
  • Loading branch information
blegat authored Apr 27, 2019
2 parents 208a9aa + 1f1503f commit c6149d5
Showing 1 changed file with 48 additions and 8 deletions.
56 changes: 48 additions & 8 deletions src/Bridges/bridgeoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,42 @@ function MOI.get(b::AbstractBridgeOptimizer,
attr::MOI.AbstractConstraintAttribute,
ci::CI)
if is_bridged(b, typeof(ci))
if MOI.is_set_by_optimize(attr)
MOI.get(b, attr, bridge(b, ci))
else
MOI.get(b.bridged, attr, ci)
end
return MOI.get(b, attr, bridge(b, ci))
else
return MOI.get(b.model, attr, ci)
end
end
function MOI.supports(b::AbstractBridgeOptimizer,
attr::MOI.AbstractConstraintAttribute,
IndexType::Type{CI{F, S}}) where {F,S}
if is_bridged(b, IndexType)
return MOI.supports(b, attr, concrete_bridge_type(b, F, S))
else
return MOI.supports(b.model, attr, IndexType)
end
end

function MOI.set(b::AbstractBridgeOptimizer,
attr::MOI.AbstractConstraintAttribute,
index::CI, value)
if is_bridged(b, typeof(index))
return MOI.set(b, attr, bridge(b, index), value)
else
return MOI.set(b.model, attr, index, value)
end
end
## Getting and Setting names
function MOI.get(b::AbstractBridgeOptimizer, attr::MOI.ConstraintName,
constraint_index::CI)
if is_bridged(b, typeof(constraint_index))
return MOI.get(b.bridged, attr, constraint_index)
else
MOI.get(b.model, attr, ci)
return MOI.get(b.model, attr, constraint_index)
end
end
## Setting names

function MOI.supports(b::AbstractBridgeOptimizer, attr::MOI.ConstraintName,
Index::Type{<:CI})
Index::Type{CI{F,S}}) where {F,S}
if is_bridged(b, Index)
return MOI.supports(b.bridged, attr, Index)
else
Expand All @@ -253,6 +277,22 @@ function MOI.set(b::AbstractBridgeOptimizer, attr::MOI.ConstraintName,
MOI.set(b.model, attr, constraint_index, name)
end
end
## Getting functions and sets
function MOI.get(b::AbstractBridgeOptimizer, attr::MOI.ConstraintSet, ci::CI)
if is_bridged(b, typeof(ci))
return MOI.get(b.bridged, attr, ci)
else
return MOI.get(b.model, attr, ci)
end
end
function MOI.get(b::AbstractBridgeOptimizer, attr::MOI.ConstraintFunction,
ci::CI)
if is_bridged(b, typeof(ci))
return MOI.get(b.bridged, attr, ci)
else
return MOI.get(b.model, attr, ci)
end
end
## Setting functions and sets
function MOI.set(b::AbstractBridgeOptimizer, ::MOI.ConstraintSet,
constraint_index::CI{F, S}, set::S) where {F, S}
Expand Down

0 comments on commit c6149d5

Please sign in to comment.