osqp-solver

A guide for using the OSQP Python solver to solve continuous convex quadratic programs: optimization problems with a quadratic objective and linear constraints. It also covers model conversion, status checks, residuals, infeasibility evidence, and repeated solves.

In plain words
What is it for?
Use it to model, solve, update, reproduce, or diagnose supported convex quadratic programs with OSQP. It does not cover integer variables or general nonlinear constraints.
Why use it?
It helps prevent incorrect solver models and unsupported problem types by requiring the formulation, dimensions, convexity, and returned status to be checked.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/verymath/ai4math-optimization/osqp-solver
Any agent
npx skills add VeryMath/AI4Math-Optimization --skill osqp-solver
Clone the repo
git clone --depth 1 https://github.com/VeryMath/AI4Math-Optimization

Made for: Claude Code, Codex.

Per session 131 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,071 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00131 $0.02071
Opus 5 $0.00066 $0.01035
Sonnet 5 $0.00026 $0.00414
Haiku 4.5 $0.00013 $0.00207

Measured 2d ago against content hash c3290c2ca248, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

osqp-solver scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/check_osqp_environment.py, scripts/solve_qp.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/osqp-solver/SKILL.md · 245 lines

How it starts

The opening of the file, as written. The whole thing — 245 lines — stays where its author put it; the contents beside it link to each section on GitHub.

OSQP Solver

Scope

Work only with the continuous convex QP

[ \begin{array}{ll} \operatorname{minimize} & \frac12 x^\top P x + q^\top x \ \operatorname{subject\ to} & l \leq A x \leq u, \end{array} \qquad P=P^\top\succeq 0. ]

Treat OSQP as a numerical solver, not as a modeling oracle. Derive the model, check dimensions and convexity, solve, and then independently verify what the returned status means.

Route elsewhere when the task contains integer variables, a genuinely indefinite (P), nonlinear constraints, or cones that cannot be represented by linear bounds. Do not claim that failure to detect nonconvexity proves convexity.

Workflow

1. Freeze the interpreted model

Write a short modeling checkpoint before executable code:

source:
variables and units:
objective before conversion:
constraints before conversion:
canonical P, q, A, l, u:
dimensions and expected sparsity:
why P is positive semidefinite:
requested accuracy and runtime budget:
ambiguities:

Confirm any interpretation that changes the mathematics. Keep the factor (\tfrac12) visible: if the original quadratic is (x^\top Qx), then OSQP usually needs (P=2Q).

2. Inspect the environment

Run the non-mutating probe:

python3 scripts/check_osqp_environment.py --json

Require osqp, numpy, and scipy. If they are missing, report:

python3 -m pip install 'osqp>=1,<2'

Obtain approval before changing an existing environment. Do not infer solver availability from a package listing alone; import it with the probe. Require ready: true: an importable but unsupported OSQP major version is not ready for this runner.

3. Construct solver data deliberately

  • Store P and A as scipy.sparse.csc_matrix.
  • Reject materially asymmetric input. For differences within the declared symmetry tolerance, construct one canonical symmetric P and use that same matrix for the PSD, objective, stationarity, setup, and update checks. Pass its upper triangle to OSQP because the solver uses upper-triangular storage.
  • Encode one row of (l\leq Ax\leq u) per equality, interval, lower bound, or upper bound. Use numpy.inf for open sides.
  • Check P.shape == (n, n), q.shape == (n,), A.shape == (m, n), and l.shape == u.shape == (m,).
  • Check l <= u, finite P, q, and A, and the scale of every row and column. Avoid accidental dense construction for large problems.

Read the full file on GitHub · 245 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 245 lines · 131 tokens per session scan A c3290c2ca248

Subscribe to this mod's changes

osqp-solver is a skill published in the GitHub repository VeryMath/AI4Math-Optimization (5 stars, last pushed 1mo ago), licensed MIT. It adds 131 tokens to every session and 2,071 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

math-beamer

Use when creating, revising, or auditing source-grounded mathematical Beamer slide decks from papers, notes, proofs, lectures, experiments, or existing LaTeX slides across pure mathematics, applied mathematics, computational mathematics, statistics, optimization, geometry, topology, algebra, number theory…

VeryMath/AI4Math-Writing · 100 tokens

paper-writing

Use when drafting, revising, or auditing source-grounded mathematical paper text, including abstracts, introductions, related work, theorem exposition, experiment narratives, revision plans, and response letters.

VeryMath/AI4Math-Writing · 40 tokens

latex-build-and-layout-audit

Use when checking LaTeX paper projects for compilation, latexmk logs, undefined references, citation issues, duplicate labels, macro/package hygiene, layout warnings, floats, arXiv, or venue compatibility.

VeryMath/AI4Math-Writing · 48 tokens

paper-skeleton-and-logical-architecture

Use when turning mathematical notes, theorem statements, proof sketches, experiments, or reading outputs into a paper skeleton, section plan, result dependency map, or contribution architecture before prose drafting.

VeryMath/AI4Math-Writing · 45 tokens

proof-obligation-and-assumption-audit

Use when checking mathematical paper results for assumptions, quantifiers, domains, dependency fit, edge cases, external theorem use, proof coverage, or theorem-to-claim consistency.

VeryMath/AI4Math-Writing · 43 tokens

claim-evidence-ledger

Use when auditing mathematical paper drafts for supported claims, missing citations, overclaims, proof status, experiment support, or source-to-text traceability.

VeryMath/AI4Math-Writing · 35 tokens