Skip to main content

ValueError using model.addMConstr since gurobipy 11.0.0

Answered

Comments

3 comments

  • Official comment
    Robert Luce
    Gurobi Staff Gurobi Staff

    Christian,

    in all versions 10.0.* and 11.0.0 you can use a list of strings as the 'name' argument for Model.addMConstr to give individual names per constraint. That's in line with the docstring of this method.  For versions 10.0.* it just happened that an ndarray type for this argument was handled gracefully, but no longer in version 11.0.0.  To be on the safe side, please pass in a list of names, e.g., do

    model.addMConstr(A, gp_vars, sense, rhs, constr_names.tolist()) 

    With the next technical release 11.0.1 the method will handle an ndarray name argument gracefully again, but we cannot make a promise that it will do so future versions.

  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    Hi Christian,

    Concerning the ValueError: The constr_names array is the problem, see the documentation of Model.addMConstr()

    name: Single string defining the name for new constraints. The given name will be subscripted by the index of the constraint in the matrix.

    For the installation issue, note that Python 3.12. is not supported by Gurobi 10.0.3 or earlier. If you want to use Verison 10, please downgrade to Python 3.11.

    Best regards,
    Marika

    0
  • Christian Perau
    Curious
    Gurobi-versary
    Conversationalist

    Hi Marika,

    thanks for the quick response! I know this problem actually existed before version 10 of gurobi. I also created a post regarding that a while ago (https://support.gurobi.com/hc/en-us/community/posts/8827103170065-Gurobipy-addMConstr-raises-GurobiError-Name-too-long-when-passing-list-of-names). But it did work in gurobi 10 so I´m wondering why this feature was removed in version 11? Do you maybe know if there is already a feature request for this? Otherwise I will create one.

    Best regards,
    Christian

    0

Please sign in to leave a comment.