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 says it in words a planner understands. Use it from Python, any MCP client, or Claude Code, on HiGHS, SCIP or your own Gurobi.

pip install "optlens[scip,mcp] @ git+https://github.com/jjd-lab/optlens"
claude plugin install optlens --marketplace jjd-lab/optlens   # Claude Code
codex mcp add optlens -- optlens-mcp                           # Codex (others: one line)

Measured on 400 models

400 broken and working models, up to 837,000 rows, each with a solver-verified answer key. Claude with optlens against the same agent with only a solver, both given the same model context.

95-100 %
correct in every suite, with or without the engine: the answers were never the gap
35-48 %
lower cost for the same correct answers, growing with model size
35-61 %
less time on models too large to read (279,000 to 837,000 rows)
755 → 9
plan changes reported after an edit: the forced ones, not the solver's reshuffle
optlensbare
optlens, small: $0.056 per case, 5.1 turns, 80/81 right$0.056bare, 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, 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, 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, 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

Every answer comes from a solve, and every recommended fix is re-solved before it is offered.

Why is it infeasible?

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

What fixes it?

The smallest change per family that restores feasibility, with the best plan it allows, and 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: each family's business meaning, checked against the model, saved as JSON your team reviews and reuses.

Everything you can ask, tool by tool →

For the planners who own the plan

optchat, a chat agent built on optlens, answers business planners in plain language and asks before applying a change. Here a planner finds a data-entry error, approves the fix and asks what the rules cost (waiting time cut to two seconds). 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 the engine
Markdown
is all a new business domain needs: the model's document and a pack's skill; helpers only for linked models
A planner asks why the week's plan is infeasible, approves the fix, and asks
  which rule costs the most revenue

Solvers

HiGHSSCIP Gurobi (your license)

A hard time limit on every solve. A Gurobi session does every step on Gurobi; every IIS is checked.

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; the agent gets the tools and the method together. Local, on your machine.