How to define summation type equation as constraints in Python optimization

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How to define summation type equation as constraints in Python optimization



I was trying to solve a optimization problem using scipy package of python. But i don't know how to represent summation type equation as constraints and how to pass those constraint as argumnet to minimize function.



The equation is the following :



∑ (Xrij + Xrji) - Yri >= 0,∀r,i



j∈V



For r=2, V=5 and i=5
I expanded the equation And defined every equation as separate constraint.



x[1][1][1]+ x[1][1][1]+ x[1][1][2]+ x[1][2][1]+ x[1][1][3]+ x[1][3][1]+ x[1][1][4]+ x[1][4][1]+ x[1][1][5]+ x[1][5][1] - y[1][1] >= 0



x[1][2][1]+ x[1][1][2]+ x[1][2][2]+ x[1][2][2]+ x[1][2][3]+ x[1][3][2]+ x[1][2][4]+ x[1][4][2]+ x[1][2][5]+ x[1][5][2] - y[1][2] >= 0



x[1][3][1]+ x[1][1][3]+ x[1][3][2]+ x[1][2][3]+ x[1][3][3]+ x[1][3][3]+ x[1][3][4]+ x[1][4][3]+ x[1][3][5]+ x[1][5][3] - y[1][3] >= 0



x[1][4][1]+ x[1][1][4]+ x[1][4][2]+ x[1][2][4]+ x[1][4][3]+ x[1][3][4]+ x[1][4][4]+ x[1][4][4]+ x[1][4][5]+ x[1][5][4] - y[1][4] >= 0



x[1][5][1]+ x[1][1][5]+ x[1][5][2]+ x[1][2][5]+ x[1][5][3]+ x[1][3][5]+ x[1][5][4]+ x[1][4][5]+ x[1][5][5]+ x[1][5][5] - y[1][5] >= 0



x[2][1][1]+ x[2][1][1]+ x[2][1][2]+ x[2][2][1]+ x[2][1][3]+ x[2][3][1]+ x[2][1][4]+ x[2][4][1]+ x[2][1][5]+ x[2][5][1] - y[2][1] >= 0



x[2][2][1]+ x[2][1][2]+ x[2][2][2]+ x[2][2][2]+ x[2][2][3]+ x[2][3][2]+ x[2][2][4]+ x[2][4][2]+ x[2][2][5]+ x[2][5][2] - y[2][2] >= 0



x[2][3][1]+ x[2][1][3]+ x[2][3][2]+ x[2][2][3]+ x[2][3][3]+ x[2][3][3]+ x[2][3][4]+ x[2][4][3]+ x[2][3][5]+ x[2][5][3] - y[2][3] >= 0



x[2][4][1]+ x[2][1][4]+ x[2][4][2]+ x[2][2][4]+ x[2][4][3]+ x[2][3][4]+ x[2][4][4]+ x[2][4][4]+ x[2][4][5]+ x[2][5][4] - y[2][4] >= 0



x[2][5][1]+ x[2][1][5]+ x[2][5][2]+ x[2][2][5]+ x[2][5][3]+ x[2][3][5]+ x[2][5][4]+ x[2][4][5]+ x[2][5][5]+ x[2][5][5] - y[2][5] >= 0





What have you tried so far?
– Lorelorelore
19 mins ago





For r=2, V=5 and i=5 I expanded the equation And defined every equation as separate constraint.
– Rishabh Garg
8 mins ago





Please add this line as an edit to the question.
– Lorelorelore
8 mins ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived