Skip to main content

dict to tupledict conversion

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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.
  • 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

Post is closed for comments.