Skip to main content

Odd behaviors with NA in the objective function

Answered

Comments

3 comments

  • Ying Zhang
    First Question
    First Comment

    Actually, even if the range of x[0] is none-empty, it still is ignored in mode.objVal.

    0
  • Ying Zhang
    First Question
    First Comment

    Another point is that if instead of doing 

    obj = obj - beta.sum()

    I do

    obj = obj - beta[0] - beta[1],

    then the code does not crash. Again, I am not saying that this is wrong in itself, just that it confuses the debugging effort. 

    0
  • Simon Bowly
    Gurobi Staff Gurobi Staff

    Hi Ying,

    Thanks for reporting this. I agree with you that this is not the right behaviour, really any `nan` values in input data should result in an error when building a model. Evidently there is some inconsistent behaviour: for some cases, gurobipy will raise an exception for invalid data. For some others, it will ignore the invalid coefficients (which are then essentially treated as zero when solving a model or writing it to a file).

    We will fix this in a future release. In the meantime, the best approach is to validate your data beforehand, for example using numpy's isnan.

    0

Please sign in to leave a comment.