Back to overview
Blog

When a good LLM answer isn’t enough: an introduction to mathematical optimization

Read on
Roelof Kuipers

Roelof Kuipers

Read on
Updated
26 Nov 2026
Published
26 Nov 2026
Reading time
8 min
Tags
When a good LLM answer isn’t enough: an introduction to mathematical optimization
Share this on:
When a good LLM answer isn’t enough: an introduction to mathematical optimization
9:43

Executive summary:

Large language models (LLMs) can draft a plan in seconds, but they cannot guarantee that it respects every rule or that no better plan exists. Mathematical optimization closes that gap: it turns decisions, constraints, and a measurable goal into a model that a solver checks and, when solved to optimality, proves is the best. At ML6, we combine it with generative AI (GenAI) to turn customer requests and business data into concrete action plans for scheduling, logistics, energy, and beyond. 

Why LLMs cannot make every decision

Imagine asking an LLM to create a weekly staff schedule. Every shift needs enough people, employees have different availability, and the aim is to keep overtime low. The model may produce a useful schedule in seconds, along with a clear explanation of its choices.

But a schedule that looks sensible can still contain one critical mistake: it assigns someone to a shift when they are unavailable. Most of the plan may be correct, yet that single violation makes it unusable as written. A convincing explanation does not establish that every requirement has been checked. And even if the schedule meets all the requirements, could another one cover the same shifts with less overtime? Finding a good solution does not prove that no better one exists.

LLMs can solve problems, but their outputs alone cannot guarantee either feasibility (meeting every requirement) or optimality (finding the best feasible solution). This is not a hypothetical risk. In ConstraintBench, a 2026 benchmark of 200 constrained planning tasks, the best frontier model returned a feasible solution only 65% of the time; for crew assignment, feasibility dropped below 1%. When those guarantees matter, the schedule needs explicit checks and a method to determine whether a better option exists.

What does mathematical optimization do differently?

For a staff schedule, we need to know whether every rule is met and whether another schedule could reduce overtime. Mathematical optimization helps answer both questions.

Optimization is about making the best possible decisions to achieve a goal while respecting constraints. Approaches include reinforcement learning and search algorithms. Here, we focus on mathematical optimization, which is especially useful when we can describe rules as explicit mathematical equations and define a measurable goal.

Whether we are planning shifts, optimizing a battery connected to the electricity grid, or choosing delivery routes, we always start with three ingredients:

  1. Decisions: what can we choose?
    These are the choices we need to make. Which employee works which shift? When should an industrial battery charge? Which route should a truck take? In a mathematical model, these choices become decision variables.
  2. Constraints: what are the rules?
    Employees must be available for their shifts. A battery cannot deliver more energy than is stored. Trucks must respect road restrictions and delivery deadlines. We express these rules mathematically as constraints. A solution that respects every constraint is called feasible.
  3. Objective: what does "best" mean?
    We don’t want just any feasible solution. We want the best possible one. The objectives define what we want to achieve: what we want to minimize or maximize. For shift planning, we might minimize overtime. For battery optimization, electricity cost. For delivery routes, total distance driven. Different objectives can lead to different decisions, even under the same constraints.

At ML6, we help companies define these ingredients. A solver, a specialized algorithm such as Gurobi or HiGHS, then uses the resulting model to find the best feasible solution without checking every combination. It can quantify how much improvement is still possible and, when solved optimally, prove that no better solution exists within the model.

The result is a concrete recommendation: who works when, how much energy to store, or which route to take.

Diagram of shift planning for three employees, showing how decisions, constraints and the objective combine.

Shift planning for 3 employees: decisions define the choices, constraints set the limits, and the objective defines what “best” means.

What makes optimization difficult?

Describing a problem through decisions, constraints, and an objective sounds straightforward. In practice, understanding exactly what those ingredients should be is often the hardest part.

Understanding the business logic

In employee scheduling, minimizing overtime might repeatedly give the same people unpopular shifts. The model must include fairness if it should influence the outcome, but translating it into numbers is difficult. How do you measure "fairness"?

Requirements can also conflict. Covering every shift may require overtime, while avoiding overtime may leave shifts unfilled. When both goals cannot be met, someone must decide how to compromise.

