About how to create variable x_ij
回答済みI want to create a variable which contain i is from 1 to 8, j is from 1 to 8
x_11, x_12, x_13, x_14, x_15, x_16,x_17, x_18,....., X_88
Does it have a convenient way to create rather than create them one by one.
0
-
正式なコメント
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?. -
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
投稿コメントは受け付けていません。
コメント
2件のコメント