Closed ferrolho closed 3 years ago
MWE:
using JuMP, Ipopt
model = Model(Ipopt.Optimizer)
@variable(model, x <= 1)
@NLobjective(model, Max, rad2deg(x))
optimize!(model)
The issue is switchexpr
contains bits like this:
if operator_id <= 52
if operator_id == 51
return 0::T
else
if operator_id == 52
return 0::T
end
end
else
I guess https://github.com/jump-dev/JuMP.jl/blob/1e7cc25fd9b9842a9f4e75bd5154f3ae3667f234/src/_Derivatives/forward.jl#L483 should be
ex = :(return convert(T, $deriv_expr)::T
Maybe add a special case for the derivative expression of rad2deg
? It's unusual that the derivative evaluates to an Int. I'm worried that if we add a convert, it will end up being a MethodError
in some case we haven't thought of yet.
Hi! I think I have found a bug in JuMP.jl. I am facing a
TypeError
if I userad2deg
in a@NLexpression
. I have reproduced this issue using Ipopt.jl and KNITRO.jl. If I write down the conversion myself, the error is not triggered.I stumbled upon this problem in a notebook I have recently created for
JuMPTutorials.jl
, but I will link to a copy of the notebook on a repository of mine since the PR is being reviewed. Here is the notebook.At some point in the notebook, you will find this comment (in a code cell)
and you will see that the lines
are commented, because they trigger the error I am reporting.
If I replace the calls to
rad2deg(x)
with180 * x / π
, the error goes away.Here is the stacktrace when using Ipopt.jl:
And here is the stacktrace when using KNITRO.jl: