Skip to main content

Tupledict with lists for values

Answered

Comments

2 comments

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

    Hi Pavithra,

    Let values be the list of the elements, (5, 10, 15, 20, 21) in your example. You can just write:

    d = tupledict([(("Type A", "Time period 1", index), value) for 
    index, value in enumerate(values)])

    Then \(\texttt{d}\) will be:

    {
    ('Type A', 'Time period 1', 0): 5, ('Type A', 'Time period 1', 1): 10,
    ('Type A', 'Time period 1', 2): 15, ('Type A', 'Time period 1', 3): 20,
    ('Type A', 'Time period 1', 4): 21
    }


    Best regards,

    Maliheh

    0

Post is closed for comments.