DecCF./ˈdɛk.ɛf/

Use preconditions and run inputs

A precondition is a named reference to a value the model can read. Create it with input, then give it a name in defineModel().

input.decimal, rate, fraction, integer, date, money, and textfile create scalar inputs. A fraction must be between zero and one, and an integer must be whole. Numeric inputs must be finite and can have an explicit numeric domain. input.date() accepts an ISO date or year-month and can be used for timeline starts and schedule dates that are resolved during compilation. input.textfile(defaultText = "") stores a string. In the Calculator, its editor is a local text-file picker; the file contents are supplied to the run as that string. In JavaScript, pass the content directly with deterministic.inputs, just like other scalar overrides. Currency is selected on a run with run(model, { currency }); it does not need to be declared as a model precondition.

Use input.enum() for a fixed choice. Each option has a stable value used by the model and a label shown in Model input:

Give these inputs names in your model's preconditions, or place them as fields inside input.object(), a group, or another input layout. Two enum options appear as a buttonbar; more than two appear as a dropdown. Selecting “Monte Carlo simulation” supplies "monteCarlo" to the model. The field uses ui.label when provided; otherwise it uses the field's name, including when nested in an object.

The integer's domain gives inclusive lower and upper limits. In this example, both 10 and 100000 are allowed. Model input shows those limits, and calculations reject values outside the range or values that are not whole numbers. Saved cases and scenarios keep the selected enum value and integer value.

A curve contains dated points:

Curves use step interpolation by default and also support linear. Read the value at the current period with ctx.get(price), or at an explicit date with ctx.curveAt(price, date).

In the Calculator, each curve appears in its own grouped editor. Add or remove dated points and select the interpolation method. The run result includes the effective curve points so the editor can preserve the model's original series until you change it.

For uncertainty, use input.normal, input.logNormal, input.uniform, or input.triangular. A deterministic run uses a central value: the mean for normal, expected value for log-normal, midpoint for uniform, and mode for triangular. Monte Carlo runs draw values instead.

Inputs are declared in the model. To override them with an inline run configuration, see Run one model with different inputs. In the Calculator, you can also create named input variations after the model's preconditions have been discovered; see Create scenarios in the Calculator.

Use input.object() and input.objectArray() when related values belong together, such as a list of household members. Nested scalar types keep validation and presentation metadata in the declaration. Object arrays render as cards, or as Tabulator tables with {type:"table"}. A connectedSource can make an income or ownership list follow the household members while preserving each person's entered values. See Connect lists across pages and Declare allocations and fund needs.

For larger applications, add pages with input.domain and input.section, tab areas with input.aspect, and titled frames with input.group. These are optional object layouts; existing input declarations keep working. See Organize inputs into pages, tabs and groups.

Next: Work with currency and money.

For alternatives with different fields, declare labeled object variants with a hidden string type. input.Object(variants) selects one; input.objectArray(variants, {type:"manyOfAnyChangeable"}), manyOfAny and anyOf offer changeable, fixed or unique cards. See Offer alternative object inputs for complete model-editor examples and saved-value behavior.