2
$\begingroup$

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
$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$
    – Macro
    Commented May 28, 2012 at 6:03
  • $\begingroup$ 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. $\endgroup$ Commented May 28, 2012 at 6:11

1 Answer 1

4
$\begingroup$

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)$.

Then

$$G\times\begin{pmatrix}c\\d\\f\end{pmatrix}=\begin{pmatrix}c\\d\\f\\c-ad+af \end{pmatrix}\ge 0=h$$

and your constraints are satisfied.

$\endgroup$
2
  • $\begingroup$ Thanks for your help, but why the first row of G matrix should be (-1,0, 0). I think it should be (1, 0, 0). Am i right? $\endgroup$ Commented May 28, 2012 at 22:03
  • $\begingroup$ Yes, it is a typo. $\endgroup$
    – mpiktas
    Commented May 29, 2012 at 2:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.