Runtime bug with DeficitParameter - #725
Conversation
…with missing parameter index in state
|
I've had a quick look at this. I think there's a wider issue with the changes brought in #599. I.e. what happens if you use an aggregated parameter on parameters that only return a value in "after". The I think the actual issue is that the pywr-next/pywr-core/src/state/mod.rs Line 261 in bdb1fb5 Vec::get. Therefore, the code path can no longer distinguish between a missing state entry (which should not happen) and an explicit None returned from before. That probably needs fixing such that the former is an error.
Then the logic in any parameters consuming others needs updating somehow. The metric API requires a The reason for not making the deficit a |
|
I have addressed this problem in #745. Would you mind having a look at that and see if it works for your case? |
If one defines a parameter as:
The model panics at the first time step with:
I originally implemented the deficit metric in the output node via the
DeficitParameter, but apparently it is not properly registered in the state. The new implementation moves the logic from the parameter to a newMetricF64metric and removeDeficitParameterconsidering that the parameter was not public in the schema and this approach is consistent with how other metrics are defined.