cvxpy-python

Write, debug, and validate Python CVXPY convex optimization models with solver and status handling.

Updated Aug 12, 2026
One-click install
npx skills add https://github.com/schattenspiegel/skill-foundry-skills --skill cvxpy-python-schattenspiegel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cvxpy-python
Source: https://github.com/schattenspiegel/skill-foundry-skills/tree/main/skills/cvxpy-python
Command: npx skills add https://github.com/schattenspiegel/skill-foundry-skills --skill cvxpy-python-schattenspiegel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires cvxpy, numpy, and includes references (resource) components.

What problem does it solve? Translating a mathematical optimization problem into correct CVXPY code is error-prone: curvature rules (DCP/DPP/DGP), shape semantics, solver selection, and status handling all cause silent failures or wrong results. This Skill guides writing, reviewing, debugging, and validating CVXPY models so the code matches the intended mathematics. ## Core Features & Use Cases - Disciplined model construction: Enforces correct use of Variable, Parameter, Expression, Constraint, Objective, and Problem, including DCP/DPP ruleset checks before solving. - Solver and status discipline: Guides solver selection from installed capabilities, branches on OPTIMAL, OPTIMAL_INACCURATE, INFEASIBLE, and UNBOUNDED, and blocks reading values before status gates. - Independent validation: Requires residual, integrality, objective, and dual/KKT checks at justified tolerances rather than trusting solver output. - Use Case: You need a bounded least-squares model whose coefficients change between runs. The Skill produces a Parameter-based DPP-compliant formulation, verifies is_dcp(), selects an installed solver, and validates primal feasibility before returning results. ## Quick Start Ask the AI to write a CVXPY model for your optimization problem, including DCP checks, solver selection, status handling, and residual validation.

Frequently Asked Questions about cvxpy-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a convex optimization model in CVXPY?▼

Define the mathematics first, then create cp.Variable with shape and domain, build the objective with CVXPY atoms like cp.sum_squares or cp.norm, add constraints, and call cp.Problem(...).solve(). Check problem.is_dcp() before solving and branch on problem.status afterward.

How do I solve repeated CVXPY problems with changing data?▼

Use cp.Parameter for coefficients or bounds that change between solves while the structure stays fixed. Assign new values to parameter.value and re-solve; verify problem.is_dcp(dpp=True) before claiming DPP recompilation speedups.

Why does CVXPY reject my convex expression as not DCP?▼

CVXPY's analyzer only accepts expressions composed from recognized atoms that prove curvature, so mathematically convex code can be rejected based on its form. Rewrite using a recognized atom or equivalent formulation instead of suppressing the DCP error.

When should I use CVXPY instead of scipy.optimize?▼

Use CVXPY when the problem is convex or belongs to a disciplined class (DCP, DGP, DQCP) and you want declarative modeling with dual values and solver choice. Use scipy.optimize for general nonlinear problems without convex structure; this Skill does not cover scipy-only workflows.

Why does my CVXPY solve return None or inaccurate results?▼

A None or nonfinite value means the solver did not reach an optimal status, such as INFEASIBLE, UNBOUNDED, or a solver failure. Always check problem.status before reading variable.value, and treat OPTIMAL_INACCURATE as requiring residual validation rather than exact optimality.