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

[Bridges] add ComplementsToScalarNonlinearFunctionBridge #2591

Closed
wants to merge 3 commits into from

Conversation

odow
Copy link
Member

@odow odow commented Dec 12, 2024

Closes #2589

This would be a replacement for Complementarity.jl (cc @chkwon). It's not a perfect replacement because there's no flexibility in how we reformulate, but it's good enough for basic stuff:

julia> using JuMP, Ipopt

julia> begin
           model = Model(Ipopt.Optimizer)
           set_silent(model)
           @variable(model, x)
           @variable(model, z)
           @variable(model, w >= 0)
           @objective(model, Min, (x - 3.5)^2 + (z + 4)^2)
           @constraint(model, z - 3 + 2*z*w == 0)
           @constraint(model, -(z^2 - x)   w)
           optimize!(model)
           solution_summary(model)
       end
* Solver : Ipopt

* Status
  Result count       : 1
  Termination status : LOCALLY_SOLVED
  Message from the solver:
  "Solve_Succeeded"

* Candidate solution (result #1)
  Primal status      : FEASIBLE_POINT
  Dual status        : FEASIBLE_POINT
  Objective value    : 2.82500e+01

* Work counters
  Solve time (sec)   : 8.78320e-02
  Barrier iterations : 303

Current reformulation is really just a proof of concept to check things work. Numerically, we might be better off doing this reformulation though. It just required more lines of code so I didn't do it to begin with.

y - F == 0  # G-in-EqualTo
if isfinite(l)
    (x - l) * y <= 0.0  # ScalarQuadratic-in-LessThan
else
    y <= 0.0  # VariableIndex-in-LessThan
end
if isfinite(u)
    (x - u) * y <= 0.0  # ScalarQuadratic-in-LessThan
else
    y >= 0.0.  # VariableIndex-in-GreaterThan
end

@odow odow closed this Dec 20, 2024
@odow
Copy link
Member Author

odow commented Dec 20, 2024

Add as a package, not a bridge

@odow odow deleted the od/ComplementsBridge branch December 20, 2024 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Bridge from complement to nonlinear
1 participant