empty tuplelist, tupledict

268 views
Skip to first unread message

Mohammad Najarian

unread,
Jul 27, 2018, 12:28:33 AM7/27/18
to Gurobi Optimization
Hi,

I have a model for which I first create a tuple (or dict) and the convert it to gurobipy.tuplelist (gurobipy.tupledict). I have two questions: 
Can we use the python list of tuple and dictionary instead of Gurobi types? 
Can I create an empty tuplelist or tupledict and populate it later? 

Best regards,
Matt

Dan Jeffrey

unread,
Jul 27, 2018, 4:00:13 PM7/27/18
to Gurobi Optimization
> Can we use the python list of tuple and dictionary instead of Gurobi types?
Yes. But the Gurobi types are more effiecient in two senses:
1. They are syntactically easier to tpye at the keyboard
2. Select functions are computationally more efficient on a tuplelist than on a list of tuples

> Can I create an empty tuplelist or tupledict and populate it later?
Yes. For example:
    tl = tuplelist()
    tl += [(1,2,3)]
    tl += [(4,5,6),(7,8,9)]
    print(tl)
output:
    <gurobi.tuplelist (3 tuples, 3 values each):
     ( 1 , 2 , 3 )
     ( 4 , 5 , 6 )
     ( 7 , 8 , 9 )
Reply all
Reply to author
Forward
0 new messages