EnergyInnovation / eps-us

Energy Policy Simulator - United States
GNU General Public License v3.0
22 stars 7 forks source link

Recalculate BAU case when control levers change #202

Closed jrissman closed 2 years ago

jrissman commented 2 years ago

Unlike policy levers, control levers affect both the BAU case and the Policy case in Vensim. In the web app, the BAU case is frozen, so toggling a control lever changes the policy case but not the BAU case. This is an annoyance for many graph types, but is more serious for wedge diagrams and cost curves, which break. Here's an example of the wedge diagram for the built-in "Example scenario" with the “Use 20-Year GWP Values” control lever enabled:

wedge

The solution is that instead of having a static BAU case, the BAU case is recalculated any time a control setting (but not a policy lever) changes. Some ways that a control lever can change include:

When one of these things happens, the web app should invalidate the BAU scenario in the cache. It should re-run the BAU scenario if it is being displayed or its values are needed for a wedge diagram or cost curve.

Changes to the control lever should never generate the "(unsaved changes)" flag for the BAU scenario. If the BAU scenario is activated, it should only show "(unsaved changes)" if a policy lever has been changed. The idea is that the control levers represent different ways of visualizing the BAU scenario, not meaningful changes to the BAU scenario.

The one wrinkle is identifying which levers are control levers vs. policy levers. Here are three approaches:

I somewhat lean against the first approach because it causes unnecessary model runs and might end up needing to be changed in the future. The latter two approaches both seem good to me. The one based on the header name is simpler.

jrissman commented 2 years ago

Sorry, I meant to put this into the issue tracker for the eps-webapp repo. I accidentally posted it to the eps-us issue tracker. Closing this.