Skip to main content

About how to create variable x_ij

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

    You can use the addVars method for this task.

    import gurobipy as gp

    m = gp.Model("test")
    x = m.addVars(8,8,name="x")
    m.addConstr(x[0,7] - x[3,5] == 0)

    Please note that the indexing starts with \(0\) and ends with your value \(-1\). Thus, you can access \(\texttt{x}\) via \(\texttt{x[i,j]}\) with \(i,j \in \{0,\dots, 7\}\).

    Best regards,
    Jaromił

    0

Post is closed for comments.