or-solver

A solver-management guide for optimization problems such as linear programming, mixed-integer programming, and second-order cone programming. It detects installed solver packages, checks licenses, selects a suitable solver, and describes installation when none is available.

In plain words
What is it for?
Use it before solving supported optimization problems to inspect the environment, choose among commercial or open-source solvers, configure licenses, or plan installation.
Why use it?
It avoids maintaining separate setup logic for each optimization workflow and helps identify why a solver cannot be used.

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/or-solver
Any agent
npx skills add VeryMath/AI4Math-Optimization --skill or-solver
Clone the repo
git clone --depth 1 https://github.com/VeryMath/AI4Math-Optimization

Made for: Claude Code, Codex.

Per session 145 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,236 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.00145 $0.05236
Opus 5 $0.00072 $0.02618
Sonnet 5 $0.00029 $0.01047
Haiku 4.5 $0.00015 $0.00524

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

Security

Grade A, and why

or-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 yesterday.

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/or-solver/SKILL.md · 405 lines

How it starts

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

运筹优化求解器统一配置

适用场景

本 skill 为以下运筹优化 skill 提供统一的求解器检测、安装与选择:

  • LP(线性规划)→ ../linear-programming/SKILL.md
  • MIP(混合整数规划)→ ../mixed-integer-programming/SKILL.md
  • SOCP(二阶锥规划)→ ../second-order-cone-programming/SKILL.md

当 LP / MIP / SOCP skill 在 Quick Start 第一步需要做环境准备时,应调用本 skill 的检测与安装流程,而非各自维护独立的求解器管理代码。

Quick Start(求解器环境准备)

核心原则:先检测,再分类,后规划。不做任何预设。

flowchart TD
  DETECT["Step 1: pip list 检测所有包"]
  DETECT --> DONE{" "}
  DONE --> COMM{"商业求解器已安装?"}
  COMM -->|是| LIC["逐个验证 License"]
  LIC --> SELECT["Step 2: 综合已安装的商业 + 开源,按优先级选择"]
  COMM -->|否| SELECT
  SELECT --> AVAIL{"有可用求解器?"}
  AVAIL -->|有| SOLVE["求解"]
  AVAIL -->|无| INSTALL["Step 3: pip install 安装开源求解器(需询问用户)"]
  INSTALL --> SOLVE

Step 1:统一检测

执行以下命令,一次性检测所有求解器包:

pip list | findstr -i "coptpy gurobipy mosek cplex pyscipopt highspy clarabel pulp mip ortools ecos scs cvxopt cosmo osqp swiglpk scipy lpsolve55 numpy cvxpy"

Unix 下将 findstr -i 替换为 grep -iE

检测后,将结果分为两类:

类别 包含包
商业求解器(需 License) coptpy, gurobipy, mosek, cplex
开源求解器(无需 License) scipy, highspy, pulp, cvxpy, clarabel, ecos, scs, cvxopt, cosmo, osqp, pyscipopt, mip, ortools, swiglpk, lpsolve55
基础依赖 numpy

Step 2:分类验证 + 选择

2a. 验证商业求解器 License(仅对已安装的)

检测到哪些商业求解器,就逐一验证哪些。不做"大概率没有"的预设——用户设备上有什么就验证什么。

对每个已安装的商业求解器,通过实际创建模型来验证 License(不能只看包是否可导入):

求解器 License 验证方式
COPT import coptpy as cp; cp.Envr().createModel("_t") — 抛异常则 License 缺失
Gurobi import gurobipy as gp; gp.Model("_t") — 抛异常则 License 缺失(注意:v13+ 自带受限 License,通常无需额外配置)
MOSEK 通过 cvxpy 调用 prob.solve(solver=cvx.MOSEK) — 裸 mosek.Env() 可能走试用许可,但 cvxpy 调用必须要有正式 mosek.lic 文件
CPLEX 通过 cvxpy 调用 prob.solve(solver=cvx.CPLEX) — v22.1+ 自带学术 License

验证结果:

  • License 有效 → 该求解器标记为可用
  • License 缺失 → 告知用户如何申请(详见「License 配置」节),将该求解器标记为不可用,继续检查其他求解器
2b. 确认问题类型

Read the full file on GitHub · 405 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. yesterday First seen · 405 lines · 145 tokens per session scan A feae3bc11c1b

Subscribe to this mod's changes

or-solver is a skill published in the GitHub repository VeryMath/AI4Math-Optimization (5 stars, last pushed 1mo ago), licensed MIT. It adds 145 tokens to every session and 5,236 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

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

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