Skip to main content

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

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    Gurobi Staff Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • 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

Post is closed for comments.