gurobipy - How can I get the tupledict object using model.getVars()?
回答済みI have established all of my model variables using the x = model.addVars(list1,list2) command which gives a tupledict with len(list1)*len(list2) variables, accessed by x["key1","key2"], but when I use x = model.getVars() in a callback, it gives me a list of variables instead of the original tupledict that I have used to establish them all.
How can I access the tupledict data structure from within my callback function? failing that, is there any easy mapping from tupledict key to list index that i can use? is it simply x["key1","key2"] -> x[idx(key1)*len(list2)+idx(key2)]? (here, idx("key1") is the index in list1 of string "key1")
-
正式なコメント
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?. -
Hi Angus,
One easy trick to access your variables inside the callback is to just add them as members to the model, as it is done in the callback example that comes with Gurobi:
model._vars = xCheers,
Matthias0 -
awesome, thanks a lot! that worked perfectly
0
投稿コメントは受け付けていません。
コメント
3件のコメント