python – how to loop all possible values when using scipy and why scipy does not respect constraints

First I have the simple below constraints + constraint 7 and 8


in my objective function I have constant that are represented as a list and I want to calculate all possible solution with variation of those constants.

So LGSR,LGRS,LGSS,LGPR,LGRP,LGPP represent constants in form of lists with Len=100 and contains random value


LGSR = (2.4,3.4,300.4,...)

my objective if function is to maximize the minimum between two function, so the goal is to find the optimal value for x(0),x(1),x(2).

so I want to test my code with every element of LGSR,LGRS,LGSS,LGPR,LGRP,LGPP (100)

the problem is that i figure out that the index of the for loop is displayed 10000 in my funcion instead of 100 solution.

the second thing is that the optimal solution of x(0) x(1) x(2) does not respect the constraints.

I’m getting negative value

 for x(0) x(1) x(2) instead of 0<x(0)<1, 0<x(1)<10, 0<x(2)<10

the problem look like this with Nr = 1trying to maximize the min of those two function

with the three first contraints this one A'

this constraints

this is my code :

   import numpy as np
from scipy.optimize import fmin_cobyla

import scipy
liste1 = ()

def constr1(x):  
    return 10 - x(1)
def constr2(x):
       return x(1)
def constr3(x):  
  return 10 - x(2)
def constr4(x):
     return x(2)
def constr5(x):  
    return 1 - x(0) 
def constr6(x):
     return x(0)

for i in range(0,len(LGSR)):
  def objective(x,sig=-1): 
        print(i) # more then 100

        return sig*(np.minimum((LGSR(i)*(1-x(0))*x(1))/(LGPR(i)*Pp+1),(LGSS(i)*x(1)+LGRS(i)*x(2)+2*(np.sqrt(LGRS(i)*LGSS(i)*x(0)*x(1)*x(2))))))

  def A_():

    return ((LGPP(i) * Pp )/((((1+LGPP(i)*Pp)**(1-to))-1)))
  def constr7(x):
    Res = (A_()-1)/(LGRP(i)*x(2))
    if Res > 0 : 
        return Res
  def constr8(x):
    res1 = (A_()-1)
    Res = res1-(LGRP(i)*x(2))
    return Res

  a= fmin_cobyla(objective, (0.5,5,6), (constr1, constr2,constr3,constr4,constr5,constr6,constr7,constr8), rhoend=1e-7)