chkwon / Complementarity.jl

provides a modeling interface for mixed complementarity problems (MCP) and math programs with equilibrium problems (MPEC) via JuMP
Other
75 stars 20 forks source link

Upcoming refactoring of JuMP's nonlinear API #66

Open odow opened 2 years ago

odow commented 2 years ago

The upcoming release of JuMP v1.2 will break Complementarity. Read more here: https://discourse.julialang.org/t/ann-upcoming-refactoring-of-jumps-nonlinear-api/83052

The breakage looks pretty minor, and is mostly hacks that were added to delete nonlinear constraints: https://github.com/chkwon/Complementarity.jl/blob/c1afb671907edbfb205300cf0fff46d695c2f4f0/src/mcp.jl#L235-L237

x-ref: https://github.com/jump-dev/JuMP.jl/pull/2955

Please ping me if you have questions.

chkwon commented 2 years ago

Thanks for notifying me. I'll watch the change closely.

odow commented 2 years ago

Instead of deleting the nonlinear constraints, we can just keep track of how many constraints have been added:

+    offset = get(m.ext, :MCP_EXPRESSIONS_ADDED, 0)
+    for i in (offset+1):n
+        JuMP.@NLconstraint(m, mcp_data[p[i]].F == 0)
+    end
+    m.ext[:MCP_EXPRESSIONS_ADDED] = n

But that doesn't get us to v1.2.0, because embedding macros in macros like this: https://github.com/chkwon/Complementarity.jl/blob/1cb30ad2c021c3df3ab115995e05603c8948d47d/src/mpec.jl#L265 is unsafe and leads to scoping errors. I'll have a go at rewriting to use the function form of the API.