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

error when JuMP tries autodiff User-defined Function #1998

Closed
KestutisMa opened this issue Jun 24, 2019 · 2 comments
Closed

error when JuMP tries autodiff User-defined Function #1998

KestutisMa opened this issue Jun 24, 2019 · 2 comments

Comments

@KestutisMa
Copy link

KestutisMa commented Jun 24, 2019

Hello, I am trying to optimize User-defined function and I got this error:

ERROR: LoadError: MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{getfield(JuMP, Symbol("##84#86")){typeof(min_f)},Float64},Float64,11})
Closest candidates are:
  Float64(::Real, ::RoundingMode) where T<:AbstractFloat at rounding.jl:194
  Float64(::T<:Number) where T<:Number at boot.jl:741
  Float64(::Int8) at float.jl:60
  ...
Stacktrace:
 [1] convert(::Type{Float64}, ::ForwardDiff.Dual{ForwardDiff.Tag{getfield(JuMP, Symbol("##84#86")){typeof(min_f)},Float64},Float64,11}) at ./number.jl:7
 [2] setindex! at ./array.jl:769 [inlined]
 [3] MC36SM_Mindaugo_SS(::Float64, ::NTuple{32,ForwardDiff.Dual{ForwardDiff.Tag{getfield(JuMP, Symbol("##84#86")){typeof(min_f)},Float64},Float64,11}}, ::Array{Float64,1}, ::Float64, ::Float64) at /home/kest/Projects/gjJulia/testMC36SM.jl:90

Looks like that it is because of trying to do (in User-defined function for JuMP):

g = zeros(36, 4);
.....
g[.....,.....] = Go[1]

g type is 2D Array of Float64, but Go[1] (optimization variable) passed by JuMP autodiff type is:

Dual{ForwardDiff.Tag{getfield(JuMP, Symbol("##84#86")){typeof(min_f)},Float64}}(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0)

Any ideas how to solve such type mismatch?

@mlubin
Copy link
Member

mlubin commented Jun 25, 2019

This was answered at https://discourse.julialang.org/t/dual-forwarddiff-type-error-when-jump-tries-autodiff-user-defined-function/25639/2. In the future, please cross-link when double posting a question.

@mlubin mlubin closed this as completed Jun 25, 2019
@KestutisMa
Copy link
Author

Ok.

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

No branches or pull requests

2 participants