Scipy.optimize Inequality Constraint - Which side of inequality is considered?

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.

+4
source share
1 answer

https://docs.scipy.org/doc/scipy-0.18.1/reference/tutorial/optimize.html (), ,

:

enter image description here

C_j(x) >= 0.

,

def constraint1(x):
    return x[0]+x[1]+x[2]+x[3]-1

con1 = {'type': 'ineq', 'fun': constraint1}

, x[0]+x[1]+x[2]+x[3]-1>=0, .. x[0]+x[1]+x[2]+x[3]>=1

+6

Source: https://habr.com/ru/post/1670106/


All Articles