How meal scoring works
The meal score is absolute: nutrients fill prorated targets, energy is rewarded toward a calorie target (a tent), optional macronutrient targets use that same tent, and stomach volume is a one-sided capacity hinge. Charts and the playground below import the real engine and your live config from the side panel — change weights, RNI cap, target, macros, or capacity and this page updates.
Component fills are saturating ramps against RNI × (target ÷ daily), except an enabled protein target which swaps that ramp for a tent. Carbohydrate and fat tents are extra terms when those targets are on. The calories weight is the energy-tent weight (clamped ≥ 0). UPF multiplies when ultra-processed foods supply ≥50% of meal energy.
reward = min(amount / target, cap=1)
reward = max(0, 1 − |E − T| / T)
penalty = max(0, V / C − 1)
| x (% of target) | saturating ramp | energy tent | volume hinge |
|---|---|---|---|
| 0% | 0.00 | 0.00 | 0.00 |
| 25% | 0.25 | 0.25 | 0.00 |
| 50% | 0.50 | 0.50 | 0.00 |
| 75% | 0.75 | 0.75 | 0.00 |
| 100% | 1.00 | 1.00 | 0.00 |
| 125% | 1.00 | 0.75 | 0.25 |
| 150% | 1.00 | 0.50 | 0.50 |
| 175% | 1.00 | 0.25 | 0.75 |
| 200% | 1.00 | 0.00 | 1.00 |
User-set macronutrient targets reuse the energy tent. Grams versus % of the meal calorie target is one setting for protein, carbohydrate, and fat together (4 / 4 / 9 kcal per gram). Reward is 1 at the target and 0 at 0 and at 2×.
Loading food composition…
The paper's per-mass NVS remains the context-free “how good is this stuff” ranking. Search results still show it alongside the contextual marginal value.
With no scarce budgets, the tent and hinge vanish and the marginal of 100 g into an empty meal is nutrient density — the current score. Budgets & gaps generalises the density model.
| Constant / mechanism | Status | Why |
|---|---|---|
| ±20% calorie band | removed | the tent's slope replaces the ramp-in band |
| EMR sign flip under target | removed | the tent is naturally two-sided |
| kcal/100 g share attribution | removed | marginal contribution attributes automatically |
| Calorie target + daily energy | shipped | tent peak + RNI prorating |
| Stomach capacity + food densities | shipped | volume hinge kink |
| Macronutrient targets (g or % of meal kcal) | shipped | same tent as energy; optional; protein replaces the RNI ramp |
| RNI cap, weights, UPF/NR | shipped | cap is the saturating ramp; weights apply to meal totals |
Design history: docs/nvs-budgets-and-gaps.html (static prototype). This page is the first-class, engine-backed reference.