Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jul 19, 2019
1 parent 92f314c commit bd63ad3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/Bridges/bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function MOI.delete(b::AbstractBridgeOptimizer, vi::MOI.VariableIndex)
if is_bridged(b, vi)
MOI.throw_if_not_valid(b, vi)
if Variable.length_of_vector_of_variables(Variable.bridges(b), vi) > 1
if Variable.constrained_set(Variable.bridges(b), vi) <: MOIU.DimensionUpdatableSets
if MOI.supports_dimension_update(Variable.constrained_set(Variable.bridges(b), vi))
MOI.delete(b, bridge(b, vi), _index(b, vi)...)
else
MOIU.throw_delete_variable_in_vov(vi)
Expand Down Expand Up @@ -534,7 +534,7 @@ function MOI.get(b::AbstractBridgeOptimizer, attr::MOI.ConstraintSet,
# The function constant of the bridged function was moved to the set,
# we need to remove it.
if is_bridged(b, ci)
func = MOI.get(b, MOI.ConstraintFunction(), bridge(b, c))
func = MOI.get(b, MOI.ConstraintFunction(), bridge(b, ci))
else
func = MOI.get(b.model, MOI.ConstraintFunction(), ci)
end
Expand Down Expand Up @@ -1007,6 +1007,10 @@ function unbridged_constraint_function(b::AbstractBridgeOptimizer,
end
return f
end
function unbridged_constraint_function(
::AbstractBridgeOptimizer, func::MOI.AbstractVectorFunction)
return func
end


# TODO add transform
4 changes: 2 additions & 2 deletions test/Bridges/Constraint/slack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ config = MOIT.TestConfig()

for T in [Int, Float64], S in [MOI.GreaterThan{T}, MOI.GreaterThan{T}]
for F in [MOI.ScalarAffineFunction{T}, MOI.ScalarQuadraticFunction{T}]
@test MOIB.added_constraint_types(MOIB.Constraint.ScalarSlackBridge{T, F, S}) == [(F, MOI.EqualTo{T}), (MOI.SingleVariable, S)]
@test MOIB.added_constraint_types(MOIB.Constraint.ScalarSlackBridge{T, F, S}) == [(F, MOI.EqualTo{T})]
end
end
end
Expand Down Expand Up @@ -146,7 +146,7 @@ end

for T in [Int, Float64], S in [MOI.Nonnegatives, MOI.Nonpositives]
for F in [MOI.VectorAffineFunction{T}, MOI.VectorQuadraticFunction{T}]
@test MOIB.added_constraint_types(MOIB.Constraint.VectorSlackBridge{T, F, S}) == [(F, MOI.Zeros), (MOI.VectorOfVariables, S)]
@test MOIB.added_constraint_types(MOIB.Constraint.VectorSlackBridge{T, F, S}) == [(F, MOI.Zeros)]
end
end
end
2 changes: 1 addition & 1 deletion test/Bridges/Variable/rsoc_to_psd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bridged_mock = MOIB.Variable.RSOCtoPSD{Float64}(mock)
@test length(v) == 4

message = string("Cannot delete variable as it is constrained with other",
" other variables in a `MOI.VectorOfVariables`.")
" variables in a `MOI.VectorOfVariables`.")
for i in 1:4
err = MOI.DeleteNotAllowed(v[i], message)
@test_throws err MOI.delete(bridged_mock, v[i])
Expand Down

0 comments on commit bd63ad3

Please sign in to comment.