solve.moq

solve.moq, call function

solve.moq solves MOQ (minimum order quantity) constraints over a grid table and returns a boolean selection. See MOQs and other ordering constraints.

Example

table G = with
  [| as Item, as Qty, as Reward, as Cost, as MOQ |]
  [| "A", 1, 10, 4, 1 |]
  [| "A", 2, 18, 7, 1 |]
  [| "B", 1, 6, 3, 1 |]
  [| "B", 2, 11, 5, 1 |]

G.Buy = solve.moq(
  Item: G.Item,
  Quantity: G.Qty,
  Reward: G.Reward,
  Cost: G.Cost,
  MaxCost: 10,
  GroupId: G.Item,
  GroupQuantity: G.Qty,
  GroupMinQuantity: G.MOQ)

show table "MOQ plan" with
  G.Item
  G.Qty
  G.Buy

This outputs the following table:

Item Qty Buy
A 1 false
A 2 true
B 1 false
B 2 false

Remarks

Provide exactly one of MaxCost, MaxTarget, or MinTarget. Target and TargetGroup are only relevant with a target-based mode. Multiple MOQ constraints can be added by repeating GroupId, GroupQuantity, and GroupMinQuantity arguments (up to eight).

User Contributed Notes
0 notes + add a note