Using a tuple as first part of a double indeces
回答済みHi
I have a tuplelist
arcs = [(1,2),(3,4)]
and a list
uncer = [1,2]
and I create a variable with a double index
v = model.addVars(arcs, uncer, vtype=GRB.BINARY, name="v")
Now the indeces of the variables are not
((1,2),1),((1,2),2), ((3,4),1), ((3,4),2)
but
(1,2,1),(1,2,2), (3,4,1), (3,4,2)
so addVars turned a tuple and a number into a triple.
This clashes with :
quicksum(v[a,k] for a in arcs for k in uncer)
since it looks for variables with indeces of the form ((1,2),1),ect... but they of course do not exist.
Is there an easy solution where I can keep uncer and arcs as they are (I need them in other places) ?
Preferably, there should be a way to tell gurobi that the first index of the variable 'v' is a tuple.
Many thanks in advance
Markus
-
正式なコメント
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?. -
Thanks a lot for you quick answer! That is a very helpful and simple solution.
Have a nice weekend :)
0
投稿コメントは受け付けていません。
コメント
3件のコメント