Skip to main content

I cant see variable notations in printint results

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • 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

    Hi Mustafa,

    This is because you name all of your variables "x". The addVar uses the provided name since it creates exactly 1 optimization variable. There are multiple ways of how to get the variable names you want. You can either set them manually via

    for j in range (1,3):
    for o in range (1,3):
    for m in range(1,3):
    x[j,o,m] = model.addVar(vtype=GRB.BINARY,name="x[%d,%d,%d]"%(j,o,m))

    or use the addVars method, which will generate these names automatically

    J = [1,2]
    O = [1,2]
    M = [1,2]
    x = model.addVars(J, O, M, vtype=GRB.BINARY, name="x")
    # access variables via x[j,o,m]

    Best regards,
    Jaromił

    0

Post is closed for comments.