You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the En-ROADS and C-ROADS models, we have a number of equations that are gated by a kind of "feature flag" for things that aren't used in the app but are made available for internal testing and calibration by modelers. The construct usually has the following form:
a = IF THEN ELSE(Choose scenario > 0, Something complex, Something simple) ~~|
Currently there is no way for SDE to optimize these out when the conditional resolves to a constant value, so we end up generating code (and including data) that doesn't actually get used in the actual app.
I found a way to optimize this by adding a simple ExprReader class that determines whether an expression tree resolves to a single constant numeric value, and then for the case where the condition is constant, EquationReader only needs to visit one branch (the other one can be culled by the unused reference elimination code), and EquationGen can generate the single branch instead of the full IF THEN ELSE.
This change decreases the generated WASM binary for En-ROADS by ~25%, and makes the model run ~10% faster.
The text was updated successfully, but these errors were encountered:
In the En-ROADS and C-ROADS models, we have a number of equations that are gated by a kind of "feature flag" for things that aren't used in the app but are made available for internal testing and calibration by modelers. The construct usually has the following form:
Currently there is no way for SDE to optimize these out when the conditional resolves to a constant value, so we end up generating code (and including data) that doesn't actually get used in the actual app.
I found a way to optimize this by adding a simple
ExprReader
class that determines whether an expression tree resolves to a single constant numeric value, and then for the case where the condition is constant,EquationReader
only needs to visit one branch (the other one can be culled by the unused reference elimination code), andEquationGen
can generate the single branch instead of the fullIF THEN ELSE
.This change decreases the generated WASM binary for En-ROADS by ~25%, and makes the model run ~10% faster.
The text was updated successfully, but these errors were encountered: