A constraint analysis and debugging toolkit for Pyomo, an open-source optimization modeling language in Python. This library provides tools for analyzing solver outputs, diagnosing infeasibility, and identifying binding constraints in linear optimization models.
Three core capabilities designed to help you understand and improve optimization models:
- Find Bottlenecks: Identify tight constraints limiting your solution (via
ConstraintAnalyzer) - Diagnose Infeasibility: When models fail to solve, diagnose constraint violations and their severity (via
UnfeasibilityDetector) - Extract Insights: Unified interface extracting dual values, slack analysis, and sensitivity metrics (via
SolverDiagnostics)
Install from PyPI:
pip install pyomo-solver-analyzerOr install from source with development dependencies:
git clone https://github.com/jaimeam/Pyomo-Solver-Analyzer.git
cd PyomoSolverAnalyzer
pip install -e ".[dev]"The simplest approach is to use SolverDiagnostics for complete analysis:
from pyomo_solver_analyzer import SolverDiagnostics
import pyomo.environ as pyo
model = pyo.ConcreteModel()
# ... define and solve your model ...
solver = pyo.SolverFactory('glpk')
results = solver.solve(model)
# One-line diagnostics report
diagnostics = SolverDiagnostics(model, results)
diagnostics.print_report()For specialized analyses or detailed examples, see the Examples Guide.
For detailed development setup instructions, see DEVELOPMENT.md.
PyomoSolverAnalyzer/
├── src/
│ └── pyomo_solver_analyzer/ # Main package
│ ├── __init__.py
│ ├── analyzer.py
│ ├── diagnostics.py
│ ├── introspection.py
│ └── unfeasibility.py
├── tests/ # Test suite
├── docs/ # Documentation
├── README.md
├── LICENSE
├── pyproject.toml # Project configuration
└── DEVELOPMENT.md
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Before committing, ensure:
- Code passes
rufflinting:ruff check src/ - Code passes
mypytype checking:mypy src/ - Tests pass:
pytest tests/ - Pre-commit hooks pass:
pre-commit run --all-files
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or feature requests, please open an issue on GitHub.
If you use this library in your research, please cite:
@software{pyomo_solver_analyzer,
title={Pyomo Solver Analyzer},
author={Adroher, Jaime},
year={2025},
url={https://github.com/jaimeam/Pyomo-Solver-Analyzer}
}