PySLSQP
PySLSQP: A transparent Python package for the SLSQP optimization algorithm modernized with utilities for visualization and post-processing - Published in JOSS (2024)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 7 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org -
✓Committers with academic emails
1 of 2 committers (50.0%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Repository
A transparent Python interface to the SLSQP optimization algorithm, with advanced features and visualization capabilities.
Basic Info
- Host: GitHub
- Owner: anugrahjo
- License: bsd-3-clause
- Language: Python
- Default Branch: main
- Homepage: https://pyslsqp.readthedocs.io/
- Size: 3.45 MB
Statistics
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 0
- Releases: 4
Topics
Metadata Files
README.md
PySLSQP
<!-- [![PyPI Monthly Downloads][https://img.shields.io/pypi/dm/pyslsqp]][https://pypi.org/project/pyslsqp/] -->
<!--
-->
<!--
-->
<!--
-->
<!--
-->
The SLSQP algorithm is designed to solve nonlinear programming (NLP) problems.
PySLSQP is a Python package that wraps the original SLSQP algorithm
implemented in Fortran by Dieter Kraft.
While the Fortran code is sourced from
scipy.optimize.minimize,
PySLSQP extends its functionality
by offering new features for further analysis of optimization problems,
thereby significantly improving the utility of the original algorithm.
The prebuilt packages for various system architectures are available on PyPI for download,
thus avoiding the need for the user to compile the Fortran sources.
Some of the additional features provided by PySLSQP include:
Data Saving: PySLSQP allows you to save optimization data during the optimization process. This can be useful for analyzing the progress of the optimization, for post-processing purposes, or for warm/hot restart of the optimization.
Warm/Hot Starting: PySLSQP supports warm/hot starting, enabling users to initialize the optimization algorithm with a previously saved solution. This can be particularly useful when you want to restart an optimization from a previous solution or continue an optimization that was terminated for various reasons.
Live Visualization: PySLSQP provides the capability to visualize the optimization progress in real-time, enabling users to monitor the convergence via the optimality and feasibility measures. This also helps the users understand how the objective function, constraints, and design variables are changing during the optimization.
Scaling: PySLSQP allows you to independently scale the objective function, constraints, and design variables, separate from their original definitions. Scaling can help improve the convergence behavior of the optimization algorithm and make it more robust.
More Internal Optimization Variables: PySLSQP provides access to additional internal optimization variables such as optimality, feasibility, Lagrange multipliers, etc. which can be useful for advanced analysis of the optimization problem. In
scipy.optimize.minimize, the original callback function returns only the optimization variables, and only for the major iterations.
These additional features make PySLSQP a powerful tool for solving constrained optimization problems in Python. In addition, PySLSQP also supports the estimation of gradients using first-order finite differencing, as in the Scipy version.
Installation
To install the latest release of PySLSQP on PyPI, run on the terminal or command line
sh
pip install pyslsqp
Warning
Precompiled wheels for common Ubuntu, macOS, and Windows architectures are available on PyPI. However, if a wheel for your system's architecture is not available, the above installation will compile the source distribution directly on your machine. In such scenarios, if your Fortran compilers aren't compatible, you may encounter compilation errors. Additional troubleshooting may be required to resolve these errors depending on their specifics.
To install the latest commit from the main branch, run
sh
pip install git+https://github.com/anugrahjo/PySLSQP.git@main
Note that this installation method will compile the Fortran sources locally on your machine.
Therefore, we only recommend this method if you are a developer looking to modify the package for your own use case.
To upgrade PySLSQP from an older version to the latest released version on PyPI, run
sh
pip install --upgrade pyslsqp
To uninstall PySLSQP, run
sh
pip uninstall pyslsqp
Testing
To test if the package works correctly and as intended, install pytest using
sh
pip install pytest
and run the following line on the terminal from the project's root directory:
sh
pytest -m "not visualize"
Usage
Most features of the PySLSQP package can be accessed through the optimize function.
However, there are some additional utility functions that are available for post-processing.
Here is a small optimization example that minimizes x^2 + y^2.
```python import numpy as np from pyslsqp import optimize
v represents the vector of optimization variables
def objective(v): # the objective function return v[0]2 + v[1]2
x0 = np.array([1., 1.])
optimize() returns a dictionary that contains the results from optimization
results = optimize(x0, obj=objective)
print(results)
``
Note that we did not provide the gradient for the objective function above.
In the absence of user-provided gradients,optimize` estimates the gradients
using first-order finite differencing.
However, it is always more efficient for the user to provide the exact gradients.
Note also that we did not have any constraints or variable bounds in this problem.
Examples with user-defined gradients, constraints, and bounds
can be found in the Basic User Guide.
Documentation
For API reference and more details on installation and usage, visit the documentation.
Citation
If you use PySLSQP in your work, please use the following reference for citation:
@article{joshy2024pyslsqp,
title = {PySLSQP: A transparent Python package for the SLSQP optimization algorithm modernized with utilities for visualization and post-processing},
author = {Anugrah Jo Joshy and John T. Hwang},
journal = {Journal of Open Source Software},
publisher = {The Open Journal},
year = {2024},
volume = {9},
number = {103},
pages = {7246},
url = {https://doi.org/10.21105/joss.07246},
doi = {10.21105/joss.07246},
}
Bugs, feature requests, questions
Please use the GitHub issue tracker for reporting bugs, requesting new features, or any other questions.
Contributing
We always welcome contributions to PySLSQP.
Please refer the CONTRIBUTING.md
file for guidelines on how to contribute.
License
This project is licensed under the terms of the BSD 3-Clause "New" or "Revised" License.
Owner
- Login: anugrahjo
- Kind: user
- Repositories: 1
- Profile: https://github.com/anugrahjo
JOSS Publication
PySLSQP: A transparent Python package for the SLSQP optimization algorithm modernized with utilities for visualization and post-processing
Authors
Department of Mechanical and Aerospace Engineering, University of California San Diego, USA
Department of Mechanical and Aerospace Engineering, University of California San Diego, USA
Tags
SLSQP optimization optimizer algorithmGitHub Events
Total
- Create event: 3
- Release event: 4
- Issues event: 2
- Watch event: 5
- Issue comment event: 1
- Push event: 25
- Pull request review event: 1
- Pull request event: 2
- Fork event: 3
Last Year
- Create event: 3
- Release event: 4
- Issues event: 2
- Watch event: 5
- Issue comment event: 1
- Push event: 25
- Pull request review event: 1
- Pull request event: 2
- Fork event: 3
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| anugrahjo | a****d@g****m | 94 |
| Daniel S. Katz | d****z@i****g | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 3
- Total pull requests: 1
- Average time to close issues: 26 days
- Average time to close pull requests: about 1 hour
- Total issue authors: 3
- Total pull request authors: 1
- Average comments per issue: 3.0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 1
- Average time to close issues: 6 days
- Average time to close pull requests: about 1 hour
- Issue authors: 2
- Pull request authors: 1
- Average comments per issue: 3.5
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- ChRen95 (1)
- msperryucsd (1)
- antonionicampos (1)
Pull Request Authors
- danielskatz (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 431 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 9
- Total maintainers: 1
pypi.org: pyslsqp
A transparent Python interface to the SLSQP optimization algorithm, with advanced features and visualization capabilities.
- Documentation: https://pyslsqp.readthedocs.io/en/latest/
- License: Copyright (c) 2024, Anugrah Jo Joshy. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
Latest release: 0.1.4
published 11 months ago