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 3 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
63 changes: 49 additions & 14 deletions src/Bridges/bridgeoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,37 +222,72 @@ function MOI.set(b::AbstractBridgeOptimizer,
return MOI.set(b.model, attr, indices, values)
end

# function MOI.get(::MOI.ModelLike, attr::MOI.AbstractConstraintAttribute,
blegat marked this conversation as resolved.
Show resolved Hide resolved
# bridge::AbstractBridge)
# throw(ArgumentError("Constraint bridge of type `$(typeof(bridge))` does not support accessing the attribute `$attr`."))
# end

# Constraint attributes
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
if attr isa MOI.ConstraintName || attr isa MOI.ConstraintFunction ||
blegat marked this conversation as resolved.
Show resolved Hide resolved
blegat marked this conversation as resolved.
Show resolved Hide resolved
attr isa MOI.ConstraintSet
MOI.get(b.bridged, attr, ci)
else
MOI.get(b, attr, bridge(b, ci))
end
else
MOI.get(b.model, attr, ci)
end
end
## Setting names
function MOI.supports(b::AbstractBridgeOptimizer, attr::MOI.ConstraintName,
Index::Type{<:CI})
if is_bridged(b, Index)
return MOI.supports(b.bridged, attr, Index)
function MOI.supports(b::AbstractBridgeOptimizer,
attr::MOI.AbstractConstraintAttribute,
IndexType::Type{CI{F, S}}) where {F,S}
if is_bridged(b, IndexType)
if attr isa MOI.ConstraintName || attr isa MOI.ConstraintFunction ||
blegat marked this conversation as resolved.
Show resolved Hide resolved
attr isa MOI.ConstraintSet
return MOI.supports(b.bridged, attr, IndexType)
else
return MOI.supports(b, attr, concrete_bridge_type(b, F, S))
end
else
return MOI.supports(b.model, attr, Index)
return MOI.supports(b.model, attr, IndexType)
end
end
function MOI.set(b::AbstractBridgeOptimizer, attr::MOI.ConstraintName,
constraint_index::CI, name::String)
if is_bridged(b, typeof(constraint_index))
MOI.set(b.bridged, attr, constraint_index, name)

function MOI.set(b::AbstractBridgeOptimizer,
attr::MOI.AbstractConstraintAttribute,
index::CI, value)
if is_bridged(b, typeof(index))
if attr isa MOI.ConstraintName || attr isa MOI.ConstraintFunction ||
blegat marked this conversation as resolved.
Show resolved Hide resolved
attr isa MOI.ConstraintName
return MOI.set(b.bridged, attr, index, value)
else
return MOI.set(b, attr, bridge(b, index), value)
end
else
MOI.set(b.model, attr, constraint_index, name)
return MOI.set(b.model, attr, index, value)
end
end
## Setting names
# function MOI.supports(b::AbstractBridgeOptimizer, attr::MOI.ConstraintName,
# Index::Type{<:CI})
# if is_bridged(b, Index)
# return MOI.supports(b.bridged, attr, Index)
# else
# return MOI.supports(b.model, attr, Index)
# end
# end
# function MOI.set(b::AbstractBridgeOptimizer, attr::MOI.ConstraintName,
blegat marked this conversation as resolved.
Show resolved Hide resolved
# constraint_index::CI, name::String)
# if is_bridged(b, typeof(constraint_index))
# MOI.set(b.bridged, attr, constraint_index, name)
# else
# MOI.set(b.model, attr, constraint_index, name)
# 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