--- id: amplpy version: "0.18.0" license: BSD-3 license_treatment: permissive maintenance: active --- # amplpy — Python API for AMPL License: permissive · Maintenance: active · Downloads: 75.2K/mo ## What it is and what it does amplpy is a Python binding for AMPL, a domain-specific language for mathematical optimization. It lets you express optimization problems—linear, nonlinear, mixed-integer—using natural mathematical syntax within Python, then solve them with industry-standard solvers like Gurobi, HiGHS, or CBC. The library handles model generation and solver communication directly in AMPL's optimized C code, so you get performance without sacrificing readability. You define models using AMPL's syntax (passed as strings), populate them with data from Python lists, pandas DataFrames, or numpy arrays, call solve(), and extract results back into Python objects. This workflow is especially useful for large-scale optimization where you want the stability and speed of compiled solvers but the flexibility of Python for data preprocessing and post-processing. Use it for: - Portfolio optimization: define variance minimization with weight constraints, pass covariance matrices from pandas, solve with Gurobi. - Supply chain planning: model production, inventory, and distribution constraints in AMPL, feed demand forecasts from Python, retrieve optimal schedules. - Engineering design: set up nonlinear constraint systems, optimize over continuous or discrete variables, integrate results into a larger Python application. - Research and prototyping: quickly iterate on optimization formulations without rewriting solver interfaces for each model variant. - Production deployment: use the same AMPL model across Python, C++, or other languages by switching only the API layer. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. amplpy is a Python interface to AMPL, an algebraic modeling language for optimization problems, allowing you to define, solve, and extract results from large-scale linear, nonlinear, and mixed-integer optimization models. Yes, if you need to solve optimization problems and want a mature, language-agnostic modeling layer. The active maintenance, broad Python version support, and permissive license make it a solid choice. Caveat: you must install a solver separately and obtain an AMPL license (free Community Edition available); this adds setup friction beyond a typical pip install. ## Install pip install amplpy uv add amplpy poetry add amplpy ## Installing amplpy Before you install: Medium install friction: prebuilt wheels available for Python 3.8–3.14 across macOS, Linux, and Windows, but the package depends on ampltools and requires an AMPL solver installation (HiGHS, CBC, Gurobi, etc.) via a separate module installer. Repository is actively maintained with a recent release. License in practice: BSD-3 license is permissive; you can use amplpy in commercial and proprietary projects without copyleft obligations, though you must include the license notice. Quickstart: pip install amplpy python -m amplpy.modules install highs from amplpy import AMPL ampl = AMPL() ampl.eval("var x >= 0; minimize cost: x;") ampl.solve(solver="highs") Requires a solver to be installed via `python -m amplpy.modules install ` (e.g., highs, cbc, gurobi) and a valid AMPL license (free Community Edition available). Verify before relying: - Whether ampltools is a compiled dependency that may require build tools on some platforms. - Exact memory and CPU overhead when working with very large models or datasets. - Whether the free AMPL Community Edition has model size or feature restrictions. ## Package facts - License: BSD-3 (permissive) - Python support: unspecified - Install friction: medium - Maintenance: active - Downloads: 75.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags optimization modeling in Python, AMPL Python interface, mathematical optimization solver, linear programming Python, mixed-integer optimization, algebraic modeling language, constraint optimization, optimization, mathematical-modeling, solver-interface [View on SkillFed](https://skillfed.io/packages/amplpy) · [View on PyPI](https://pypi.org/project/amplpy/)