EconForge / Dolo.jl

Economic modeling in Julia
Other
57 stars 29 forks source link

Smolyak Grid + Time Iteration gives Method Error #158

Open ShlokG opened 3 years ago

ShlokG commented 3 years ago

Related to issues with reinterpret (#143 ), I get a type error whenever I try to run time iteration with a Smolyak Grid approximation. For example, I take the rbc_iid.jl model in examples and change the Cartesian grid to options: grid: !Smolyak mu: [2,2]

I then run in Julia-1.3.1, model = yaml_import("rbc_iid.jl") Dolo.time_iteration(model) # I get the following error in the time iteration step:

ERROR: MethodError: no method matching (::Dolo.ConstantDecisionRule{3})(::Int64, ::Base.ReinterpretArray{StaticArrays.SArray{Tuple{30},Float64,1,30},1,Float64,Array{Float64,1}}) Closest candidates are: Any(::Int64, ::Union{Array{StaticArrays.SArray{Tuple{d},Float64,1,d},1}, StaticArrays.SArray{Tuple{d},Float64,1,d}}) where d at /home/rcesxg39/.julia/packages/Dolo/d0Rro/src/numeric/decision_rules/core.jl:29 Any(::Int64, ::Int64, ::Union{Array{StaticArrays.SArray{Tuple{d},Float64,1,d},1}, StaticArrays.SArray{Tuple{d},Float64,1,d}}) where d at /home/rcesxg39/.julia/packages/Dolo/d0Rro/src/numeric/decision_rules/core.jl:30

The code suggests that the init_dr(i, endo_nodes) step takes the SArray array but calling nodes for the SmolyakGrid runs (in src/numeric/grid.jl) reinterpret(Point{d}, vec(copy(grid.nodes')))