Contract
- Input: problem description and inputs defined by the skill body.
- Output: Markdown artifact with completed process steps.
- Side effects: none.
- Dependencies: none.
- Stop condition: all process steps executed; artifact saved with required sections.
- Risk: low.
- Boundary: produces reasoning artifact only; no system changes.
Mathematical Optimization
Turn a real problem into a mathematical program, solve it with an appropriate solver, and report what was found — including the gap to optimality when the optimum is not proven.
When to use
- The user wants to maximize/minimize something under constraints (cost, time, risk, distance, utility).
- A decision can be cast as variables + objective + constraints.
- Other skills (logistics, finance, ML) need an optimization backbone.
Process
1. Model
Define:
- Decision variables — what the agent controls.
- Objective — single scalar to extremize (or a Pareto front if multi-objective).
- Constraints — equalities, inequalities, integrality, bounds.
- Parameters — fixed inputs that distinguish instances.
State the canonical class: LP, QP, SOCP, SDP, convex, MIP, non-convex, combinatorial.
Completion criterion: variables, objective, constraints, parameters all explicit; canonical class named.
2. Diagnose hardness
Identify why the problem is hard (or easy):
- LP: poly-time (interior point / simplex).
- Convex: poly-time in practice.
- MIP: NP-hard in general; LP relaxation gives a bound.
- Non-convex / combinatorial: NP-hard; need heuristic or approximation with a guarantee.
Completion criterion: hardness class stated; relaxation or approximation strategy named if not convex.
3. Choose solver
Pick by class:
- LP/MIP: HiGHS, Gurobi, CPLEX, OR-Tools.
- Convex (QP/SOCP/SDP): CVXPY, SCS, MOSEK.
- Non-convex smooth: scipy.optimize, IPOPT, PyTorch (gradient-based).
- Combinatorial: greedy + local search, simulated annealing, tabu, ALNS, MILP relaxation.
- Multi-objective: weighted sum, ε-constraint, or NSGA-II.
Completion criterion: solver named with one reason it fits.
4. Solve
Run the solver; for non-trivial models:
- Warm-start when possible.
- Set tolerances and iteration caps explicitly.
- Log progress (objective, gap, time) at meaningful checkpoints.
Completion criterion: solver run with explicit tolerances and a logged trace.
5. Verify optimality / bound
- LP/Convex: verify dual feasibility or KKT conditions.
- MIP: report the optimality gap (e.g. 0.2% within time limit).
- Heuristic: report best-known value and a lower bound from a relaxation.
- Always run a sensitivity check — perturb a parameter by 1–5% and confirm the solution behaves sensibly.
Completion criterion: bound, gap, or sensitivity result reported.
6. Deliver
Markdown artifact with: model formulation, hardness, solver, trace summary, optimal (or best-known) solution, gap, sensitivity, and a sanity check against intuition.
Completion criterion: all six sections present; solution reproducible from the code shown.
1---2name: math-optimization3description: Formulate and solve optimization problems (linear, convex, non-convex, combinatorial) — model, choose solver, verify optimality, report sensitivity.4---56## Contract78- **Input:** problem description and inputs defined by the skill body.9- **Output:** Markdown artifact with completed process steps.10- **Side effects:** none.11- **Dependencies:** none.12- **Stop condition:** all process steps executed; artifact saved with required sections.13- **Risk:** low.14- **Boundary:** produces reasoning artifact only; no system changes.151617# Mathematical Optimization1819Turn a real problem into a **mathematical program**, solve it with an appropriate solver, and report what was found — including the gap to optimality when the optimum is not proven.2021## When to use2223- The user wants to maximize/minimize something under constraints (cost, time, risk, distance, utility).24- A decision can be cast as variables + objective + constraints.25- Other skills (logistics, finance, ML) need an optimization backbone.2627## Process2829### 1. Model3031Define:3233- **Decision variables** — what the agent controls.34- **Objective** — single scalar to extremize (or a Pareto front if multi-objective).35- **Constraints** — equalities, inequalities, integrality, bounds.36- **Parameters** — fixed inputs that distinguish instances.3738State the canonical class: LP, QP, SOCP, SDP, convex, MIP, non-convex, combinatorial.3940**Completion criterion:** variables, objective, constraints, parameters all explicit; canonical class named.4142### 2. Diagnose hardness4344Identify why the problem is hard (or easy):4546- LP: poly-time (interior point / simplex).47- Convex: poly-time in practice.48- MIP: NP-hard in general; LP relaxation gives a bound.49- Non-convex / combinatorial: NP-hard; need heuristic or approximation with a guarantee.5051**Completion criterion:** hardness class stated; relaxation or approximation strategy named if not convex.5253### 3. Choose solver5455Pick by class:5657- **LP/MIP:** HiGHS, Gurobi, CPLEX, OR-Tools.58- **Convex (QP/SOCP/SDP):** CVXPY, SCS, MOSEK.59- **Non-convex smooth:** scipy.optimize, IPOPT, PyTorch (gradient-based).60- **Combinatorial:** greedy + local search, simulated annealing, tabu, ALNS, MILP relaxation.61- **Multi-objective:** weighted sum, ε-constraint, or NSGA-II.6263**Completion criterion:** solver named with one reason it fits.6465### 4. Solve6667Run the solver; for non-trivial models:6869- Warm-start when possible.70- Set tolerances and iteration caps explicitly.71- Log progress (objective, gap, time) at meaningful checkpoints.7273**Completion criterion:** solver run with explicit tolerances and a logged trace.7475### 5. Verify optimality / bound7677- **LP/Convex:** verify dual feasibility or KKT conditions.78- **MIP:** report the optimality gap (e.g. 0.2% within time limit).79- **Heuristic:** report best-known value and a lower bound from a relaxation.80- Always run a **sensitivity check** — perturb a parameter by 1–5% and confirm the solution behaves sensibly.8182**Completion criterion:** bound, gap, or sensitivity result reported.8384### 6. Deliver8586Markdown artifact with: model formulation, hardness, solver, trace summary, optimal (or best-known) solution, gap, sensitivity, and a sanity check against intuition.8788**Completion criterion:** all six sections present; solution reproducible from the code shown.