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).
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file optimagic-0.5.4.tar.gz.
File metadata
- Download URL: optimagic-0.5.4.tar.gz
- Upload date:
- Size: 412.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf3fd655a60fef0f40c18f81870f30fc1db7ed783a620dcad0bb9526ff6985e7
|
|
| MD5 |
c31e3d4f4044057e848ef809653a0eb3
|
|
| BLAKE2b-256 |
f9bf4e743abaa65147bc3d6d7e93638096a8efed94f9053cdf6039ea57409ac2
|
File details
Details for the file optimagic-0.5.4-py3-none-any.whl.
File metadata
- Download URL: optimagic-0.5.4-py3-none-any.whl
- Upload date:
- Size: 475.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e93d15d39875f36294cb4f138c33c9606b351c0bc0c0194ca6476094406e19e
|
|
| MD5 |
81e4adfa0d4a16525cf401ebe71d95a3
|
|
| BLAKE2b-256 |
7157cab04d396d8818a90e0bedb097826fe28bdb39cb66c937541f38f7547641
|