I have a $m \times n$ matrix $A$, where $n$ is very large and $ n>m$ (underdetermined), and $b$ is $m \times 1$ matrix. I want to minimize $|Ax-b|$, but at most $5$ $x_i$ can be non-zero. Other constraints are that $\sum x_i=1$ and $x_i\geq 0$. So I have set up a mixed interger linear program:
$$\min \sum z_i$$ s.t. $$Ax-b\leq z$$ $$b-Ax\leq z$$ $$\sum x_i=1$$ $$y_i \in\{0,1\}$$ $$\sum y_i=5$$ $$0\leq x_i\leq y_i$$
I'm absolutely clueless as to how to put this into MatLab. Any help would be appreciated.
With the MATLAB Toolbox YALMIP (disclaimer, developed by me), it would be
If you have an integer solver installed, such as intlinprog, it will automatically be used. If you want to see what the intlinprog model looks like to reverse engineer, you can use the command export. As mentioned above though, if you really have a large problem, you would benefit from a better solver such as cplex, gurobi or mosek (all still available via via YALMIP and the same code)
Having said that, the lazy person would let the modelling layer do all the modelling
As asked about in the comments, generate many solutions