KatInterview

Route Each Order to One of Two Suppliers to Minimize Cost

Machine LearningModel answer
HardModel answerMachine Learningcost-sensitive learningcausal inferenceconstrained optimization

Last updated

Design a constrained decision model that selects a supplier per order to minimize expected total cost while keeping SLA attainment at or above 95% and staying within a monthly budget.

Supplier Routing Under Cost and SLA Constraints

Your company sources inventory through two third-party suppliers, Supplier A and Supplier B. For every incoming order you must pick exactly one. You have historical order-level records with the following fields:

FieldDescription
lead_time_daysActual days from order to delivery
unit_pricePer-unit cost quoted by that supplier
on_time_rateTrailing delivery punctuality rate
defect_rateTrailing fraction of units failing QC
min_order_qtySupplier minimum order quantity
capacitySupplier monthly unit capacity
distance_kmWarehouse-to-destination distance
historical_cancellation_rateFraction of orders the supplier cancelled
late_penalty_per_orderFixed fee charged when SLA is missed
stockout_cost_per_dayCost per day of inventory gap
sla_metWhether the order met the agreed lead-time SLA

Your goal is to design a complete decisioning system. Address each of the following:

  1. Objective and decision rule. Write out the expected-cost formula for routing order i to supplier v, covering price, expected late penalties, expected quality failures, and stockout costs. Then state the constrained optimization problem — one routing per order, SLA attainment ≥ 95% across the month, a hard budget cap, and per-supplier capacity limits. Show how Lagrangian relaxation reduces this to a per-order scoring rule.

  2. Feature engineering and modeling. List features available at decision time, including order-level, supplier-level, and time-varying supplier state features. Recommend a modeling approach for each outcome (lateness probability, lead-time distribution, defect rate, cancellation rate), and justify your choices over alternatives such as a fixed-threshold cost-sensitive classifier, pairwise learning-to-rank, or a contextual bandit. Address class imbalance (SLA misses are rare, around 5%) and non-stationarity in supplier performance.

  3. Selection bias. Historical routing was not random — certain order types were always sent to one supplier. Explain how this causes confounding, how you would estimate and use propensity scores, how you would stabilize inverse-probability weights, and what doubly robust estimation buys you here.

  4. Offline evaluation. Describe a sound evaluation pipeline: how to split time-series data, how to estimate the expected cost and SLA attainment of a candidate policy without deploying it, and how to choose operating-point hyperparameters (the Lagrange multipliers) against a cost–SLA frontier.

  5. Online rollout and operational concerns. Lay out a staged rollout with safety guardrails. Describe how you would handle a new supplier with no history (cold start) and how you would enforce per-supplier capacity limits at serving time. If Supplier A consistently looks cheaper in the model but late penalties are rising in production, walk through the diagnostics you would run.

Hints

Hint 1

Start by separating the problem into three independent layers: outcome prediction, constrained decision-making, and counterfactual evaluation. The modeling choices in each layer are different, and conflating them is the most common mistake.

Hint 2

The stockout cost depends on how much the actual lead time exceeds your inventory buffer — that requires a lead-time *distribution* (e.g., quantile regression or a survival model), not just a mean prediction. Think about what happens to the cost formula if delivery is 3 days late versus 10 days late.

Hint 3

Historical data only shows outcomes for the supplier that was actually chosen. Before you can compare policies, you need to adjust for the fact that hard orders may have been systematically routed to the better supplier — or the worse one. Propensity modeling addresses this, but positivity (overlap) is a hard requirement you must check.