I am trying to write an optimization code with constraints using SLSQP method. But I can't understand it enough to write the proper codes for constraints.
Lets say we have a function f, with p parameters, all with the same starting values (0.1) and arg
is the array of these parameters:
arg = [.1] * p
Here I want sum(arg[2:])
to be less than 1, and arg[i] > 0
for the optimization. How can i write the constraints/boundaries for scipy.optimize.minimize
:
from scipy.optimize import minimize
minimize( fun = f,
x0 = arg,
method = 'SLSQP',
constraints = ?,
bounds = ?
)