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 cases

Infeasible, wrong and working LP and MILP models of up to 837,000 constraints, each case with a solver-verified answer key. Claude with optlens is compared with the same agent given only a solver; both get the same model context.

95-100 %
correct in every suite, with or without optlens
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 constraints)
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

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 constraints.

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 business users

optchat, a chat agent built on optlens, lets the people who act on a model's plan (planners, analysts, managers) work with it in plain language. It keeps every change as a version, compares scenarios side by side, carries a change across linked models (a new rate plan into the booking plan), and applies nothing until the planner approves, recording each decision. 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 optlens
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

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