Let $A$ be a real $m \times n$ matrix. The Lasso optimization problem is $$ \text{minimize} \quad \frac12 \| Ax - b \|_2^2 + \lambda \| x \|_1 $$ The optimization variable is $x \in \mathbb R^n$.
The $\ell_1$-norm regularization term encourages $x$ to be sparse, so Lasso is useful for finding a sparse vector $x$ that satisfies $Ax \approx b$. The parameter $\lambda > 0$ controls how sparse the solution to the Lasso problem is.
Question: Suppose I know that I would like for the solution to the Lasso problem to have exactly $p$ nonzero entries. Are there any techniques or tricks or heuristics for choosing a value of $\lambda$ such that the solution to the Lasso problem has exactly (or at least approximately) $p$ nonzero entries?