GUROBI ERROR: Element 0 of a double array is Nan or Inf.

3,639 views
Skip to first unread message

Antonio García Borreguero

unread,
Apr 16, 2012, 11:14:34 AM4/16/12
to Gurobi Optimization
I'm having little trouble here. i can recognize i'm totally clueless
with Gurobi so hope you can enlight me :)

Im doing an enhance of a MATLAB-GUROBI code but now im using the 64
bits releases of them instead of the 32 ones on the original code.
When my code call gurobi the next trace appears:

Gurobi Mex Version 1.61. Gurobi Library Version 4.6.1.
Check input & ouput.
Call GRBloadenv.
Check and set options.
Convert input data ... Converted
Call GRBloadmodel.
GUROBI ERROR: Element 0 of a double array is Nan or Inf.


i got 2011b MATLAB, Gurobi 1.61 as you can see above, Windows 7. All
of them for 64 bits.

Anyone have any information about where i can track that error, i
tried google (GUROBI ERROR: Element 0 of a double array is Nan or
Inf.) with no succes at all.

Thanks a lot and sorry for my bad English. I'm pretty stuck

Christopher Maes

unread,
Apr 16, 2012, 1:34:18 PM4/16/12
to gur...@googlegroups.com
> GUROBI ERROR: Element 0 of a double array is Nan or Inf.

Hi Antonio,

This error indicates that you have a NaN or Inf in one of the columns
of the constraint matrix. You are only allowed to have real numbers in
the constraint matrix. You can find the row and column index of the
bad coefficient in the matrix by issuing the following command in
Matlab:

>> [i, j, v] = find(isnan(A) | isinf(A))

Here A is the constraint matrix.

Chris

Antonio García Borreguero

unread,
Apr 18, 2012, 11:40:14 AM4/18/12
to Gurobi Optimization
Thanks a lot Chris,

Now with your hints i have already tracked down the Inf elements on my
inputs, there is no NaN at all. I have them in the objective
coefficient vector c and in the constraint coefficient matrix A. They
come from a log of zero, imho, but im not sure if is a mistake by me
or i need to run it with these elements aproaching oo. Is there any
way to acomplish that? maybe letting these elemnts being 10E6 or
something like that?¿.

I got like 3k lines matlab code and it's suppoused to work fine so i
dont know if i can track it for a math error. Let me know what you
think.
There is two ways, it can be a mathwork error, in case which i would
have to review all the code, or it can be a 32-bit version-64 bit
version Gurobi ghost for believers. I don't know where side I am right
now.

Thanks again :)

Antonio

Christopher Maes

unread,
Apr 18, 2012, 8:55:37 PM4/18/12
to gur...@googlegroups.com
> Now with your hints i have already tracked down the Inf elements on my
> inputs, there is no NaN at all. I have them in the objective
> coefficient vector c and in the constraint coefficient matrix A. They
> come from a log of zero, imho, but im not sure if is a mistake by me
> or i need to run it with these elements aproaching  oo. Is there any
> way to acomplish that? maybe letting these elemnts being 10E6 or
> something like that?

You can try to replace the infs with a large value like 1e6, but this
could cause your model to be poorly scaled and you might run into
numerical trouble. You should see if you can reformulate the model to
not require coefficients of infinity.

> There is two ways, it can be a mathwork error, in case which i would
> have to review all the code, or it can be a 32-bit version-64 bit
> version Gurobi ghost for believers.

If find(isinf(A)) is returning indices, the problem is in the code
that forms the A matrix. But you should always be careful to be
consistent with MATLAB and Gurobi. That is, if you are using 64 bit
MATLAB you also need to use the 64 bit version of Gurobi.

Good luck!

Chris

Reply all
Reply to author
Forward
0 new messages