Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/Bridges/bridgeoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ function MOI.empty!(b::AbstractBridgeOptimizer)
empty!(b.bridges)
empty!(b.constraint_types)
empty!(b.single_variable_constraints)
empty!(b.con_to_name)
b.name_to_con = nothing
end
function MOI.supports(b::AbstractBridgeOptimizer,
attr::Union{MOI.AbstractModelAttribute,
Expand Down Expand Up @@ -146,6 +148,10 @@ function MOI.delete(b::AbstractBridgeOptimizer, ci::CI)
end
MOI.delete(b, bridge(b, ci))
_remove_bridge(b, ci)
b.name_to_con = nothing
if haskey(b.con_to_name, ci)
delete!(b.con_to_name, ci)
end
else
MOI.delete(b.model, ci)
end
Expand Down Expand Up @@ -379,6 +385,9 @@ function MOI.get(b::AbstractBridgeOptimizer, IdxT::Type{<:MOI.ConstraintIndex},
if ci == CI{Nothing, Nothing}(-1)
error("Multiple constraints have the name $name.")
elseif ci isa IdxT
if MOI.get(b.model, CI, name) !== nothing
error("Multiple constraints have the name $name.")
end
return ci
else
return nothing
Expand Down
4 changes: 3 additions & 1 deletion test/Bridges/bridgeoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct UnknownConstraintAttribute <: MOI.AbstractConstraintAttribute end
MOI.is_set_by_optimize(::UnknownConstraintAttribute) = true

mock = MOIU.MockOptimizer(SimpleModel{Float64}())
bridged_mock = MOIB.SplitInterval{Float64}(mock)
bridged_mock = MOIB.LessToGreater{Float64}(MOIB.SplitInterval{Float64}(mock))

@testset "Unsupported constraint attribute" begin
attr = UnknownConstraintAttribute()
Expand Down Expand Up @@ -50,6 +50,8 @@ MOI.empty!(bridged_mock)

@testset "Name test" begin
MOIT.nametest(bridged_mock)
# Test that names are deleted in `MOI.empty!`
MOIT.nametest(bridged_mock)
end

@testset "Copy test" begin
Expand Down