In lasso, we have a regularization term in the loss function:
$$\sum \|y-\hat{y}\|_{2} + \lambda \sum\|\beta\|_{1}$$
As the loss function is minimized, some $\beta$'s will become zero. That's what people refer to as 'sparsity'
My question is : how to add a hard constraint for 'max number of non-zero beta' , say, 10?
I suppose this is a mixed-integer programming problem: we introduce a temporary variable $s$, which only takes value of $\{0, 1\}$, so we have an extra constraint $\sum s = 10$ . Afterward, we will have $\beta = \beta_{\rm raw} \cdot s$.
Then I got stuck, how to constraint $\beta_{\rm raw}$ ?
Any insight?