1
votes

Either fminbox or the Optim.autodiff function appear to create a vector of type Array{Dual{Float64},1} when I run the code below, since I get the error "fbellmanind has no method matching...Array{Dual{Float64},1}". I've specified the function fbellmanind to accept Array{Any,1} but with no luck. Any ideas?

function fbargsolve(x::Vector)
 fbellmanind(probc,EV,V,Ind,x,V0,VUnemp0,Vnp,Vp,q,obj,assets,EmpState,i)
 fbellmanfirm(probc,poachedwage,minw,x,jfirm1,jfirm0,Ind,i)
 @inbounds for ia in 1:na
  Vnp[ia]=V[ia]
  Indnp[ia]=Ind[ia]
  firmratio[ia]=jfirm1[ia]/jfirmres[ia]
  hhratio[ia]=((Vnp[ia]-VUnemp0[ia])/(Vp[ia]-VUnemp0[ia]))
  end
  Crit_bwr=vnormdiff(firmratio,hhratio,Inf)
  return Crit_bwr
end

f=fbargsolve 
df = Optim.autodiff(f, Float64, na)
x0=vec(bargwage0)
l=vec(max(reswage,minw))
u=vec(poachedwage*ones(na))

sol=fminbox(df,x0,l,u)
1
note that Array{T, 1} !<: Array{Any,1} where T<:Any. - Gnimuc

1 Answers

1
votes

Refer to a very important paragraph from Julia doc

Julia’s type parameters are invariant....

You can follow at least these two possible solutions:

1- Change your function declaration, best is to explicitly use right data type Array{Dual{Float64},1} but if you like a generic way:

Use a parametric data type:

julia> function fbellmanind{T}(::Array{T,1})
  "OK"
end
julia> fbellmanind(["test"])
 "OK"

2- Type cast your arguments

julia> function fbellmanind(::Array{Any,1})
  "OK"
end
julia> fbellmanind(Any["test"])
 "OK"