Issue with Select method for Tuplelist class in Gurobi 7

70 views
Skip to first unread message

Ahmad Baubaid

unread,
Jan 7, 2017, 12:31:13 AM1/7/17
to Gurobi Optimization
I have upgraded from Gurobi 6.5.2 to Gurobi 7.0.1 and I'm having an issue with a Python script that worked perfectly fine with GurobiPy 6.5.2. I've tried looking for the issue and it seems to be in the select method when used with the tuplelist class. For some reason, I used to get the correct output in GurobiPy 6.5.2 but now I just get an empty list with the exact same code. Documentation for the select method for the tuplelist class seems to be the same in both versions, so I can't tell what went wrong. Here is an example of the issue:

>>> from gurobipy import *
>>> A = tuplelist([(('A', 1), ('B', 2)), (('A', 1), ('C', 3))])
>>> A
<gurobi.tuplelist (2 tuples, 2 values each):
 ( ('A', 1) , ('B', 2) )
 ( ('A', 1) , ('C', 3) )
>
>>> A.select(('A', 1), '*')
[]

Whereas when using GurobiPy 6.5.2 this would give me the correct output (namely the entire tuplelist since both entries have the tuple ('A', 1) as their first entry). I can't tell what I'm doing wrong here, so any help would be appreciated. Thanks!

Renan Garcia

unread,
Jan 17, 2017, 2:34:28 PM1/17/17
to gur...@googlegroups.com
tuplelist does not support nested tuples. We'll consider updating the docs to make this clearer.

In the meantime, the workaround would be to use flattened tuples. For example, your tuple list would contain elements ('A', 1, 'B', 2) and ('A', 1, 'C', 3), and the corresponding call to the select method would be A.select('A', 1, '*', '*').

--

---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ahmad BaUbaid

unread,
Jan 18, 2017, 9:50:00 AM1/18/17
to Gurobi Optimization
Thanks for your reply. This was working fine with GurobiPy 6.5.2 and only stopped working when I upgraded to 7.0.1. Was this something that was intentionally changed in the new version?

I'll consider using the workaround you suggested. Thanks for the help!

Renan Garcia

unread,
Jan 18, 2017, 11:08:41 AM1/18/17
to gur...@googlegroups.com
If it was supported for v6.5.2, that was a fortunate coincidence because it wasn't intended. tuplelist was enhanced for v7.0, and this likely broke the functionality. For instance, tuplelist.select() now handles iterables.

Ex:

>>> l=tuplelist([('a',1),('b',2),('c',3)])
>>> l.select(['a','b'], '*')
<gurobi.tuplelist (2 tuples, 2 values each):
 ( a , 1 )
 ( b , 2 )
Reply all
Reply to author
Forward
0 new messages