Least-squares example. #613
Replies: 2 comments 1 reply
-
If I understand your comment correctly, I think the issue is that what you describe is modelling the first of the problems at the link you gave, i.e. the one where That's completely fine to do in the solver, and as you say you just need to expand the quadratic expression into The suggestion though is to model it as the second problem, with variables The reason we suggest to do it that way is that 1) it avoids computing the product |
Beta Was this translation helpful? Give feedback.
-
Yes, this can make a really big difference for many problems. An extreme example would be one where |
Beta Was this translation helpful? Give feedback.
-
I am sorry if I am saying something silly. :-)
I am taking a look at the "Least-squares example", here:
https://osqp.org/docs/examples/least-squares.html
Looking at the python code, I can see that the$A$ matrix. Maybe we could give the problem matrix a different name, by the way. I will use $B$ for the problem's matrix.
Ad
variable is the problem'sI do not understand, in the code, why$\frac{1}{2} y^Ty$ , where $y = (Bx - b)$ . Implies that we want to minimize
P
andA
were constructed the way they were. As far as I understand, problem translation to "minimizeWe can ignore$b^Tb$ , because it is constant. And since $x^TA^Tb$ is $1 \times 1$ , you can transpose it to conclude that we want to minimize
That is,$q = 2b^TB$ and $P = B^TB$ .
I think that instead of solving for$x$ , the example is solving for $(x, b)$ , so the example code constructs
$B' = \begin{bmatrix}B & -I \\ I & 0\end{bmatrix}$.
But this matrix is called
A
in the code!?!? Which does not seems correct. Probably it should beP
.Also, the$(x,b)$ and produces the constant $(0,b)$ .
P
matrix in the code does not seem really useful, because it takesI am getting anything wrong?
Beta Was this translation helpful? Give feedback.
All reactions