Hey Lisa,
I made the replacement and have some questions:
- Should the name of the new component have to be the same as the one you are replacing (it doesn’t appear to make a difference neither throws errors)?
eg:
replace_comp!(m_fund, impactsealevelrise, :impactsealevelrise, reconnect = true )
vs.
replace_comp!(m_fund, impactslrparameter, :impactsealevelrise, reconnect = true )
- I get an error when I try to evaluate the model using the new component. Thoughts or suggestions would be much appreciated. The full stacktrace is below:
MethodError: no method matching getindex(::Float64, ::Mimi.FixedTimestep{1950,1,3000}, ::Int64)
Closest candidates are:
getindex(::Number, !Matched::Integer…) at number.jl:82
getindex(::Number) at number.jl:75
getindex(::Number, !Matched::Integer) at number.jl:77
…
Stacktrace:
[1] macro expansion at .\In[90]:182 [inlined]
[2]run_timestep_impactsealevelrise(::Mimi.ComponentInstanceParameters{NamedTuple{(:incdens, :emcst, :immcst, :dvydl, :wvel, :wvbm, :slrwvpopdens0, :wvpdl, :wvsl, :dvbm, :slrwvypc0, :protpar, :pc, :slrprtp, :wmbm, :dlbm, :drylandlossparam, :wlbm, :coastpd, :wetmax, :wetland90, :maxlandloss, :sea, :migrate, :income, :population, :area),Tuple{Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},1},Array{Float64,2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2}}}}, ::Mimi.ComponentInstanceVariables{NamedTuple{(:wetval, :wetlandloss, :cumwetlandloss, :wetlandgrowth, :wetcost, :dryval, :landloss, :cumlandloss, :drycost, :npprotcost, :npwetcost, :npdrycost, :protlev, :protcost, :enter, :leave, :entercost, :leavecost, :imigrate),Tuple{Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Array{Float64,2}}}}, ::Mimi.DimDict, ::Mimi.FixedTimestep{1950,1,3000}) at C:\Users\sturner.julia\packages\Mimi\ULzD7\src\core\defcomp.jl:68
[3] run_timestep(::Mimi.ComponentInstance{Mimi.ComponentInstanceVariables{NamedTuple{(:wetval, :wetlandloss, :cumwetlandloss, :wetlandgrowth, :wetcost, :dryval, :landloss, :cumlandloss, :drycost, :npprotcost, :npwetcost, :npdrycost, :protlev, :protcost, :enter, :leave, :entercost, :leavecost, :imigrate),Tuple{Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Array{Float64,2}}}},Mimi.ComponentInstanceParameters{NamedTuple{(:incdens, :emcst, :immcst, :dvydl, :wvel, :wvbm, :slrwvpopdens0, :wvpdl, :wvsl, :dvbm, :slrwvypc0, :protpar, :pc, :slrprtp, :wmbm, :dlbm, :drylandlossparam, :wlbm, :coastpd, :wetmax, :wetland90, :maxlandloss, :sea, :migrate, :income, :population, :area),Tuple{Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},1},Array{Float64,2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},2}}}}}, ::Mimi.Clock{Mimi.FixedTimestep}) at C:\Users\sturner.julia\packages\Mimi\ULzD7\src\core\instances.jl:264
[4] _run_components(::Mimi.ModelInstance, ::Mimi.Clock{Mimi.FixedTimestep}, ::Array{Int64,1}, ::Array{Int64,1}, ::Array{Mimi.Clock{Mimi.FixedTimestep},1}) at C:\Users\sturner.julia\packages\Mimi\ULzD7\src\core\instances.jl:277
[5] run(::Mimi.ModelInstance, ::Int64, ::Nothing) at C:\Users\sturner.julia\packages\Mimi\ULzD7\src\core\instances.jl:313
[6] #run#114(::Int64, ::Nothing, ::Function, ::Mimi.Model) at C:\Users\sturner.julia\packages\Mimi\ULzD7\src\core\model.jl:399
[7] run at C:\Users\sturner.julia\packages\Mimi\ULzD7\src\core\model.jl:390 [inlined]
[8] #our_model#30(::Float64, ::Float64, ::Float64, ::Float64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Float64, ::Float64, ::Float64, ::Int64, ::Nothing, ::Nothing, ::Nothing, ::Float64, ::typeof(our_model)) at .\In[91]:81
[9] (::getfield(Main, Symbol("#kw##our_model")))(::NamedTuple{(:carbon_tax_start, :carbon_tax_end, :prtp, :start_year, :end_year, :nt_impact, :wregion, :gini_year),Tuple{Float64,Float64,Float64,Int64,Int64,Int64,Int64,Int64}}, ::typeof(our_model)) at .\none:0
[10] top-level scope at In[92]:1