optlens

Debug and explain your optimization models.

optlens finds why an LP or MILP model is infeasible, the smallest change that fixes it, and what a change costs. Then it says so in words a planner understands. Use it from Python, any MCP client, or Claude Code, on HiGHS, SCIP or your own Gurobi.

Get started

pip

pip install "optlens[scip,mcp]"

Claude Code

claude plugin marketplace add jjd-lab/optlens
claude plugin install optlens@optlens

Codex (others: one line)

codex mcp add optlens -- optlens-mcp

Measured on 400 cases

Infeasible, wrong and working LP and MILP models of up to 837,000 constraints, each case with a solver-verified answer key.

We compare Claude with optlens against the same agent given only a solver, both in our own minimal agent loop with the same model context. We also measured the plugin in Claude Code itself.

95-100 %
correct in every suite, with or without optlens
35-48 %
lower cost for the same correct answers, growing with model size (optlens called from the agent's code)
43-71 %
less time on models too large to read (279,000 to 837,000 constraints)
32/33
right in Claude Code with the plugin, against 30/33 without it, in 65 % less time (Sonnet 5.5, three runs of 11 questions)
755 → 9
variables reported as changed after one edit to an ad-allocation MIP. A plain diff counts 755, mostly the solver switching between equally good plans. optlens shows the 9 the edit forces.
optlensbare (solver only)
optlens, small: $0.056 per case, 5.1 turns, 80/81 right$0.056bare (solver only), small: $0.085 per case, 6.2 turns, 79/81 right$0.085−35%smalloptlens, mid: $0.066 per case, 5.7 turns, 56/56 right$0.066bare (solver only), mid: $0.111 per case, 8.3 turns, 56/56 right$0.111−40%midoptlens, large: $0.050 per case, 3.7 turns, 13/13 right$0.050bare (solver only), large: $0.087 per case, 6.7 turns, 13/13 right$0.087−42%largeoptlens, too large to read: $0.069 per case, 6.1 turns, 16/16 right$0.069bare (solver only), too large to read: $0.133 per case, 10.0 turns, 16/16 right$0.133−48%too large to read
Mean cost per case and run, same cases; the percentage is optlens's saving. Hover a bar for turns and correctness.

How we measured it, and how six setups compare →

What it does

optlens solves the model for every answer, and it re-solves every fix before it offers it.

Why is it infeasible?

The conflicting constraints (an IIS), grouped by family, even on models with hundreds of thousands of constraints.

What fixes it?

The smallest change per family that restores feasibility, with the best plan it allows. Also the inputs that break their own pattern, each with its undo already solved.

What if…?

Edits as versions, why-not questions, marginal values and sensitivity, without touching your model code.

How do these plans differ?

Changes against the closest optimal plan, so an edit shows what it forces, not the solver's choice among ties.

Which scenario is better?

Open several models or scenarios side by side and compare status, objective and every family's metrics, or ask a what-if on one of them.

What does this model mean?

A model context, generated once from your document or code. It gives each family's business meaning, checked against the model, as JSON your team reviews and reuses.

Everything you can ask, tool by tool →

Guides

Step-by-step answers to common questions about infeasible models, with code you can run and the output it prints.

In Claude Code

A clean Claude Code with the optlens plugin works on the hotel pack's week. A data load typed one night's group target as 1,200 instead of 120. The agent finds the cause, re-solves to check the fix, then prices each business rule. The animation comes from a recorded session, and each tool call shows its real duration.

Claude Code with the optlens plugin finds why the week's hotel plan is
  infeasible, checks the fix, and ranks the business rules by the revenue they cost

Try the same week yourself, in a setup of its own: git clone https://github.com/jjd-lab/optlens && optlens/scripts/sandbox.sh ~/optlens-try

For business users

optchat is a chat agent built on optlens. Planners, analysts and managers, the people who act on a model's plan, use it to work with the model in plain language. It keeps every change as a version and compares scenarios side by side. It carries a change across linked models, such as a new rate plan into the booking plan. It applies nothing until the planner approves, and it records each decision. In the recording, a planner finds a data-entry error, approves the fix and asks what the rules cost. In the recording, waits longer than two seconds are cut to two. optchat is available on request: hello@optlens.dev.

4/4
turns right with the hotel pack on a rate plan that feeds the booking plan; 2/4 without the pack, 1/4 for the coding agent with optlens
Markdown
is all a new business domain needs: the model's document and a pack's skill. Only linked models also need helper code.
A planner asks why the week's plan is infeasible, approves the fix, and asks
  which rule costs the most revenue

Two full sessions with a planner, as recorded →

Solvers

HiGHSSCIP Gurobi (your license)

A hard time limit on every solve. What each solver handles →

Models

LPMPS PyomogurobipyPuLP

Load the file, the model object, or the script that builds it.

Where

Claude CodeCodex CursorCopilotClaude Desktop Python

One MCP server, connected with one line, gives the agent the tools and the method. It runs locally, on your machine.