A Python package for constrained Nelder-Mead optimization.
constrNMPy is a Python package that allows to use scipy's fmin
function for constrained problems. It is a reimplementation
of a popular matlab package.
Simply clone this repository via
git clone https://github.com/alexblaessle/constrNMPy.git
and install with
python setup.py install
constrNMPy solely requires
- numpy
- scipy
Using constrNMPy is analogous to other scipy optimization functions, such as fmin
. Let's say we want
to optimize a rosenbrock function with a given range for x
and y
# Define initial guess
x0=[2.5,2.5]
# Define lower and upper bounds (None indicates no bound)
LB=[2,2]
UB=[None,3]
# Call optimizer
import constrNMPy as cNM
res=cNM.constrNM(cNM.test_funcs.rosenbrock,x0,LB,UB,full_output=True)
# Print results
cNM.printDict(res)
More examples are in constrNMPy/examples/
.
To test constrNMPy, simply run
pytest constrNMPy/tests/
The API of can be found here .