python-optimization

Guide Python optimization problem classification, library selection, and solver configuration.

16|Updated Dec 28, 2025
One-click install
npx skills add https://github.com/Hongyu-yu/matsci-ai-skills --skill python-optimization-hongyu-yu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-optimization
Source: https://github.com/Hongyu-yu/matsci-ai-skills/tree/main/skills/python-optimization
Command: npx skills add https://github.com/Hongyu-yu/matsci-ai-skills --skill python-optimization-hongyu-yu

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provide structured, practitioner-focused guidance to convert mathematical optimization problems into working Python solutions, covering problem formulation, library choice, solver configuration, and robust implementation patterns.

Core Features & Use Cases

  • Problem Analysis Framework: Classify objectives, decision variables, constraints, and data to select the right approach.
  • Library & Solver Guidance: Recommend SciPy, Pyomo, CVXPY, GEKKO, and backends based on problem type and scale.
  • Implementation Patterns: Templates for unconstrained, constrained, least squares, curve fitting, LP/QP/NLP/MIP, and global optimization.
  • Practical Use Cases: Hyperparameter optimization, design optimization, parameter estimation, and portfolio optimization in Python.

Quick Start

Run a minimal optimization example by solving a small linear program in Python using scipy.optimize to see the workflow.

Frequently Asked Questions about python-optimization

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

FAQPage Schema
What is the best way to solve nonlinear optimization problems in Python?

Python optimization classifies your mathematical problem type—such as linear, quadratic, or nonlinear—and recommends libraries like SciPy, CVXPY, or Pyomo to formulate objectives and constraints for solver execution.

How do I choose between SciPy, CVXPY, and Pyomo for my optimization problem?

Choosing between SciPy, CVXPY, and Pyomo depends on problem classification. SciPy handles general small-scale tasks, CVXPY excels at convex optimization, and Pyomo suits large-scale mixed-integer programming, ensuring proper solver configuration and scaling.

Can I use Python for large-scale mixed-integer programming and global optimization?

Yes, Python supports large-scale mixed-integer programming and global optimization. By using frameworks like Pyomo or GEKKO, you can configure appropriate solvers, apply scaling, and implement templates for robust execution across complex problem spaces.

How do I set up parameter estimation and curve fitting using Python optimization?

Parameter estimation and curve fitting use Python optimization via least squares templates in SciPy. You define the objective function, input data, and constraints, then configure the solver to iteratively minimize residuals and estimate parameters.

What should I do if my Python optimization solver is not converging?

If your Python optimization solver is not converging, apply troubleshooting best practices like scaling variables and constraints, checking gradient usage, and verifying problem convexity. Proper solver configuration and formulation alignment are critical.