Scipy minimize: How to pass args to both the objective and the constraint
问题 My MWE is as follows def obj(e, p): S = f(e) + g(p) return S I would like to minimize this function over only e and pass p as an argument to the function. However, I also would like a constraint that depends on p and e that is of the form p + e < 1 I tried cons = {'type': 'ineq', 'fun': lambda e, p: -e -p + 1, 'args': (p)} And then, I try to minimize this for the case of p = 0.5 minimize(obj, initial_guess, method = 'SLSQP', args = 0.5, constraints = cons) but this doesn't work. I get the