This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.
WHATIF_PACKAGE
const WHATIF_PACKAGE: IEnginePackage;Defined in: packages/engine/src/packages/whatif/WhatIfPackage.ts:47
What-if and sweeps, re-running a line with different inputs (GitHub issue #505).
line 4 with deposit = 150000 reads as “what line 4 would say if deposit
were 150000”, and line 4 for rate from 3% to 6% step 1% as “line 4’s
answer for each of those rates”. Neither edits the note. Both re-run every
line from the top of the document to the target, from its text, in a
scratch engine with the input held fixed, so the input reaches the target
through every line between (see LineExecutionContext.rerunLines).
Grammar and work live apart, the split every package here uses:
whatIfNormalizerRulefusesline N withintoWHAT_IFwhen a<name> =follows, andsweepNormalizerRulefusesline N for <name> fromintoSWEEPand the sweep’sstepintoSWEEP_STEP. Neitherwith,fornorstepbecomes a keyword anywhere else.WhatIfParseletandSweepParseletread the rest and emit the plugin calls.WhatIfPluginFunctionsdoes the work, including the sweep’s step and work limits.
Named scenarios (#744) are a what-if with a name kept in the note:
scenario bull with growth = 8% declares one, and line 5 under bull reads
line 5 with its inputs, through the same re-run.
Registered after LINES_PACKAGE, whose rule mints the LINE_REF both of
this package’s rules read.