What-if parameters
Sliders on the parameters a design is sized for. As one moves, every number that reads it is worked out again, and a card puts the scenario beside the baseline. It does the job of the anfra What if: pricing app.
archec new my-app --kind data-app --template what-if-parameters
archec ui preview my-app/main.arche --serve
What it shows#
- Four tiles: the heating energy, its cost, the peak heater power, the coldest hour.
- Three sliders, one per
parameter: the setpoint, the heat loss of a zone, the energy price.↺puts one back to its written value. - Baseline and scenario: each metric at the parameters' written values, at
their values now, and the change. Name a scenario and save it; a saved one
is a button that sets the sliders again,
⤓saves them all as a file. - The cost by zone, and the peak power a day against
REQ-HEATER.
How it works#
A metric may name a parameter of the project as a number:
parameter SETPOINT "Heating setpoint" { value 20; unit degC; range 16...26; step 0.5 }
metric energy "Heating energy" = LOSS * (SETPOINT - mean(outside)) * count() unit kWh in Climate
slider setpoint "Setpoint" { param SETPOINT } moves it between the ends of
its range. The page works the metrics out again on the same rows; nothing is
simulated again. scenarios plan "…" { columns energy, cost, peak } compares
them.
The data#
data/climate.csv: an hour a row for two weeks, in three zones:at,zone, theoutsideandinsidetemperatures. A cold spell sits in the middle.
Limits#
- The formulas are of aggregates:
mean(outside)over the rows, not a sum hour by hour. A model whose behaviour needs a new run gets its rows fromarchec simor a study, then reads them here. - The saved scenarios stay in the browser that saved them, until
⤓writes them to a file.
The model is lib/data-apps/what-if-parameters/main.arche, and the gallery lists
the other templates.