I use the scipy.optimize module to find optimal input weights that would minimize my output. From the examples I saw, we define a constraint with a one-way equation; then we create a variable of type "inequality". My question is how does the optimization package know if the sum of the variables in my constraint should be less than 1 or greater than 1?
...
def constraint1(x):
return x[0]+x[1]+x[2]+x[3]-1
....
con1 = {'type': 'ineq', 'fun': constraint1}
link to the complete solution that I use in my example:
http://apmonitor.com/che263/index.php/Main/PythonOptimization
Thank.
source
share