Skip to content

Ignore SlackBridgePrimalDualStart for non-Slack bridge #2365

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

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/Bridges/Objective/bridges/slack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ end
# Pretend that every model supports, and silently skip in set if unsupported
MOI.supports_fallback(::MOI.ModelLike, ::SlackBridgePrimalDualStart) = true

function MOI.throw_set_error_fallback(
::MOI.ModelLike,
::SlackBridgePrimalDualStart,
::AbstractBridge,
::Nothing,
)
return # Silently ignore for other bridges
end

function MOI.set(
model::MOI.ModelLike,
::SlackBridgePrimalDualStart,
Expand Down
18 changes: 18 additions & 0 deletions test/Bridges/Objective/slack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,24 @@ function test_deletion_of_variable_in_slacked_objective()
return
end

function test_SlackBridgePrimalDualStart_non_slack()
inner = MOI.Utilities.MockOptimizer(
MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()),
)
# Should ignore without erroring
MOI.set(inner, MOI.Bridges.Objective.SlackBridgePrimalDualStart(), nothing)
model = MOI.Bridges.Objective.Functionize{Float64}(inner)
x = MOI.add_variable(model)
MOI.set(model, MOI.ObjectiveFunction{typeof(x)}(), x)
# Should ignore without erroring
MOI.set(
model,
MOI.Bridges.Objective.SlackBridgePrimalDualStart(),
nothing,
)
return
end

function test_SlackBridgePrimalDualStart()
inner = MOI.Utilities.MockOptimizer(
MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()),
Expand Down