The hardest part is often translating business reality into precise rules. At ML6, our work often starts here: working with people who understand the operation, uncovering the actual rules, resolving conflicting goals, and deciding what "better" should mean.

Improving performance

Time matters too. The number of possible schedules grows rapidly as employees, shifts, and rules are added. Techniques that rule out combinations early, along with heuristics, can speed up optimization by orders of magnitude. When a plan breaks, for example because someone calls in sick, the same speed lets us re-optimize in real -time. At ML6, we combine business understanding, mathematical modeling, and engineering to make these choices.

Where does optimization create business value?

The same decision structure appears across industries, from daily operational planning to investments that shape a business for decades. Employee scheduling is one example; logistics, energy, and grid operations follow the same pattern.

Logistics: how do we deliver orders with the resources available?

Optimization determines delivery routes and vehicle loads within capacity limits, delivery windows, and driver working hours. Better plans mean timely deliveries, less driving, and lower costs.

Energy investments: which assets make financial sense?

At ML6, we have modeled how renewable generation and batteries create value for large industrial energy consumers. Decisions about buying, storing, using, and selling electricity on volatile markets translate into expected costs, revenues, and investment payback. Simulating a site with and without a battery shows what that battery would add to the annual bill, and so whether the investment holds. Operational optimization in this way becomes an input to a bankable investment business case.

Grid operations: how can we use existing infrastructure better?

Our grid optimization prototype uses reinforcement learning, where an agent learns which actions work through trial and error in simulation, to suggest changes to the grid’s configuration that could relieve congestion. In benchmark simulations, it kept the grid within limits for a full 28-day episode in 87% of runs, against 65% for a greedy baseline. It presents candidate actions for an operator to assess, supporting better use of existing infrastructure.

Different industries pose different optimization challenges, and even similar problems can call for different methods. In each case, delivering value depends on understanding how the business actually operates.

Often, we first need to extract the information for those decisions from conversations, documents, or other business systems. This is why optimization has a natural connection with GenAI.

One battery. Many connected decisions

Diagram of one industrial battery linked to connected decisions about when to buy, store, use and sell electricity.

Optimizing when to buy, store, use, and sell electricity reveals the value an industrial battery can deliver.

Combining GenAI and mathematical optimization

Imagine a customer calls their internet provider: "My connection has been down since yesterday, and I need someone to fix it."

A voice agent can understand the complaint, extract the issue type and urgency, and create a service ticket. Then comes a decision problem. A telecom company may have thousands of tickets. Which technician handles which ticket? When and in what order?

That is where optimization comes in. It can assign tickets and plan routes while accounting for technician skills, availability, travel time, and employment contracts. The objective might be to solve as many tickets as possible while balancing workloads between technicians.

Optimization therefore complements the voice agent: GenAI structures the customer’s request. Optimization uses that information to calculate an action plan. The business defines the rules and priorities, and employees handle exceptions.

Together, we connect the customer conversation to the work needed to resolve it, extending the business value beyond just understanding and recording the request.

From customer request to action planFlow from a customer request, structured by GenAI, to an action plan that decides who does what and when.

GenAI turns customer requests into structured information; optimization uses it to plan who does what, when.

Which decision could you improve?

Which recurring decision in your organization ties up resources, consumes planning time, or creates avoidable costs? If you can identify the choices, rules, and a goal, you likely have a mathematical optimization opportunity. In the next articles, we will explore specific approaches and applications, and how to turn them into planning tools your teams use every day.

About the author

Roelof Kuipers

Roelof Kuipers is a Senior AI Engineer and Tech Lead at ML6, where he combines strong expertise in optimization with a focus on forecasting and agentic AI systems. Working primarily in the energy transition, he translates complex business and operational challenges into AI solutions that work in practice. His projects include optimizing renewable energy portfolios, battery operations and trading decisions. With a background spanning energy, manufacturing, mobility and digital platforms, Roelof brings experience across the full delivery lifecycle: identifying use cases, designing systems, developing models and deploying solutions into production. He pairs hands-on technical work with leading engineering teams, mentoring colleagues and collaborating with domain experts. Roelof holds a Master’s degree in Mathematics from the University of Amsterdam.

Other contributors

  • Robin SasseML Engineer
The answers you've been looking for

Frequently asked questions