optipoly


Nameoptipoly JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryAn NLP solver for box-constrained optimization of polynomial cost functions
upload_time2024-11-12 14:00:32
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords nonlinear programming optimization derivative free constrained optimization multi-variate polynomial
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # optipoly

`optipoly` is a non conventional optimizer dedicated to the optimization
of multi-variate polynomial cost functions on admissible hypercubes. It
leverages the extraordinarily fast computation of scalar polynomials by
the `scipy.interpolation.interp1d` method in oder to derive a robust to
local minima solution of the polynomial optimization problem.

Interested reader can refer to the citation provided 
for a complete description and comparison with some existing solvers.

Here, the main elements are explained briefly for an easy and quick use
of the solver.

## Installation

``` default
pip install optipoly
```

[Full description of the module is available](https://mazenalamir.github.io/optipoly/).

Here a very short presentation is given. 

## The problem addressed

Given a polynomial in several variables of the form:

$$
P(x)=\sum_{i=1}^{n_c}c_i\phi_i(x)\quad \text{where} \quad \phi_i(x):=\prod_{j=1}^n x_j^{p_ij}
$$

Assume that we want to find the minimum value of the polynomial over some hyper box defined by `xmin`and `xmax`, namely

$$
\min_{x} P(x) \quad \text{$\vert\quad x\in [x_\text{min}, x_\text{max}]\subset \mathbb R^n$}
$$

This is the kind of porblem `optipoly` is done for. 

> **Tip**
> 
> Using specific choice of the call inputs, `optipoly`can be used as well to find a maximum or to find a root of the polynomial.
>

[Full description of the module is available](https://mazenalamir.github.io/optipoly/).

## Example of use

Consider the polynomial in three variables defined by:

$$
P(x) = x_1x_3^2+2x_2^3
$$

An instance of the class `Pol` that represent this polynomial can be created via the following script:

```python 
from optipoly import Pol

# Define the matrix of powers and c.
 
powers = [[1, 0, 2], [0,3,0]] 
coefs = [1.0, 2.0]            

# Create an instance of the class.

pol = Pol(powers, coefs)      
```

The following script gives an example of a call that asks for the maximization of the polynomial defined earlier (see @eq-examplePx) then prints the results so obtained:

```python
nx = 3
x0 = np.zeros(nx)
ntrials = 6
ngrid = 1000
xmin = -1*np.ones(nx)
xmax = 2*np.ones(nx)

solution, cpu = pol.solve(x0=x0, 
                          xmin=xmin, 
                          xmax=xmax, 
                          ngrid=ngrid, 
                          Ntrials=ntrials, 
                          psi=lambda v:-v
                          )
                          
print(f'xopt = {solution.x}')
print(f'fopt = {solution.f}')
print(f'computation time = {solution.cpu}')

>> xopt = [-1.  2.  0.]
>> fopt = 16.0
>> computation time = 0.0046999454498291016
```

Changing the argument `psi`to `psi=lambda v:abs(v)` asks the solver to zero the polynomial and hence, leads to the following results:

```python
>> xopt = [-0.996997    0.58858859  0.63963964]
>> fopt = -9.305087356087371e-05
>> computation time = 0.003011941909790039
```

Finally, using the default definition leads to `solve` trying to find a minimum of the polynomial leading to:

```python 
>> xopt = [-1. -1.  2.]
>> fopt = -6.0
>> computation time = 0.005150318145751953
```

[Full description of the module is available](https://mazenalamir.github.io/optipoly/).

## Citing optipoly

``` bibtex
@misc{optipoly2024,
      title={optipoly: A Python package for boxed-constrained multi-variable polynomial cost functions optimization}, 
      author={Mazen Alamir},
      year={2024},
      eprint={5987757},
      archivePrefix={arXiv},
      primaryClass={eess.SY},
      url={https://arxiv.org/submit/5987757}, 
}
```


> **Tip**
>
> The above reference contains some comparison with alternative solver
> that underlines the performance of `optipoly` in terms of the achieved
> cost as well as in terms of the compuation time.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "optipoly",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "Nonlinear Programming, optimization, derivative free, constrained optimization, multi-variate polynomial",
    "author": null,
    "author_email": "Mazen Alamir <mazen.alamir@grenoble-inp.fr>",
    "download_url": "https://files.pythonhosted.org/packages/1e/6c/2eb7b17d08e384618563589e2fc15a24d6ccac56bd41276add471ac3e5ca/optipoly-0.0.2.tar.gz",
    "platform": null,
    "description": "# optipoly\n\n`optipoly` is a non conventional optimizer dedicated to the optimization\nof multi-variate polynomial cost functions on admissible hypercubes. It\nleverages the extraordinarily fast computation of scalar polynomials by\nthe `scipy.interpolation.interp1d` method in oder to derive a robust to\nlocal minima solution of the polynomial optimization problem.\n\nInterested reader can refer to the citation provided \nfor a complete description and comparison with some existing solvers.\n\nHere, the main elements are explained briefly for an easy and quick use\nof the solver.\n\n## Installation\n\n``` default\npip install optipoly\n```\n\n[Full description of the module is available](https://mazenalamir.github.io/optipoly/).\n\nHere a very short presentation is given. \n\n## The problem addressed\n\nGiven a polynomial in several variables of the form:\n\n$$\nP(x)=\\sum_{i=1}^{n_c}c_i\\phi_i(x)\\quad \\text{where} \\quad \\phi_i(x):=\\prod_{j=1}^n x_j^{p_ij}\n$$\n\nAssume that we want to find the minimum value of the polynomial over some hyper box defined by `xmin`and `xmax`, namely\n\n$$\n\\min_{x} P(x) \\quad \\text{$\\vert\\quad x\\in [x_\\text{min}, x_\\text{max}]\\subset \\mathbb R^n$}\n$$\n\nThis is the kind of porblem `optipoly` is done for. \n\n> **Tip**\n> \n> Using specific choice of the call inputs, `optipoly`can be used as well to find a maximum or to find a root of the polynomial.\n>\n\n[Full description of the module is available](https://mazenalamir.github.io/optipoly/).\n\n## Example of use\n\nConsider the polynomial in three variables defined by:\n\n$$\nP(x) = x_1x_3^2+2x_2^3\n$$\n\nAn instance of the class `Pol` that represent this polynomial can be created via the following script:\n\n```python \nfrom optipoly import Pol\n\n# Define the matrix of powers and c.\n \npowers = [[1, 0, 2], [0,3,0]] \ncoefs = [1.0, 2.0]            \n\n# Create an instance of the class.\n\npol = Pol(powers, coefs)      \n```\n\nThe following script gives an example of a call that asks for the maximization of the polynomial defined earlier (see @eq-examplePx) then prints the results so obtained:\n\n```python\nnx = 3\nx0 = np.zeros(nx)\nntrials = 6\nngrid = 1000\nxmin = -1*np.ones(nx)\nxmax = 2*np.ones(nx)\n\nsolution, cpu = pol.solve(x0=x0, \n                          xmin=xmin, \n                          xmax=xmax, \n                          ngrid=ngrid, \n                          Ntrials=ntrials, \n                          psi=lambda v:-v\n                          )\n                          \nprint(f'xopt = {solution.x}')\nprint(f'fopt = {solution.f}')\nprint(f'computation time = {solution.cpu}')\n\n>> xopt = [-1.  2.  0.]\n>> fopt = 16.0\n>> computation time = 0.0046999454498291016\n```\n\nChanging the argument `psi`to `psi=lambda v:abs(v)` asks the solver to zero the polynomial and hence, leads to the following results:\n\n```python\n>> xopt = [-0.996997    0.58858859  0.63963964]\n>> fopt = -9.305087356087371e-05\n>> computation time = 0.003011941909790039\n```\n\nFinally, using the default definition leads to `solve` trying to find a minimum of the polynomial leading to:\n\n```python \n>> xopt = [-1. -1.  2.]\n>> fopt = -6.0\n>> computation time = 0.005150318145751953\n```\n\n[Full description of the module is available](https://mazenalamir.github.io/optipoly/).\n\n## Citing optipoly\n\n``` bibtex\n@misc{optipoly2024,\n      title={optipoly: A Python package for boxed-constrained multi-variable polynomial cost functions optimization}, \n      author={Mazen Alamir},\n      year={2024},\n      eprint={5987757},\n      archivePrefix={arXiv},\n      primaryClass={eess.SY},\n      url={https://arxiv.org/submit/5987757}, \n}\n```\n\n\n> **Tip**\n>\n> The above reference contains some comparison with alternative solver\n> that underlines the performance of `optipoly` in terms of the achieved\n> cost as well as in terms of the compuation time.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "An NLP solver for box-constrained optimization of polynomial cost functions",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/mazenalamir/optipoly",
        "Issues": "https://github.com/mazenalamir/optipoly/issues"
    },
    "split_keywords": [
        "nonlinear programming",
        " optimization",
        " derivative free",
        " constrained optimization",
        " multi-variate polynomial"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3f4b6527fca2ff7132110f8680112ccb37fb4f58c8206e8e4489690179e831e",
                "md5": "ed0494efe2b99a6148e37380ce553593",
                "sha256": "5b648af8d1d8eb0257b3212401cb2259105c26a349cb0e7ef6b6d2f026f7fdad"
            },
            "downloads": -1,
            "filename": "optipoly-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ed0494efe2b99a6148e37380ce553593",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5978,
            "upload_time": "2024-11-12T14:00:30",
            "upload_time_iso_8601": "2024-11-12T14:00:30.706471Z",
            "url": "https://files.pythonhosted.org/packages/b3/f4/b6527fca2ff7132110f8680112ccb37fb4f58c8206e8e4489690179e831e/optipoly-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e6c2eb7b17d08e384618563589e2fc15a24d6ccac56bd41276add471ac3e5ca",
                "md5": "dd7d792ce344f3d5d975448786f607d1",
                "sha256": "a84026952d5a9daa4dcdd1d01b8970d430c91c400ca4fbeba67bbdcdf7d2eb76"
            },
            "downloads": -1,
            "filename": "optipoly-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "dd7d792ce344f3d5d975448786f607d1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5776,
            "upload_time": "2024-11-12T14:00:32",
            "upload_time_iso_8601": "2024-11-12T14:00:32.130336Z",
            "url": "https://files.pythonhosted.org/packages/1e/6c/2eb7b17d08e384618563589e2fc15a24d6ccac56bd41276add471ac3e5ca/optipoly-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-12 14:00:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mazenalamir",
    "github_project": "optipoly",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "optipoly"
}
        
Elapsed time: 0.41141s