Nelder-Mead for numerical optimization in Python
Project description
# neldermead
Nelder-Mead implementation
## Getting Started
### Prerequisites
You need only [NumPy](http://www.numpy.org/) that is the package for scientific computing.
### Installing
Please run the following command.
```bash
$ pip install neldermead
```
## Example
This is a simple example that objective function is sphere function.
```python
import numpy as np
from neldermead import NelderMead
dim = 3
f = lambda x: np.sum(x**2)
simplex = np.zeros([dim, dim + 1])
for i in range(dim + 1):
simplex[:, i] = np.array([np.random.rand() for _ in range(dim)])
nm = NelderMead(dim, f, simplex)
x_best, f_best = nm.optimize(100)
print("x_best:{}, f_best:{}".format(x_best, f_best))
# x_best:[[0.60389863]
# [0.26992676]
# [0.13184699]], f_best:0.45493763222718836
```
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/nmasahiro/neldermead/tags).
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/nmasahiro/neldermead/blob/master/LISENCE) file for details
Nelder-Mead implementation
## Getting Started
### Prerequisites
You need only [NumPy](http://www.numpy.org/) that is the package for scientific computing.
### Installing
Please run the following command.
```bash
$ pip install neldermead
```
## Example
This is a simple example that objective function is sphere function.
```python
import numpy as np
from neldermead import NelderMead
dim = 3
f = lambda x: np.sum(x**2)
simplex = np.zeros([dim, dim + 1])
for i in range(dim + 1):
simplex[:, i] = np.array([np.random.rand() for _ in range(dim)])
nm = NelderMead(dim, f, simplex)
x_best, f_best = nm.optimize(100)
print("x_best:{}, f_best:{}".format(x_best, f_best))
# x_best:[[0.60389863]
# [0.26992676]
# [0.13184699]], f_best:0.45493763222718836
```
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/nmasahiro/neldermead/tags).
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/nmasahiro/neldermead/blob/master/LISENCE) file for details
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
neldermead-0.0.9.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for neldermead-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57c609ea7a519f7448d77cbb625d0c86016ec6d2749876f97be709c5458efa62 |
|
MD5 | bc248141b5ce2beae1f168828c766f46 |
|
BLAKE2b-256 | 759b447f3c17cc7c17a552ad8f66de3b7f5725e768e1b87579424079bf04c50d |