Skip to main content

dict to tupledict conversion

Answered

Comments

2 comments

  • Riley Clement
    • Gurobi Staff

    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
  • Iason Liagkas
    • Gurobi-versary
    • Detective
    • Thought Leader

    thanks Riley!

    0

Please sign in to leave a comment.