Problem Definition - Complete Documentation
This page is a single-reference version of the workbook contract used by the current engine. It is intended to stay aligned with parser behavior in engine/R/01_initialize_data.R and related helpers.
Workbook Overview
Mandatory sheets:
impfosmetacovorgmeta
Optional sheets:
formulas
Optional supporting sheets:
- custom distribution sheets referenced from
imp
Parser load order:
formulasimpcovfosmetaorgmeta
Impact Multipliers - imp
Purpose:
- Defines multiplier names, ranges, distributions, and weight types.
Terminology:
| Term | Meaning |
|---|---|
Impact Differentiator |
The multiplier name defined in this sheet. |
SOW |
State of the World. In implementation terms, this is the sampled multiplier value for a given differentiator and simulation. |
OC |
Organization Characteristic. This is the organization-specific value from the fos sheet for the same differentiator. |
Recognized columns:
| Column | Required | Meaning |
|---|---|---|
Impact Differentiator |
Yes | Multiplier name. Spaces and dots are removed internally. |
Min |
Yes | Lower numeric input used by the distribution. |
Max |
Yes | Upper numeric input used by the distribution. |
Distribution |
Yes | Distribution family. |
Weight Type |
No | Alias for internal Type. |
Category |
No | Optional metadata used by some downstream grouping utilities and plots. |
Supported distributions:
| Distrib name | Description | Min/Max application |
|---|---|---|
normal |
Samples from a normal distribution with mean = (Min + Max) / 2 and sd = (Max - Min) / 4. |
Interpreted as an approximate central 95% range around the mean, not as hard bounds. |
lognormal |
Converts the same midpoint-and-quarter-range interpretation into lognormal parameters, then samples from a lognormal distribution. | Used as rough anchors for the distribution on the original scale, not as literal bounds or exact percentiles. |
uniform |
Samples uniformly between two endpoints. | Used as literal lower and upper bounds. |
custom |
Reads empirical values from a separate sheet named after the normalized Impact Differentiator, then samples from that empirical distribution. |
Used only to filter the empirical values before sampling. |
formula |
Placeholder distribution for multipliers computed from formulas rather than sampled directly. | Not used for formula-based multipliers. |
unity |
Always returns 1. |
Ignored. |
Important behavior:
- For
normalandlognormal,MinandMaxare not literal hard bounds and are not implemented as p5/p95. - If
Min = Maxfor a sampled distribution such asnormal,lognormal, oruniform, the engine treats the multiplier as a constant internally. This does not apply tocustom,formula, orunity. - For
custom,MinandMaxare used only to filter the empirical values before sampling.
Supported weight types:
SOW x OCOC ^ SOWSOW ^ OCTempModifier-CompoundedTempModifier-SingleYearUtilityDeclineParameter
How these types are used:
| Type | Role in the model |
|---|---|
SOW x OC |
Used in the base expected-value calculation. |
OC ^ SOW |
Used in the base expected-value calculation. |
SOW ^ OC |
Used in the base expected-value calculation. |
TempModifier-Compounded |
Applied later when expected values are propagated across years. |
TempModifier-SingleYear |
Applied later as a year-specific adjustment when expected values are propagated across years. |
UtilityDeclineParameter |
Used later in bracket-level utility adjustment for portfolio optimization. |
See Expected Value Computation for a fuller explanation of:
- how
SOW x OC,OC ^ SOW, andSOW ^ OCfeed into base expected values, - how temporal modifiers affect later years, and
- how
UtilityDeclineParameterinteracts with bracket-level utility adjustment.
Defaults and validation:
- Missing weight type defaults to
SOW x OCfor non-temporal rows. - Common aliases such as
OC x SOW,sow*oc,Multiplier, andExponentare normalized to current type labels. - Older templates may still use
Class; the parser recognizes temporal modifier values there and maps them intoWeight Typewith a warning. - If no compounded temporal modifier exists, the engine adds a default
DiscountAllYears = 1. - Duplicate multipliers keep the first row and record an error.
- Multiple compounded temporal modifiers are rejected.
- Multiple utility-decline parameters are rejected.
Organization Characteristics - fos
Purpose:
- Defines organization-specific values for each differentiator.
Recognized structure:
- Metadata columns:
Impact Differentiator, optionalVariable Type, optionalSD, optionalCoV - Organization mean columns:
OrgName - Organization standard-deviation columns:
OrgName_StDevorOrgName_SD
Defaults and inference:
- If organization-specific standard deviation exists, use it.
- Else if row
SDexists, useSD. - Else if row
CoVexists, useCoV * Mean. - Else record an error if a mean exists with no usable standard deviation.
Validation and parser behavior:
- Entire organization columns that are all
NAare dropped. - Spaces and dots are removed from organization and differentiator names.
- Missing organization-by-differentiator combinations are completed later with
NA. Indicatormeans must be0,1, orNA.Indicatormean0is currently converted toNA.- Large mismatch between implied and row-level CoV generates a warning.
- Rows for differentiators that do not exist after multiplier processing are removed later.
Important cross-sheet behavior:
foscan reference formula-generated differentiators.- Final initialization keeps only organizations present in both
fosandorgmeta.
Funding Parameters - meta
Purpose:
- Defines budget, horizon, and optional virtual-organization parameters.
Recognized variables:
BudgetTotal- legacy
Budget BudgetYearlyYearsVirtualOrgsPerYearVirtualOrgsSamplingStrategy
Defaults:
BudgetTotalfalls back toBudget.BudgetYearlydefaults toBudgetTotal.Yearsdefaults to the caller-provideddefault_budget_years.VirtualOrgsPerYeardefaults to0if missing or invalid.VirtualOrgsSamplingStrategydefaults tofit_sampleif missing or invalid.
Accepted sampling strategies:
fit_samplefit_percentilepercentileweighted_fit_sampleweighted_fit_percentileweighted_percentile
Validation:
- After defaulting,
BudgetTotalandBudgetYearlymust exist. BudgetTotalmust be at leastBudgetYearly.
Correlation Matrix - cov
Purpose:
- Defines multiplier correlation, and optionally noise correlation for organizations.
Accepted formats:
Matrix format
- First column named
Impact Multiplier - Remaining columns named by multiplier
- Lower triangle is sufficient
Vertical format
Required columns:
Variable1Variable2Correlation
Optional column:
Typewith valuesMultiplierorNoise
See Noise And Model Coverage for how Type = Noise correlations are used after expected values are computed.
Parser behavior:
- Detects format automatically.
- Matrix labels are normalized by removing spaces and dots.
- Duplicate rows, columns, or variable pairs keep the first occurrence and record an error.
- Missing pairs default to
0. - Symmetry is enforced by mirroring
(A, B)and(B, A). - Unrecognized names are filtered out.
- Noise rows only matter if organization names are available.
Safer authoring convention:
- Prefer explicit diagonal
1s. - Prefer lower-triangle matrix input or explicitly symmetric vertical input.
Organization Funding - orgmeta
Purpose:
- Defines room for funding, diminishing returns, year availability, and model coverage.
Recognized variable families:
Room for fundingDiscountUtility declineUtility multiplierAvailable in yearModel CoverageorModel_Coverage
Important bracket behavior:
- Brackets are assigned by row order within a variable family.
- Square-bracket labels such as
[1]and[2]are helpful for humans but are not the authoritative source of bracket numbering.
From a modeling perspective:
- earlier
Room for fundingbrackets usually represent the first and most attractive dollars you can grant, - later brackets represent additional funding after those earlier opportunities have been filled,
- later brackets often have higher
Discountvalues to reflect diminishing returns, - later brackets may also have lower
Utility multipliervalues if you want to scale down their value directly.
Defaults:
- Missing
Available in year Xentries default to1. - Missing
Model Coveragedefaults to1. - Missing bracketed
Discountdefaults to0. - Missing bracketed
Utility multiplierdefaults to1. - Missing bracketed
Room for fundingdefaults to0.
Validation:
- Availability values outside
[0, 1]are corrected to1.0with a warning. - Availability rows beyond
meta$Yearsare removed with a warning. - If an organization has mismatched counts of non-missing room-for-funding and discount rows, the parser records an error.
- If both
DiscountandUtility multiplierare given for the same organization and bracket, the engine warns and applies both. - Later validation warns when discounts decrease across brackets.
Cross-sheet behavior:
- Spaces and dots are removed from organization names for matching against
fos. - Organizations not present in both
orgmetaandfosare dropped during initialization. Model Coverageis used to add post-EV noise when coverage is below1; see Noise And Model Coverage.
Formulas - formulas
This optional sheet defines derived variables using a small formula language. It is primarily useful when a multiplier or organization characteristic should be computed from other variables rather than sampled directly.
Example formulas:
| Formula | What it does |
|---|---|
CombinedEV = Hedginess * FundingAdditionality |
Creates a derived variable from two existing variables. |
PolicyWeight_{region} = probit(PolicyProbability_{region}) |
Uses placeholders to create one formula per matching region. |
Mixture_{region} = draw_from(BaseCase_{region}, 0.7, Upside_{region}, 0.3) |
Creates a weighted mixture between two variables. |
LognormalEV = lognormal_ev_from_xpR(ValueAtMedian, 0.5, 4) |
Converts a percentile and percentile ratio into an expected value. |
Result{a}{b} = x{a}{b} + z{a} + u{b} |
Example of a valid multi-placeholder formula. |
Accepted structure:
- Only the first column is read.
- Each non-empty row should contain one formula assignment of the form
Name = expression. - Empty rows are ignored.
- Rows beginning with
#are comments. - Additional columns are ignored.
Supported operators:
+-*/^()×is normalized to*÷is normalized to/
Supported functions:
| Function | Purpose |
|---|---|
ln(x) / LN(x) |
Natural logarithm |
exp(x) / EXP(x) |
Exponential function |
sqrt(x) |
Square root |
abs(x) |
Absolute value |
lognormal_ev_from_xpR(x, p, R, cap_p, cap_R) |
Computes a lognormal expected value from a percentile and a percentile ratio |
probit(p, cap_p) |
Inverse standard normal CDF |
draw_from(m1, w1, m2, w2, ...) |
Row-wise stochastic choice between candidate variables |
Notes:
- Function names are case-insensitive where documented.
draw_fromexpects alternatingvalue, weightpairs.cap_pandcap_Rlet you disable default capping behavior.
Custom function details:
lognormal_ev_from_xpR(x, p, R, cap_p = TRUE, cap_R = TRUE)
- Computes the expected value of a lognormal distribution from a known percentile value
x, percentilep, and ratioR = P95 / P05. xmust be positive,pmust be in(0, 1), andRmust be greater than1.- By default,
pis capped to[0.001, 0.999]andRis capped to at least1.001.
probit(p, cap_p = TRUE)
- Returns the inverse standard normal CDF, equivalent to
qnorm(p). - By default,
pis capped to[0.001, 0.999].
draw_from(m1, w1, m2, w2, ...)
- Chooses between candidate variables row by row using alternating
value, weightpairs. - Weights may be scalars or simulation-length vectors.
- Negative weights are capped to
0with a warning.
Placeholder behavior:
- Single-placeholder patterns are expanded against matching available variable names.
- Multiple-placeholder formulas must be unambiguous.
- Ambiguous placeholder patterns are warned about and ignored.
- Later formulas can reference variables created by earlier formulas in the same sheet.
Validation behavior:
- Formulas that cannot expand are ignored with warnings.
- Formulas with unresolved variables after expansion are ignored with warnings.
- Preview validation additionally checks parameters used inside
lognormal_ev_from_xpR,probit, anddraw_from.
Output behavior:
- Formula-defined variables matter only if referenced by later formulas or by
fos. - If
fosreferences a formula-defined variable missing fromimp, the engine can add it automatically. - If a formula-defined variable overrides an existing multiplier name and is used in
fos, the engine marks it asformulaand resets its correlations to0.
Custom Distributions
Important clarification:
- There is no workbook tab literally named
custom_distributions.
Actual pattern:
- In
imp, setDistribution = custom. - Create a separate sheet named after the normalized multiplier name.
- Put numeric values in the first column.
- Optionally filter those values using
MinandMaxfromimp.
Parser behavior:
- Reads the custom sheet using the normalized differentiator name.
- Uses only the first column.
- Coerces values to numeric.
- Drops
NAs. - Applies optional
MinandMaxfiltering. - Samples later from empirical quantiles of the stored values.
Failure mode:
- Missing custom sheets produce parsing errors.
- Empty or unusable custom sheets can break downstream simulation, so examples should always leave at least one valid numeric value after filtering.