I tried to solve a linear least square problem in Gurobi as follows:
# A, b are numpy arrays
n1, n2 = A.shape # shape of b is (n1,)
m = gp.Model()
x = m.addMVar(shape=n2, lb=float('-inf'))
Q = A.T @ A
c = -2 * b.T @ A
obj = x @ Q @ x + c @ x + b.T @ b
While this works for small examples, it fails for specific larger arrays (n1 = 71002, n2=502) with the error
Numerical trouble encountered
Model may be infeasible or unbounded. Consider using the
homogeneous algorithm (through parameter 'BarHomogeneous')
m.Params.BarHomogeneous = 1
yields the error "Unbounded model". But by definition of the least squares problem, the objective function can obviously not be negative.
Any ideas what happens here? Can floating point errors in the computation of Q and c modify the formulation such that it is unbounded? Thanks for help.
Edit: Here are the arrays A and b: https://www.dropbox.com/sh/ngzfdh2pofelizu/AAAXOS1rHyXMV27Hc2_fEQRNa?dl=0
Please sign in to leave a comment.