optimagic-dev/optimagic

GitHub: optimagic-dev/optimagic

optimagic 是一个兼容 SciPy API 的 Python 数值优化统一接口,集成多种优化器并提供诊断、并行导数和统计推断功能。

Stars: 317 | Forks: 52

optimagic

[![PyPI](https://raw.githubusercontent.com/optimagic-dev/optimagic/main/)](https://pypi.org/project/optimagic) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/optimagic)](https://pypi.org/project/optimagic) [![image](https://img.shields.io/conda/vn/conda-forge/optimagic.svg)](https://anaconda.org/conda-forge/optimagic) [![image](https://img.shields.io/conda/pn/conda-forge/optimagic.svg)](https://anaconda.org/conda-forge/optimagic) [![PyPI - License](https://img.shields.io/pypi/l/optimagic)](https://pypi.org/project/optimagic) [![image](https://readthedocs.org/projects/optimagic/badge/?version=latest)](https://optimagic.readthedocs.io/en/latest) [![image](https://img.shields.io/github/actions/workflow/status/optimagic-dev/optimagic/main.yml?branch=main)](https://github.com/optimagic-dev/optimagic/actions?query=branch%3Amain) [![image](https://codecov.io/gh/optimagic-dev/optimagic/branch/main/graph/badge.svg)](https://codecov.io/gh/optimagic-dev/optimagic) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/optimagic-dev/optimagic/main.svg)](https://results.pre-commit.ci/latest/github/optimagic-dev/optimagic/main) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Downloads](https://pepy.tech/badge/optimagic/month)](https://pepy.tech/project/optimagic) [![NumFOCUS](https://img.shields.io/badge/NumFOCUS-affiliated%20project-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](https://numfocus.org/sponsored-projects/affiliated-projects) optimagic 是一个用于数值优化的 Python 包。它提供了到 SciPy、NlOpt 以及许多其他 Python 包的优化器的统一接口。其特性包括: - **兼容 SciPy 的 API。** optimagic 的 `minimize` 函数与 SciPy 的用法一致,因此您无需调整代码。您无需额外操作即可获得更多优化器。 - **强大的诊断工具。** 可视化优化器历史、比较运行结果并诊断收敛问题。 - **并行数值导数。** 支持并行计算梯度、雅可比矩阵和海森矩阵。 - **带边界、约束和无约束优化。** 支持边界、线性约束、非线性约束、固定参数等。 - **估计参数的统计推断。** estimagic 子包提供置信区间、标准误和 p 值的功能。 # 安装说明 optimagic 可在 [PyPI](https://pypi.org/project/optimagic) 和 [conda-forge](https://anaconda.org/conda-forge/optimagic) 上获取。使用以下命令安装该包: ``` $ pip install optimagic ``` 或 ``` $ conda install -c conda-forge optimagic ``` optimagic 开箱即用地支持所有 scipy 优化器。如果您安装可选包,还可获得其他算法。有关所有支持的优化器以及如何启用它们的概述,请参阅[算法列表](https://optimagic.readthedocs.io/en/latest/algorithms.html)。 # 用法 ``` 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.]) ``` # 文档 您可以在 上找到文档,包括[教程](https://optimagic.readthedocs.io/en/latest/tutorials/index.html)和[操作指南](https://optimagic.readthedocs.io/en/latest/how_to/index.html)。 # 变更记录 请查阅[发行说明](https://optimagic.readthedocs.io/en/latest/development/changes.html)以了解新增内容。 # 许可证 optimagic 采用 [MIT 许可证](LICENSE) 进行分发。 # 引用 如果您在研究中使用了 optimagic,请使用以下密钥引用它,以帮助其他人发现该工具。 ``` @Unpublished{Gabler2024, Title = {optimagic: A library for nonlinear optimization}, Author = {Janos Gabler}, Year = {2022}, Url = {https://github.com/optimagic-dev/optimagic} } ``` # 致谢 我们感谢所有资助或支持 optimagic(原名 estimagic)的机构。
标签:NlOpt, Python, SciPy, 优化包, 优化器, 优化算法, 并行计算, 数值优化, 数值导数, 无后门, 统一接口, 诊断工具, 逆向工具