dict to tupledict conversion
AnsweredHello guys, is there any way that I can convert a typical python dictionary to tupledict?
Kind regards
Iason
0
-
Official comment
This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Iason,
You can just pass the dictionary into the tupledict init method
import gurobipy as gp
my_dict = {
("this", 1):"a",
("this", 2):"b",
("that", 1):"c",
("that", 2):"d",
("that", 3):"e",
}
td = gp.tupledict(my_dict)
td.select("this") # ['a', 'b']
td.select("*", 1) # ['a', 'c']- Riley
0 -
thanks Riley!
0
Post is closed for comments.
Comments
3 comments