Skip to content
Astera Technology

Test marginal and whole-band quotation rules

Execute two supplied piecewise tariffs at the exact threshold.

Download complete case notes and answer keys ↓

Set the decision and its input

The fictional tariff uses accounting credits, not a real supplier price. Under marginal pricing, the first ten units cost two credits each and excess units one. Under whole-band pricing, every unit costs one once quantity exceeds ten. Twelve units produce twenty-two and twelve respectively. The rule must be named before comparing totals.

Filled local test worksheet
CaseInput JSON
Base test{"units":12,"rule":"marginal"}
Download editable CSV ↓

Run the supplied comparison

The program evaluates the quoted function rather than guessing from the phrase “volume rate”. At ten units both functions yield twenty. At eleven they diverge to twenty-one and eleven, which gives a useful demonstration case.

Faulty and required outputs
PathOutput JSON
Faulty path{"quotedRule":"marginal","fictionalCredits":12}
Required path{"quotedRule":"marginal","fictionalCredits":22}
Download editable CSV ↓
Complete local Node24.14.1 programme
import assert from 'node:assert/strict';

const run=function run(i,corrected=true){
    if(!Number.isInteger(i.units)||i.units<0||!['marginal','whole-band'].includes(i.rule))return {held:true};
    const marginal=Math.min(i.units,10)*2+Math.max(i.units-10,0);
    const whole=i.units*(i.units>10?1:2);
    return {quotedRule:i.rule,fictionalCredits:corrected?(i.rule==='marginal'?marginal:whole):whole};
  };
const cases=[{"input":{"units":12,"rule":"marginal"},"corrected":false,"expected":{"quotedRule":"marginal","fictionalCredits":12}},{"input":{"units":12,"rule":"marginal"},"corrected":true,"expected":{"quotedRule":"marginal","fictionalCredits":22}},{"input":{"units":10,"rule":"marginal"},"corrected":true,"expected":{"quotedRule":"marginal","fictionalCredits":20}},{"input":{"units":11,"rule":"marginal"},"corrected":true,"expected":{"quotedRule":"marginal","fictionalCredits":21}},{"input":{"units":11,"rule":"whole-band"},"corrected":true,"expected":{"quotedRule":"whole-band","fictionalCredits":11}},{"input":{"units":12,"rule":null},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Download runnable example ↓

Choose from the boundary evidence

A quotation lacking the piecewise rule remains held even if one total happens to agree. The ten-unit match alone cannot distinguish the tariffs.

  1. Read the piecewise function
  2. Run threshold and first excess
  3. Compare using the stated rule

Do not infer a tariff from one coincident total.

Editable boundary inputs and outputs
ConditionInput JSONExpected output JSON
ten-unit tie{"units":10,"rule":"marginal"}{"quotedRule":"marginal","fictionalCredits":20}
first excess unit{"units":11,"rule":"marginal"}{"quotedRule":"marginal","fictionalCredits":21}
whole-band first excess{"units":11,"rule":"whole-band"}{"quotedRule":"whole-band","fictionalCredits":11}
unstated billing rule{"units":12,"rule":null}{"held":true}
Download editable CSV ↓

Does a matching total at ten establish marginal pricing?

Show the worked answer

No. Both yield twenty there. At eleven, marginal gives twenty-one while whole-band gives eleven; obtain the stated rule and retain both tests.

Related resources