メインコンテンツへスキップ

dict to tupledict conversion

回答済み

コメント

2件のコメント

  • 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

サインインしてコメントを残してください。