Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Optimisation problems such as routing, scheduling and pricing often start as clever in-house algorithms written by one engineer. Years later nobody can maintain them. How do you decide between in-house algorithms, commercial or open source solvers, and simpler heuristics?

I decide from the business value of optimality and the cost of ownership. If a few percent better routes or schedules are worth millions, a proven solver such as OR-Tools or a commercial MIP solver usually beats clever in-house code, at the cost of licences and modelling skill. If the value is small, a simple heuristic whose gap to optimal we have measured on real data is easier to explain and maintain. Whatever we choose, we remove key-person risk with documentation, tests against known optimal cases and at least two maintainers, and we revisit the choice periodically as data and solvers change.

Why this question is asked

Optimisation code has a predictable life. A talented engineer writes a custom algorithm that beats the old manual process, it becomes critical, the engineer moves on, and the code turns into a black box that nobody dares to change, while the business keeps asking for new constraints. Interviewers ask senior leaders this question to see whether they can make a build-or-buy decision for algorithms on evidence rather than taste, and whether they think about the people side, maintenance and knowledge, as much as the maths. In this answer, we will look at how to put a value on optimality, compare the three options, measure heuristics properly, manage key-person risk, and set a review rhythm, using a delivery routing system as the running example.

1Quantifying the Value of Optimality

The first question is not technical: how much is a better answer worth? Take a company that runs 2,000 delivery vans, each costing about 150 dollars a day in fuel, wages and wear. Total route cost is about 300,000 dollars a day, roughly 110 million a year. If a better optimiser shortens routes by 3 percent, that is over 3 million dollars a year, which easily pays for a commercial solver licence and a small operations research team. Now take an internal meeting room scheduler where a 3 percent better schedule saves nobody anything measurable. There, the simplest maintainable heuristic is the right answer.

So we estimate the value with the business: the cost driven by the decision, the plausible improvement from better optimisation, and the cost of being wrong or late. This turns a debate about elegance into a decision about money and risk.

2Comparing the Three Options

In-house algorithms, such as a custom dynamic program or local search written for our exact problem, can be very fast and fit our constraints precisely. Their cost is that all the knowledge lives with us, and every new business rule means changing tricky code.

Solvers, such as Google OR-Tools, which is open source, or commercial mixed integer programming solvers such as Gurobi or CPLEX, separate the model, a declarative description of variables, constraints and objective, from the search, which decades of research have made very good. Adding a constraint is often a few lines in the model. They come with documentation, communities or vendor support, and optimality gaps that tell us how far an answer may be from the best. The costs are licence fees for commercial ones, the modelling skill needed to express the problem well, and solve times that can be unpredictable on hard instances, so we always set time limits.

Heuristics, simple rules such as nearest-neighbour routing or earliest-deadline-first scheduling, are easy to explain to operations staff, quick to run and easy to maintain. They give up some quality, and the key is to know how much.

In-house, solver or heuristic
OptionStrengthCost or risk
In-house custom algorithmfits our exact problem, can be very fastkey-person risk, hard to extend
Open source solver (OR-Tools)proven search, free, model is readablemodelling skill, variable solve times
Commercial MIP solverbest performance, vendor supportlicence cost, vendor dependency
Simple heuristicexplainable, cheap, easy to maintaingap to optimal must be measured

3Measuring a Heuristic's Gap to Optimal

A heuristic is only acceptable if we know its cost. We take a representative set of real historical instances, for example 200 days of delivery data, solve them with a solver given a generous time limit to get optimal or near-optimal answers with a known bound, and run the heuristic on the same instances. The result is a distribution: the heuristic might be within 2 percent of optimal on median days and 7 percent on the worst days. Multiplied by the cost figures from the first step, that tells us exactly what the simpler choice costs, in dollars per year.

This benchmark set becomes a permanent asset. Every future change, to the heuristic, the solver model, or a new in-house algorithm, is run against it, so we always compare options on the same evidence.

4Removing Key-Person Risk

