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

Upcoming refactoring of JuMP's nonlinear API #66

Open
odow opened this issue Jun 20, 2022 · 2 comments
Open

Upcoming refactoring of JuMP's nonlinear API #66

odow opened this issue Jun 20, 2022 · 2 comments

Comments

@odow
Copy link
Contributor

odow commented Jun 20, 2022

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:

# Cleanup. Remove all dummy @NLconstraints added,
# so that the model can be re-used for multiple runs
m.nlp_data.nlconstr = []

x-ref: jump-dev/JuMP.jl#2955

Please ping me if you have questions.

@chkwon
Copy link
Owner

chkwon commented Jun 27, 2022

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

@odow
Copy link
Contributor Author

odow commented Jul 3, 2022

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:

@NLconstraint( $(m), $(esc_variable(func)) >= $(lb_F) )

is unsafe and leads to scoping errors. I'll have a go at rewriting to use the function form of the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants