Functional Weave
Code in Rust

manufacturing.batch-size@1.0.0

vectors.json

3,935 bytes · view raw

[
  { "name": "demand 1000, rate 2000, set-up £5, holding 50p: EBQ is exactly 200 (EOQ would be 141)", "args": [1000, 2000, {"minor": 500, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expect": 200 },
  { "name": "a perfect square stays put when rounding up", "args": [1000, 2000, {"minor": 500, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "up"], "expect": 200 },
  { "name": "demand 10000, rate 40000, set-up £100, holding £2: sqrt(1333333.33) = 1154.70 rounds half-up to 1155", "args": [10000, 40000, {"minor": 10000, "currency": "GBP"}, {"minor": 200, "currency": "GBP"}, "half-up"], "expect": 1155 },
  { "name": "the same rounded down is 1154", "args": [10000, 40000, {"minor": 10000, "currency": "GBP"}, {"minor": 200, "currency": "GBP"}, "down"], "expect": 1154 },
  { "name": "a rate close to demand makes the batch much larger: sqrt(180000) = 424.26", "args": [1200, 1500, {"minor": 4500, "currency": "GBP"}, {"minor": 300, "currency": "GBP"}, "half-up"], "expect": 424 },
  { "name": "the same rounded up is 425", "args": [1200, 1500, {"minor": 4500, "currency": "GBP"}, {"minor": 300, "currency": "GBP"}, "up"], "expect": 425 },
  { "name": "an exact half, sqrt(6.25) = 2.5, rounds half-up to 3", "args": [25, 50, {"minor": 1, "currency": "GBP"}, {"minor": 16, "currency": "GBP"}, "half-up"], "expect": 3 },
  { "name": "an exact half, sqrt(6.25) = 2.5, rounds half-even to 2", "args": [25, 50, {"minor": 1, "currency": "GBP"}, {"minor": 16, "currency": "GBP"}, "half-even"], "expect": 2 },
  { "name": "an exact half, sqrt(12.25) = 3.5, rounds half-even to 4", "args": [49, 98, {"minor": 1, "currency": "GBP"}, {"minor": 16, "currency": "GBP"}, "half-even"], "expect": 4 },
  { "name": "below the half, sqrt(6) = 2.449, rounds half-up to 2", "args": [24, 48, {"minor": 1, "currency": "GBP"}, {"minor": 16, "currency": "GBP"}, "half-up"], "expect": 2 },
  { "name": "zero demand needs no batch", "args": [0, 100, {"minor": 500, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expect": 0 },
  { "name": "a free set-up gives a batch of zero", "args": [1000, 2000, {"minor": 0, "currency": "EUR"}, {"minor": 50, "currency": "EUR"}, "up"], "expect": 0 },
  { "name": "a production rate equal to demand is an error", "args": [1000, 1000, {"minor": 500, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expectError": "annualProductionRate must be a whole number greater than annualDemand" },
  { "name": "a zero holding cost is an error", "args": [1000, 2000, {"minor": 500, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, "half-up"], "expectError": "holdingCost must be greater than zero" },
  { "name": "a negative set-up cost is an error", "args": [1000, 2000, {"minor": -500, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expectError": "setupCost must not be negative" },
  { "name": "negative demand is an error", "args": [-1, 2000, {"minor": 500, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expectError": "annualDemand must be a whole number of units, not negative" },
  { "name": "fractional demand is an error", "args": [10.5, 2000, {"minor": 500, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expectError": "annualDemand must be a whole number of units, not negative" },
  { "name": "mixed currencies are an error", "args": [1000, 2000, {"minor": 500, "currency": "GBP"}, {"minor": 50, "currency": "EUR"}, "half-up"], "expectError": "currency mismatch" },
  { "name": "8DSP beyond 2^63 - 1 is an error", "args": [1000000000, 2000000000, {"minor": 10000000, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "half-up"], "expectError": "8 x D x S x P must stay within 2^63 - 1" },
  { "name": "an unknown rounding mode is an error", "args": [1000, 2000, {"minor": 500, "currency": "GBP"}, {"minor": 50, "currency": "GBP"}, "nearest"], "expectError": "unknown rounding mode" }
]