'Adding multiple generalised constraint equalities in SciPy optimization
I've been having some success using Scipy for optimization problems in Python lately. So far, I've been using scipy.optimize.minimize to minimize an objective function. I've also been adding additional constraints to my model, which has all worked fine so far.
I have hit a point that is causing me a bit of confusion, however. I'd like to add an equality constraint to my problem, which can be described as a function of x, ie f(x). Let's say for the sake of example that f(x) is of the form f(x) = mx + c, wherein I know what the parameters m and c are. In reality, I actually have multiple equality constraints that all follow the same general form of f(x), with m and x known apriori for each of the constraints.
I know how to add a single function f(x) to my optimizer, however, I'm not sure how to do it for multiple occurrences of f(x). I had thought about defining m and c as arrays of the specific corresponding m and c values that each constraint will use, however, the optimizer does not seem to want to accept this.
Any insight on how to approach this would be appreciated!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
