I get NaN as the solver output even when the the solution status says 'Successfully Solved (MOSEK)'

66 views
Skip to first unread message

Syed Adnan Akhtar

unread,
Jan 12, 2020, 7:55:05 AM1/12/20
to YALMIP
HI!

I am trying to set up a function that solves a least square problem without constraints using Yalmip. However, I get a vector containing some NaNs as the output from Mosek/Yalmip. Following is the code:


Z = [0.0100
         0
    0.0300
         0
         0
         0
    0.0456
   -0.1047
         0
         0
         0
         0
         0
         0
         0
         0
    0.0300
         0
    0.0900
         0
         0
         0
    0.1367
   -0.3142
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
    0.0456
         0
    0.1367
         0
         0
         0
    0.2077
   -0.4772
   -0.1047
         0
   -0.3142
         0
         0
         0
   -0.4772
    1.0968];

F_T = 3.0607;

thetaHat = sdpvar(64,1);
residuals = F_T - Z*thetaHat;
optimize([],norm(residuals,2))
theta = value(thetaHat);


Mosek returns this:
yalmipversion: '20190425'
yalmiptime: 1.4075
solvertime: 0.2735
info: 'Successfully solved (MOSEK)'
problem: 0


I know here I have just used one data point. But I have to call this function again and again, with successively one more data point than before. Could anyone help me with why is MOSEK returning NaN even when solution status is SOLVED? Thanks!

Johan Löfberg

unread,
Jan 12, 2020, 8:18:33 AM1/12/20
to YALMIP
Since Z has many zero rows, there are many variables in theta which aren't used in the optimization problem. Hence they can be set o what ever you want. You are solving a problem like this

sdpvar x y
optimize
([],(x-1)^2)

and then noting that y does not have a specified value. You can assign y any want you want

Having said that, the dimensions you claim cannot be correct as both Z and theta are column vectors in your code

Syed Adnan Akhtar

unread,
Jan 12, 2020, 11:24:58 AM1/12/20
to YALMIP
Thanks, Johan for your prompt reply!

I am sorry, I missed the transpose in Z. You are right, its a row vector indeed. So I can change the NaN to whatever I want since the norm of the residual doesn't really change with those values. Thanks for your answer.
Reply all
Reply to author
Forward
0 new messages