Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overload MOI.set & supports for ConstraintAttribute in bridgeoptimizer #699

Merged
merged 7 commits into from
Apr 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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