# How can I minimize this least squares problem with inequality constraints?

I have a least square problem with two different inequality problems. I can not use NNLS because its just solves least square problem with equality and inequality problems or just one inequality constraint.

Can I use NNLS or any other algorithm or R package that I can solve this least square problem?How can I use limSolve package? How can I introduce the G matrix in lsei? Does anyone else have any suggestions?

min|| Ax-b||^2    x = c(c, d, f) is a vector
x >= 0
g(a) = c - d * a + f * a >= 0 which a is a predetermined value

• When you say $x \geq 0$ does this mean each element of $x$ is $\geq 0$? If so, $c + da + fa = c + a(d+f) \geq 0$ as long as $a \geq 0$, so you really only have one constraint. Commented May 28, 2012 at 6:03
• Thanks for your comment, but actually i made a mistake.I have edited my second equation. I know that a>=0. sorry for my typo mistake. Commented May 28, 2012 at 6:11

The $G$ matrix in lsei is such that $Gx \ge h$. So in your case it should be
$$G=\begin{pmatrix} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ 1 & -a & a \end{pmatrix}$$ and $h'=(0,0,0,0)$.
$$G\times\begin{pmatrix}c\\d\\f\end{pmatrix}=\begin{pmatrix}c\\d\\f\\c-ad+af \end{pmatrix}\ge 0=h$$