In this post a somewhat larger linearly constrained least squares problem is solved using R. The problem is simply:
| \[\begin{align}\min_P&||P s - f||^2\\ & p_{i,j} \ge 0\\ &\sum_i p_{i,j}\le 1\end{align}\] |
To make things easier for the QP solver I implemented the model as:
| \[\begin{align}\min_{P,e}&\sum_i e_i^2\\ & \sum_j p_{i,j} s_j = f_i + e_i\\&p_{i,j} \ge 0\\ &\sum_i p_{i,j}\le1\end{align}\] |
The timings for a problem with \(39 \times 196\) elements in \(P\) are:
| R+constrOptim | 15 hours |
| R+auglag | 2 hours |
| GAMS+IPOPT | 1.2 seconds |
| GAMS+Cplex | 0.15 seconds |
Sometimes it helps to choose the right solver for the problem at hand.