I am working on an optimization problem, using scipy minimize (method=SLSQP), that uses approx. 700 variables. I am setting minimum and maximum boundaries between 0 and 1.
My issue is that the problem requires only 400 variables to have values greater than 0 (the other 300 must be equal to zero). I do not know precisely which variables are those; otherwise, I would have excluded them. Therefore, I need to somehow create a constraint specifying this.
My problem is how to define the constraint. Any thoughts?
Update: Following a comment from Joni (many thanks). It seems that I need to formulate the problem as mixed-integer linear optimization. I am unfamiliar with it. Any pointers would be appreciated.
Below I provide more details on the intended optimization.
Problem: minimize the difference between the weights of an investor portfolio vs. the weights of a stock index benchmark (with 700 stocks) subject to several constraints (allocation to specific industries, for instance). The difficulty comes in specifying an additional constraint in which the investor only allocates positive weights to 400 stocks, while the remaining 300 must be equal to zero.
objective function --> min ((w -wbenchmark)^2).sum()
boundaries (0,1)
Constraints: --> industry allocations (no problem here)
--> limit number of stock weights with weights greater than zero to max 400 and the remaining 300 equal to zero