Whatever we choose, the system must not depend on one person. For the delivery example, I would require written documentation of the problem itself, the objective, every constraint and why it exists, separate from the code, because the problem description outlives any implementation. I would require a test suite with small instances whose optimal answers are known, solved by hand or by brute force, plus the benchmark set with expected quality thresholds, so a change that breaks optimality fails the build. And I would require at least two engineers who can change and deploy it, building the second through pairing on real changes, not just reading.

For an existing black-box algorithm, the first step is the same: write the tests that capture its current behaviour on real inputs, then document it, and only then consider replacing it.

Step throughChoosing an approach for an optimisation problem
  1. Estimate the yearly value of a few percent betterwith the business
  2. Is the value large?
    YesModel it with a solver firstNoStart with a simple heuristic
  3. Measure the gap on real instancesbenchmark set
  4. Does a custom algorithm beat both clearly?
    YesBuild it, with tests and two ownersNoKeep the solver or heuristic
  5. Review yearlydata scale and solver quality change

5 steps in order. Play them, or step through them one at a time.

5Revisiting the Decision Over Time

The right choice changes. Data grows: a heuristic that was within 2 percent at 200 vans may be 10 percent worse at 2,000. Solvers improve: open source solvers have become far more capable over the last decade, so a problem that needed custom code five years ago may now be a few hundred lines of OR-Tools model. And business rules accumulate, which favours declarative models over custom search code. So I would put the decision on an annual review, rerun the benchmark set with current solver versions, and look at how much engineering time the current approach costs per change. When the numbers move, we change course deliberately rather than waiting for a crisis.

6Follow-up questions

How do you convince the original author that their algorithm should be replaced?

With the benchmark rather than opinion, and by giving them a role in the result. Often their algorithm wins on some instances, and their knowledge of the constraints is exactly what the solver model needs. Framing it as reducing the risk that only they can maintain it usually lands better than framing it as their code being worse.

When does an in-house algorithm make sense today?

When the problem has a structure that general solvers handle poorly and the value is large, or when hard latency limits rule out a solver, for example a decision needed in under a millisecond. Even then, a solver often serves as the reference for testing the custom code.

How do you budget for a commercial solver licence?

We compare the licence cost with the value measured on the benchmark set, the gap between the commercial and open source solver on our instances. If the commercial solver saves 1 percent more on a 110 million dollar cost, the licence is easy to justify; if it saves nothing measurable on our instances, it is not.

7Conclusion

In this answer, we decided between in-house algorithms, solvers and heuristics by first putting a number on the value of a better answer with the business. Solvers bring proven search and support at the cost of licences and modelling skill, heuristics are cheap and explainable once we measure their gap to optimal on real data, and custom algorithms are justified only when they clearly win. In every case we documented the problem, kept tests with known optimal answers and a benchmark set, ensured at least two maintainers, and revisited the choice as data and solvers changed.

What to say in the interviewAbout 90 seconds aloud

Open with

I would start with the value of optimality, because it decides everything else. For a fleet of two thousand vans costing around a hundred million dollars a year to run, three percent better routes is worth millions, which justifies a solver, a licence and some operations research skill.

Then, if they want more

For an internal scheduler, a few percent is worth nothing, so a simple heuristic wins. Then I compare the options on evidence. Solvers like OR-Tools or a commercial MIP solver give proven performance, readable models where a new constraint is a few lines, and bounds on how far an answer is from optimal, but need modelling skill and time limits.

Heuristics are easy to explain and maintain, but only once we have measured their gap to optimal on a benchmark of real historical instances. A custom algorithm has to beat both clearly on that benchmark to be worth its maintenance cost.

Whichever we choose, I remove key-person risk: the problem and its constraints are documented separately from the code, tests include small cases with known optimal answers and quality thresholds on the benchmark, and at least two engineers can change and deploy it.

Finally, I would revisit the decision every year, because data grows, solvers improve and business rules pile up, and those all shift the balance.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Optimisation problems such as routing, scheduling and pricing often start as clever...": https://scrivio-interview-library.netlify.app/java/algorithms-and-data-structures/01320ab6be/