I’d like to let everyone know about an upcoming breaking change in how JuMP deals with user-defined functions. Previously, functions registered using
JuMP.register were global in scope, making them complicated to deal with in a modular way. Since PR #930,
JuMP.register now takes a JuMP model as the first argument, and the registration of the function will remain local to that model.
mysquare(x) = x^2 JuMP.register(:mysquare, 1, mysquare, autodiff=true) m = Model() @variable(m, x) @NLobjective(m, Min, mysquare(x))
mysquare(x) = x^2 m = Model() JuMP.register(m, :mysquare, 1, mysquare, autodiff=true) @variable(m, x) @NLobjective(m, Min, mysquare(x))
JuMP.register without a model as the first argument will produce an error. My intention is to release this relatively soon (<1 month) in JuMP 0.16. Feedback and bug reports are welcome as always.