Skip to main content

Gurobi status code

Answered

Comments

2 comments

  • Official comment
    Kostja Siefen
    Gurobi Staff Gurobi Staff

    The full list of status codes is documented at https://www.gurobi.com/documentation/current/refman/optimization_status_codes.html. There is nothing wrong with writing your own dictionary to convert the code values to strings. The status codes are normally hardcoded during compilation and the values (e.g, OPTIMAL=2) will not be changed in the future. However, we have occasionally extended the list in the past with additional values for new major releases.

    The Gurobi Python API provides class constants that can also be used (GRB.OPTIMAL, etc.) so your dictionary definition could look like this:

    status = { "LOADED" : GRB.LOADED, "OPTIMAL" : GRB.OPTIMAL, .... }

  • Irvin Lustig
    Gurobi-versary
    First Comment

    You can hack this using the Python

    __dict__

    method:

    sc = gurobipy.StatusConstClass
    d = {sc.__dict__[k]: k for k in sc.__dict__.keys() if k[0] >= 'A' and k[0] <= 'Z'}

    Then the dictionary `d` is now:

    {1: 'LOADED',
     2: 'OPTIMAL',
     3: 'INFEASIBLE',
     4: 'INF_OR_UNBD',
     5: 'UNBOUNDED',
     6: 'CUTOFF',
     7: 'ITERATION_LIMIT',
     8: 'NODE_LIMIT',
     9: 'TIME_LIMIT',
     10: 'SOLUTION_LIMIT',
     11: 'INTERRUPTED',
     12: 'NUMERIC',
     13: 'SUBOPTIMAL',
     14: 'INPROGRESS',
     15: 'USER_OBJ_LIMIT'}
    2

Please sign in to leave a comment.