Researcher
AnsweredI am new to gurobi, I have a question regarding creating an array of variables.
Question regarding how to start index with1 instead 0?
For example in gurobi, x = model.addVars(2, 3) would create six variables, accessed as x[0,0], x[0,1], x[0,2], x[1,0], x[1,1], and x[1,2].
Is there any way to create an array of variables staring with index 1 instead 0?
For example, x = model.addVars(2, 3) would create six variables, accessed as x[1,1], x[1,2], x[1,3], x[2,1], x[2,2], and x[2,3]?
0
-
Official comment
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?. -
Sure: use ranges rather than numbers, for example:
x = model.addVars(range(1,3), range(1,4), name="x")
0
Post is closed for comments.
Comments
2 comments