alexblaessle / constrNMPy

A Python package for constrained Nelder-Mead optimization.
GNU General Public License v3.0
11 stars 2 forks source link

Use of a constraint beside the bounds for the variables #6

Open emmaparker96 opened 4 years ago

emmaparker96 commented 4 years ago

Besides the lower and upper bounds for the variables, I also have a constraint, that the sum of the variables must be limited to a certain value.

In scipy I would define it as follows:

x0=[2.5,2.5]
cons = {'type':'eq', 'fun':lambda x0: 5 - sum(x0)}

How can this be realized with the package?

alexblaessle commented 4 years ago

Hey,

Good question. I haven't tried nor implemented giving implicit constraints yet. I assume that when you are giving these constraints, you are not using a Nelder-Mead algorithm in scipy?

Cheers

emmaparker96 commented 4 years ago

Hi,

Thanks for the answer, then I will continue looking for alternatives. I tried the COBYLA and SLSQP algorithms in Scipy, but could not get optimal results. I looked for an alternative and ended up with this project.

Cheers

alexblaessle commented 4 years ago

Ah, alright. Have you looked into IP methods?

https://docs.scipy.org/doc/scipy/reference/optimize.linprog-interior-point.html https://github.com/jkaardal/pyipm

The problem is that this package transforms the boundaries in such a way that the objectiv function becomes unconstrained. Doing this for implicit functions is a bit tricky and I don't have much time to implement this besides work right now.