-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add Bridges.Constraint.InequalityToComplementsBridge #2582
Conversation
@mitchphillipson with this PR you will be able to do: julia> using JuMP, PATHSolver
julia> model = Model(PATHSolver.Optimizer);
julia> @variable(model, x >= 0, start = 1.0);
julia> @constraint(model, 2 * x == 1.0)
2 x = 1
julia> optimize!(model)
Path 5.1.99 (Mon Jul 24 14:47:28 2023)
Written by Todd Munson, Steven Dirkse, Youngdae Kim, and Michael Ferris
MCPR: One: 0 Two: 2 Thr: 0 Qua: 0 WBd: 0 Fix: 0 IFx: 0
Major Iterations. . . . 0
Minor Iterations. . . . 0
Restarts. . . . . . . . 0
Crash Iterations. . . . 0
Gradient Steps. . . . . 0
Function Evaluations. . 0
Gradient Evaluations. . 0
Basis Time. . . . . . . 0.000000
Total Time. . . . . . . 0.000167
Residual. . . . . . . . 0.000000e+00
Postsolved residual: 0.0000e+00
julia> value(x)
0.5 |
Co-authored-by: Benoît Legat <benoit.legat@gmail.com>
How does JuMP know that 2x=1 is complimentary to x? Or is this being passed to PATH directly? |
It isn't. This PR adds a bridge which reformulates y = @variable(model)
@constraint(model, 2x - 1 ⟂ y) If no complementarity constraint is set for a variable, it is defined as @constraint(model, 0 ⟂ x) so the full model is equivalent to model = Model(PATHSolver.Optimizer)
@variable(model, x >= 0, start = 1)
@variable(model, y)
@constraint(model, 0 ⟂ x)
@constraint(model, 2x - 1 ⟂ y) |
Closes #2581
Basic
src/Bridges/XXX/bridges
struct must end in
Bridge
MOI.Bridges.Constraint.SetMapBridge
const
that is aSingleBridgeOptimizer
wrapping thenew bridge. The name of the const must be the name of the bridge, less
the
Bridge
suffixinclude
the file insrc/Bridges/XXX/bridges/XXX.jl
add_all_bridges
at the bottom ofsrc/Bridges/XXX/XXX.jl
Tests
tests/Bridges/XXX
MOI.Bridges.runtests
to test various inputs and outputs of thebridge
covered by the tests, add additional bridge-specific tests to cover the
untested lines.
Documentation
Final touch
If the bridge depends on run-time values of other variables and constraints in
the model:
MOI.Utilities.needs_final_touch(::Bridge)
MOI.Utilities.final_touch(::Bridge, ::MOI.ModelLike)
final_touch
can be called multiple times in a row