Skip to main content

Is it okay to input the coefficient of Gurobi linexpr as str type?

Answered

Comments

2 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Cathy,

    This is an effect of Python's duck typing. The string holding a floating point number will be casted into a floating point number. Please note that even though this works as expected, it is not recommended to use string floats when working with Gurobi objects. The string formating may depend on the machine's locale settings, i.e., on some system the decimal '.' will be a ',' which completely messes up your script. Thus, it is best to turn any string values into floating point numbers before working with them.

    Best regards,
    Jaromił

    0
  • Cathy Jung
    Gurobi-versary
    First Comment
    First Question

    Dear Jaromił,

    thank you very much for the helpful answer. I've modified the relevant lines in the script as you recommended. Thanks!

    Regards,
    Cathy

    0

Please sign in to leave a comment.