Your exact subset-DP route planner tops out near 20 stops, but dispatch now needs 35 — how do you decide what replaces it?
answer
- the ceiling is memory, and it is exponential
- a factor of 2^15 is not a tuning problem
- what is one percent of route cost worth
- who maintains the clever solver at 3am
- keep the exact one as a yardstick
basics
~20 sSubset DP's ceiling is exponential memory, so no tuning reaches 35 stops — the method must change. The real decision is what the last few percent of route quality is worth against a planner the team can operate and maintain.
solid answer
~50 sFirst close the door on the wrong option: going from 20 to 35 stops is a factor of 2^15 in states, so narrower entries, layering and pruning — all constant factors — cannot get there. That reframes the question from optimisation to method selection. Three realistic paths: **decompose** (cluster stops geographically and run the exact DP inside each cluster, ordering clusters separately), **switch exact method** (branch-and-bound with strong lower bounds routinely solves far larger routing instances, at the price of unpredictable runtime), or **accept a gap** (a constructive heuristic plus local improvement, measured against a known optimality gap). I decide on three inputs: the latency budget per dispatch, what a percent of route cost is worth at fleet scale, and who maintains the result at 3am. And I keep the exact DP as a test oracle bounding the heuristic's gap on small instances.
go deeper
Take away the shape of the limit: exact subset methods are for small inputs, and beyond roughly twenty items real systems use approximate methods. You are not expected to make this call yet.
Be able to show the arithmetic that rules out the exact method at this size, and name at least one approximate alternative and what it gives up in exchange for predictable runtime.
Demonstrate the engineering path: decompose or fall back by instance size, measure the gap against the exact method on small cases, and design for a latency budget rather than for best-case quality.
Own the tradeoff end to end — the economic value of route quality, worst-case latency, maintenance burden and who can operate the result — and write down the reversal criteria so the decision can be revisited with evidence.
## Why this is a judgment call and not a debugging task A planner that handles 20 stops and is asked for 35 is not slow; it is in the wrong complexity class for the requirement. The state count of a subset route DP is 2^n·n: about 2 × 10^7 at n = 20 and about 1.2 × 10^12 at n = 35. That is a factor of roughly 60,000 in memory alone. Every optimisation available inside the method — two-byte cost entries, keeping only two layers of the table live, pruning masks forbidden by time windows, fixing the start to kill rotational symmetry — buys constant factors that together are worth two or three extra stops. Saying this out loud early is most of the answer, because it stops the team from spending a quarter on a rewrite that cannot succeed. ## The three real options **Decompose the instance.** Cluster the stops so that each cluster is small enough for the exact method, solve each exactly, and stitch the clusters together with a cheaper ordering pass. This preserves the code you already trust, keeps a meaningful optimality guarantee *within* each cluster, and fails gracefully — a bad clustering costs route quality, not correctness. It is usually the lowest-risk move when geography is naturally clumpy, which for delivery work it generally is. **Change exact method.** Branch-and-bound with good lower bounds, or a mature solver driven by cutting planes, solves routing instances far beyond what a subset DP can hold, because it never materialises the whole state space. The catch is runtime variance: the same solver that finishes in 40 ms on Tuesday's stops may take minutes on Thursday's. If dispatch has a hard latency budget, you need an anytime formulation — best solution so far, returned when the clock expires — and the operational discipline to monitor that. **Accept an optimality gap.** A constructive pass plus local improvement gets within a small percentage of optimal on realistic instances, in predictable milliseconds, in code a normal engineer can read. For most delivery businesses this is the right answer, and the argument for it is economic rather than algorithmic. ## The inputs that actually decide it - **Latency budget.** If a dispatcher waits for the route, a method with unbounded tail latency is disqualified regardless of solution quality. Predictability often outranks optimality. - **The value of a percent.** Compute it: percent of route cost × routes per day × fleet size. If three percent of driving time is worth a meaningful sum annually, an exact-ish method earns its complexity. If it is worth less than an engineer's salary, it does not. - **Maintenance and staffing.** A hand-tuned solver is one person's expertise. A heuristic with a clear structure is the whole team's. Ask who debugs a bad route at 3am on a public holiday, and whether that person can explain why the planner chose it — explainability matters to dispatchers who override the machine. - **Input shape stability.** If 35 is really "usually 12, occasionally 35", a hybrid is legitimate: run the exact DP when the instance is small and fall back above a threshold. That threshold becomes a tuned, monitored parameter, not a constant someone guessed. ## What to do with the code you already have Do not delete the exact DP. It becomes the **oracle**: on randomly generated instances of 10–16 stops it produces the true optimum, and a test can assert that the heuristic stays within an agreed percentage of it. That converts "the new planner seems fine" into a measured, regression-tested bound, and it is by far the cheapest quality guarantee available once you have accepted an approximate method. It is also the argument that makes the switch defensible to a sceptical stakeholder: you can quote the gap rather than promise it. ## How to present the decision Write the options with their costs, not their elegance: expected route-cost delta, worst-case latency, engineer-weeks to build, and who can maintain each. Recommend one. Name the reversal condition — for instance, "if measured gap exceeds four percent, or instances shrink below 20 stops after the new depot opens, we revisit." A principal-level answer is not the cleverest algorithm; it is a decision someone else can inherit, with the evidence attached and the exit criteria written down. ## The failure modes to avoid Rewriting the same DP in a faster style and hoping; treating an exponential wall as a hardware purchase; adopting a heuristic without ever measuring its gap; and building a bespoke exact solver whose only maintainer then changes teams. Each of those is a decision that looked technical and was actually organisational.
- How do you make the case to a stakeholder who wants the guaranteed optimum?Quantify both sides. Show the memory arithmetic that makes exact-at-35 impossible on the given hardware, then show a measured optimality gap from the oracle tests — for example, within two percent on a hundred sampled days. The conversation stops being 'optimal versus not' and becomes 'two percent of driving time versus a planner that answers in 50 ms every time'.
- When would you keep the exact method in production despite the ceiling?When instances are usually small and the tail is rare: run exact below a threshold, fall back above it. That gives true optima on the common case and bounded behaviour on the rest. Make the threshold a monitored configuration value with an alert on how often the fallback fires, so the day the instance distribution shifts is a signal rather than a surprise.
- What would make decomposition the wrong choice?Stops that are geographically interleaved rather than clumpy, or constraints that cross cluster boundaries — shared capacity, time windows that force one vehicle to interleave two areas. Then the clustering itself destroys most of the achievable quality, and you are paying the complexity of two stages for a worse route than a single global heuristic would produce.
saying these in an interview costs you the question
- Proposes rewriting the same exponential DP more efficiently
- Thinks a bigger machine or more threads clears the ceiling
- Adopts a heuristic without ever measuring the optimality gap
- Ignores worst-case latency when the dispatcher is waiting
- Deletes the exact solver instead of keeping it as an oracle
- Argues purely on algorithmic elegance, never on cost or staffing