Currently, I am looking for a Nelder-Mead optimizer in python that also accepts bounds and constraints for the variables. Scipy has a Nelder-Mead optimizer, but it does not allow any constraints.
During my search I came across the package constrNMPy, which should make this possible.
Here is an example of how to use constrNMPy:
# 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)
However, this example only explains how to define bounds, but cannot define constraints. In the example above I would like to have the following constraint, so that the variables only accept values where the sum is 5:
cons = {'type':'eq', 'fun':lambda x0: 5 - sum(x0)}
How do I pass this constraint to the constrNM
call?
Or are there other packages for a Nelder-Mead optimizer with constraints?