I changed neteconomy and emissions components.
Firstly, I use replace!(m, :neteconomy=>neteconomy, reconnect=true) to replace the neteconomy component.
Secondly, I use connect_param!(m, :neteconomy, :E, :emissions, :E) to connect parameter E in neteconomy component and variable E in emissions component.
However, I changed equations of variable E in emissions component and I may repalce it after that.
Here is my question, will the declaration order influence the result? The parameter E will follow the old or new equation in emissions component?
BTW, can I view the values of the parameter without running the model? I want to know whether I match all the new parameters successfully and I think it may be of great help for my debugging afterwards.
ERROR: MissingException: Cannot get index; data is missing. You may have tried to access a value in timestep 1 that has not yet been computed.
I’ve already found the missing index. However, I have given the value by using connect!param to connect with a variable in the other component (which I didn’t change).
If I’m understanding the question correctly, no, the declaration order will not influence the result. The parameter E in neteconomy will take the outputs from the variable E in the emissions component, whatever that is. So if you replace emissions, then it will connect to that new component.
For a Parameter like the one you list above, the E Parameter of the neteconomy component which is pulling values from the E Variable of the emissions component, you cannot access the values because they are not computed until the model is run.
This is a bit difficult to diagnose without any code, but some ideas are
make sure that if you’ve added any components you’ve added them in the appropriate order, you can use before and after keyword arguments in add_comp! to specify this
println statements can help figure out where missing data is, for example if you suspect it is paramteter my_param you can try to print out println(p.my_param[t] and see if it comes out as missing – though It sounds like you already think you’ve found the culprit
Incrementally remove some modifications until you isolate what’s going on
There sometimes have to be caveats for the first tilmestep, if the connected component does not compute a value in the first year. For example, using your components from above if you look at the original neteconomy component there are a few places that look like:
for r in d.regions
if is_first(t)
v.YNET[t,r] = p.YGROSS[t,r]/(1+p.DAMFRAC[t,r])
else
v.YNET[t,r] = p.YGROSS[t,r] - p.DAMAGES[t,r]
end
end
which could indicate that p.DAMFRAC[t,r] is missing in the first tilmestep, though I’d need to take a closer look at the MimiRICE model.
These missing errors can be frustrating, and generally have to do with the flow of data through the model and where you might not have computed data before passing it through. Some more code might allow me to be more helpful here.
Hi @emilywen2001 great I’m so glad the missing error was solved quickly, those can be frustrating, it often helps me to talk through it with someone because data flow can be confusing so I’m glad the component order solved it – that’s the easiest one to fix!
I know it’s a lot to learn, I’m still learning myself, but yes understanding the structure definitely helps debug problems.
In terms of new Parameters, is the question that you want to basically update a parameter with something like
and then double check that the values are correctly entered into the model? It is a little bit tricky to access Parameter values before the model is run due to the order of how it is built and filled out, but It think it is possible with some under-the-hood functions if that’s what you’re hoping to do?