メインコンテンツへスキップ

I cant see variable notations in printint results

回答済み

コメント

2件のコメント

  • 正式なコメント
    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

投稿コメントは受け付けていません。