Q: Constraint of an unknown type passed to function Hi I am doing a minimization problem and I wanted to try the 'trust-constr' method, with scipy function optimize.minimize, to compare it with the 'SLSQP' results. Unfortunatly I don't know why when I set my method to 'trust-constr', it tells me that :
ValueError: constraint of an unknown type is passed.
The code is the following:
con1 = {'type':'eq', 'fun': eq2}
con2 =  {'type':'ineq', 'fun' : ieq_bck2}
con3 =  {'type':'ineq', 'fun' : ineq_rb2}
con4 =  {'type':'ineq', 'fun' : ls2}

con = ([con1, con2, con3, con4])

scipy.optimize.minimize(fitness2, opt, method = 'trust-constr', jac = 
'cs', hess = h1, constraints = con)

Any idea of how to solve it?

A: According to the Scipy documentation, your variable con must be a dictionary. There is also an example, con must be something like:
cons = ({'type': 'ineq', 'fun': lambda x:  x[0] - 2 * x[1] + 2},
        {'type': 'ineq', 'fun': lambda x: -x[0] - 2 * x[1] + 6},
        {'type': 'ineq', 'fun': lambda x: -x[0] + 2 * x[1] + 2})

So in your case, do this:
con = (con1, con2, con3, con4)

