python-optimization

Classify Python optimization problems and map them to solvers.

34|7|Updated Nov 29, 2025
One-click install
npx skills add https://github.com/jkitchin/skillz --skill python-optimization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-optimization
Source: https://github.com/jkitchin/skillz/tree/main/skills/programming/python-optimization
Command: npx skills add https://github.com/jkitchin/skillz --skill python-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you classify optimization problems and choose the right Python tools (scipy, pyomo, cvxpy, GEKKO), configure solvers, and implement robust patterns for LP, QP, NLP, MIP, convex, and global optimization.

Core Features & Use Cases

  • Problem Classification: Guidance to identify LP, QP, NLP, MIP, or global optimization.
  • Library Selection: Recommends scipy, pyomo, cvxpy, or GEKKO based on problem type and scale.
  • Implementation Patterns: Provides end-to-end patterns for unconstrained and constrained optimization, including common solvers and interfaces.

Quick Start

Ask Claude to classify a given optimization problem (e.g., "minimize c'x subject to Ax ≤ b with nonlinear constraints") and receive a recommended library, solver, and a starter code pattern.

Frequently Asked Questions about python-optimization

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

FAQPage Schema
How do I choose between scipy, cvxpy, pyomo, and GEKKO for my optimization problem?

Library selection depends on problem type and scale. Scipy handles unconstrained and simple constrained problems efficiently. Cvxpy suits convex optimization with elegant syntax. Pyomo scales to large mixed-integer and complex problems. GEKKO excels at nonlinear and dynamic optimization. Match your problem classification—LP, QP, NLP, MIP, or global—to the library's strengths.

What's the difference between linear programming, quadratic programming, and nonlinear programming?

Linear programming (LP) minimizes a linear objective subject to linear constraints, solved rapidly with simplex methods. Quadratic programming (QP) adds squared terms to the objective or constraints, requiring specialized QP solvers. Nonlinear programming (NLP) includes arbitrary nonlinear functions; it's harder to solve and may have multiple local optima. Classification determines which solver to use.

How do I formulate and solve a constrained optimization problem in Python?

Define your objective function, decision variables, and constraints; classify the problem type (LP, QP, NLP, MIP, convex, or global). Select the appropriate library and solver. Implement using end-to-end patterns: initialize variables, add constraints, configure the solver, and extract results. Robust patterns handle numerical stability and convergence issues.

Can I solve mixed-integer programming problems with Python optimization libraries?

Yes, both pyomo and cvxpy support mixed-integer programming (MIP). Pyomo integrates with industrial solvers like CPLEX and Gurobi for production-scale problems. Cvxpy works with open-source MIP solvers. MIP adds discrete decision variables to LP or NLP formulations, enabling applications in scheduling, routing, and resource allocation.

What problems does convex optimization solve that other methods can't?

Convex optimization guarantees that any local minimum is a global minimum, enabling efficient, reliable solutions. It applies to portfolio optimization, resource allocation, and machine learning loss minimization. Cvxpy and GEKKO detect convexity automatically. Non-convex problems may require global optimization techniques or local solvers with multiple starting points.

When should I use global optimization instead of local solvers?

Use global optimization when the problem is non-convex and local optima could be far from the global minimum, or when you need the best possible solution regardless of computation time. Global methods explore the entire search space. GEKKO and scipy support global optimization. Trade computation time against solution quality based on your problem's constraints.