This provides the SOLNP optimizaiton Algorithm.
Reason this release was yanked:
Release 2021.1.27 will not install correctly on many platforms
Project description
See full documentation on http://solnp.readthedocs.io.
pysolnp - Nonlinear optimization with the augmented Lagrange method
Description
SOLNP solves the general nonlinear optimization problem on the form:
minimize f(x)
subject to
g(x) = e_x
l_h <= h(x) <= u_h
l_x < x < u_X
where f(x), g(x) and h(x) are smooth functions.
Compatability
Precompiled Wheels are available for CPython:
- Windows: Python 2.7, 3.6+
- Linux: Python 2.7, 3.5+
- Mac OS: Python 2.7, 3.5+
For other systems, or to have BLAS and LAPACK support, please build the wheels manually. Note: For best results, building it from source is recommended, as BLAS and LAPACK will make a difference.
Installation
Simply install the package through PyPi with:
pip install pysolnp
When compiling from source code you will need CMake.
See the README for the C++ code for details.
Usage
Below is the Box example, for the complete example see /python_examples/example_box.py.
import pysolnp
def f_objective_function(x):
return -1 * x[0] * x[1] * x[2]
def g_equality_constraint_function(x):
return [4 * x[0] * x[1] + 2 * x[1] * x[2] + 2 * x[2] * x[0]]
x_starting_point = [1.1, 1.1, 9.0]
x_l = [1.0, 1.0, 1.0]
x_u = [10.0, 10.0, 10.0]
e_x = [100]
result = pysolnp.solve(
obj_func=f_objective_function,
par_start_value=x_starting_point,
par_lower_limit=x_l,
par_upper_limit=x_u,
eq_func=g_equality_constraint_function,
eq_values=e_x)
result.solve_value
result.optimum
result.callbacks
Output:
>>> result.solve_value
-48.11252206814995
>>> result.optimum
[2.8867750707815447, 2.8867750713194273, 5.773407748939196]
>>> result.callbacks
118
Parameters
The basic signature is:
solve(obj_func: function, par_start_value: List, par_lower_limit: object = None, par_upper_limit: object = None, eq_func: object = None, eq_values: object = None, ineq_func: object = None, ineq_lower_bounds: object = None, ineq_upper_bounds: object = None, rho: float = 1.0, max_major_iter: int = 10, max_minor_iter: int = 10, delta: float = 1e-05, tolerance: float = 0.0001, debug: bool = False) -> pysolnp.Result
Inputs:
Parameter | Type | Default value* | Description |
---|---|---|---|
obj_func | Callable[List, float] | - | The objective function f(x) to minimize. |
par_start_value | List | - | The starting parameter x_0. |
par_lower_limit | List | None | The parameter lower limit x_l. |
par_upper_limit | List | None | The parameter upper limit x_u. |
eq_func | Callable[List, float] | None | The equality constraint function h(x). |
eq_values | List | None | The equality constraint values e_x. |
ineq_func | Callable[List, float] | None | The inequality constraint function g(x). |
ineq_lower_bounds | List | None | The inequality constraint lower limit g_l. |
ineq_upper_bounds | List | None | The inequality constraint upper limit g_l. |
rho | float | 1.0 | Penalty weighting scalar for infeasability in the augmented objective function.** |
max_major_iter | int | 400 | Maximum number of outer iterations. |
max_minor_iter | int | 800 | Maximum number of inner iterations. |
delta | float | 1e-07 | Step-size for forward differentiation. |
tolerance | float | 1e-08 | Relative tolerance on optimality. |
debug | bool | False | If set to true some debug output will be printed. |
*Defaults for configuration parameters are based on the defaults for Rsolnp.
**Higher values means the solution will bring the solution into the feasible region with higher weight. Very high values might lead to numerical ill conditioning or slow down convergence.
Output:
The function returns the pysolnp.Result
with the below properties.
Property | Type | Description |
---|---|---|
solve_value | float | The value of the objective function at optimum f(x*). |
optimum | List[float] | A list of parameters for the optimum x*. |
callbacks | int | Number of callbacks done to find this optimum. |
Use-cases and Applications
- NMPC - Nonlinear model predictive controls-case studies using Matlab, REXYGEN and pysolnp NLP solver under Python environment by Štěpán Ožana. [NMPC Overhead Crane (PDF)] [GitHub Source Code] [Štěpán's Homepage]
Authors
- Krister S Jakobsson - Implementation - krister.s.jakobsson@gmail.com
License
This project is licensed under the Boost License - see the license file for details.
Acknowledgments
- Yinyu Ye - Publisher and mastermind behind the original SOLNP algorithm, Original Sources
- Alexios Ghalanos and Stefan Theussl - The people behind RSOLNP, Github repository
- Davis King - The mastermind behind Dlib, check out his blog! Blog
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pysolnp-2021.1.27-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a63b887708aa4bb0e76c02fd6bbc1237401f36919af0e6aca83059f099b4afab |
|
MD5 | c347313ade8fd042b15c36d9f4221d09 |
|
BLAKE2b-256 | 3943f98cb9b3d91ae6f4dbc86e6cf44b70a540f3e9956e8c86321d04eed2bfe5 |
Hashes for pysolnp-2021.1.27-cp39-cp39-manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02553122cec05eb14886960dcd9a81aeefd0b3e846e1a8c9b2c25272141fb0d7 |
|
MD5 | 8b20fa0c68c2c142829e6cc43d823da4 |
|
BLAKE2b-256 | 1410a374f39848198961ad4e72a90ba1cfc7422795a72b56ca5474ce27e6d5d3 |
Hashes for pysolnp-2021.1.27-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f0354f349450bba7f9b7dcd274ab3c0d2a1b6dd18d82370e4e5b200bfcc460c |
|
MD5 | e4343de65e6e6bff5d14698115fe3d26 |
|
BLAKE2b-256 | caff9f3008c73324de6a149b5e39b1f2898c4c2255fff33a8443843dc9705ea9 |
Hashes for pysolnp-2021.1.27-cp38-cp38-manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a76653c06ce9caa5b671b751946dd6000f14f43e7afea840fcb2e6e520f02f44 |
|
MD5 | 956abd9fb373a130b568962326e04ee2 |
|
BLAKE2b-256 | 2b1fb7550d28ecad065766e927dd57985d42039fb2334d8645748cb026b451be |
Hashes for pysolnp-2021.1.27-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5907ebaf8fcf4983fdb483b71c652aed8efa778a87c1b656999986962718785 |
|
MD5 | 8012503a396f9207a82b7b637c58dc66 |
|
BLAKE2b-256 | 97b5f4efa434bbc7d459a9ebf0315d89cb2e949f80eb15f97f9f7f2de8047828 |
Hashes for pysolnp-2021.1.27-cp37-cp37m-manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efe19b3fefa95838d4e73919fe411e4e72e90d3e292a756b8a7fb3967b744363 |
|
MD5 | bdd8fc8ef9d1db2ad5039fba4168a3da |
|
BLAKE2b-256 | 07b9e28f8a9645e97a87e0eed4930cd791eb849f306561c636ff2c6578007c80 |
Hashes for pysolnp-2021.1.27-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52eb333087197c86314be338106ce557f6a59f270cb82a23d307e64ad2807ff6 |
|
MD5 | 159717321fa0f067197fba3d5f4a0b50 |
|
BLAKE2b-256 | 59b81ebfbfe27526e63d3660e00c023aa62826d869f4d51fe5f345fb4b1ab6dd |
Hashes for pysolnp-2021.1.27-cp36-cp36m-manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 637e01bd8f5ce31630f8b9d0bf503180e6aac35be1db768a0f6b95bf0ee9466e |
|
MD5 | f03cb312c467215fdcb40d74ea4a41ef |
|
BLAKE2b-256 | 81944323a9591282314dcbb9b9e7404c64f95b6e52ce88bd17ae7f0a2b964483 |
Hashes for pysolnp-2021.1.27-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c18f9d657bb12d4d26b2ed6157b2031dc6b74a017903d365694ba998f68b687 |
|
MD5 | 23daee45eca75554b6238726835a843d |
|
BLAKE2b-256 | 3a14a89027ac4ad70171e64154d069db1f1f9fcd06e718480b171bc0fe84ed2b |
Hashes for pysolnp-2021.1.27-cp35-cp35m-manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44fecea4dc8cc34b3885e3e1c3055bd5859b0641af880a8dcc039192ea01e227 |
|
MD5 | f898592017121c5088b8f0a146c99912 |
|
BLAKE2b-256 | 99f75587808be34f46bbe280cc03b57a0dfbd75cea33a5e5a58cbbd3a46bf8f8 |