Closed b-han closed 3 years ago
I can reproduce this on JuMP master.
p.s., in future, please cross-reference when you post in multiple places:
https://github.com/JuliaOpt/NLopt.jl/issues/125#issuecomment-456409188
p.s., in future, please cross-reference when you post in multiple places:
Yes - sorry for forgetting that
As I commented in JuliaOpt/NLopt.jl#125, it seems to be a macro hygiene problem in JuMP, because it is not using the caller's scope to resolve the erf
function.
JuMP doesn't work with nonlinear functions by looking them up in the caller's scope; it has a table of recognized symbols. You can add to this table by calling JuMP.register
and providing the proper derivatives.
This is a valid issue because erf
used to work before it was moved into a separate module, but given that this affects 0.18 (so it's not a regression in 0.19) and has a workaround, I'll dispute that this issue should be a blocker for 0.19.
I did a bit of research into transitioning to DiffRules for our built-in derivative rules, which should resolve this issue. It's more complex than I expected, because there's no drop-in replacement for Calculus's symbolic differentiation. JuMP uses symbolic differentiation for second derivatives of built-in univariate functions. Options include:
I'm solving a non-linear optimization problem with JuMP, there is an erf() called in my objective function. My code throws an error saying that the erf() function is not defined.
Since erf() has been moved from Base to SpecialFunctions I have called Pkg.update(), loaded the SpecialFunctions package, and swtiched among different solvers (NLopt, Itopt). Unfortunately none of them works. It occurs to me a bug in JuMP.
Here follows the environment and the minimized code which I tested.