Optimagic
optimagic is a Python package for numerical optimization. It is a unified interface to optimizers from SciPy, NlOpt and other packages. optimagic's minimize function works just like SciPy's, so you don't have to adjust your code. You simply get more optimizers for free. On top you get diagnostic tools, parallel numerical derivatives and more.
Install / Use
/learn @optimagic-dev/OptimagicREADME
optimagic is a Python package for numerical optimization. It is a unified interface to optimizers from SciPy, NlOpt, and many other Python packages. Its features include:
- SciPy-compatible API. optimagic's
minimizefunction works just like SciPy's, so you don't have to adjust your code. You simply get more optimizers for free. - Powerful diagnostic tools. Visualize optimizer histories, compare runs, and diagnose convergence problems.
- Parallel numerical derivatives. Compute gradients, jacobians, and hessians with parallel execution.
- Bounded, constrained, and unconstrained optimization. Support for bounds, linear constraints, nonlinear constraints, fixed parameters, and more.
- Statistical inference on estimated parameters. The estimagic subpackage provides functionality for confidence intervals, standard errors, and p-values.
Installation
optimagic is available on PyPI and on conda-forge. Install the package with
$ pip install optimagic
or
$ conda install -c conda-forge optimagic
optimagic ships with all scipy optimizers out of the box. Additional algorithms become
available if you install optional packages. For an overview of all supported optimizers
and how to enable them, see the
list of algorithms.
Usage
import optimagic as om
import numpy as np
def fun(x):
return x @ x
result = om.minimize(fun, params=np.array([1, 2, 3]), algorithm="scipy_lbfgsb")
result.params.round(9) # np.array([0., 0., 0.])
Documentation
You find the documentation at https://optimagic.readthedocs.io with tutorials and how-to guides.
Changes
Consult the release notes to find out about what is new.
License
optimagic is distributed under the terms of the MIT license.
Citation
If you use optimagic for your research, please cite it with the following key to help others discover the tool.
@Unpublished{Gabler2024,
Title = {optimagic: A library for nonlinear optimization},
Author = {Janos Gabler},
Year = {2022},
Url = {https://github.com/optimagic-dev/optimagic}
}
Acknowledgment
We thank all institutions that have funded or supported optimagic (formerly estimagic).
<table> <tc> <td><img src="docs/source/_static/images/numfocus_logo.png" width="200"></td> <td><img src="docs/source/_static/images/aai-institute-logo.svg" width="185"></td> <td><img src="docs/source/_static/images/tra_logo.png" width="240"></td> <td><img src="docs/source/_static/images/hoover_logo.png" width="192"></td> </tc> </table>Related Skills
node-connect
345.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
106.4kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
106.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
345.9kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
