Skip to main content

Solving Least Squares yields wrong result



1 comment

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Yannic,

    Least squares problems can achieve negative values and even be unbounded.This can be found in, e.g., Boyd's Convex Optimization book (Example 3.9 on page 81).

    In your case, the unboundedness is very likely caused by the numerics of your model (assuming that the problem defined by your \(\texttt{A}\) matrix is indeed bounded). The quadratic ranges are pretty large

    Objective range [3e+01, 3e+04]
    QObjective range [8e-01, 3e+05]

    and the coefficients have a lot of seemingly significant digits, given their rather large order of magnitude.

    You could try reformulating your model as

    \[\begin{align}\min_{z_i,x_i} &\sum w_i \cdot z_i^2 \\
      \text{s.t.  } &z_i = a_i^T x - b_i \quad \forall i \end{align}\]

    which might help in tackling the numerical issues.

    Best regards,


Please sign in to leave a comment.