Try our new documentation site (beta).
tuplelist
Gurobi tuple list. This is a sub-class of the Python list
class that is designed to efficiently support a usage pattern that is
quite common when building optimization models. In particular, if a
tuplelist
is populated with a list of tuples, the
select function on this
class efficiently selects tuples whose values match specified values
in specified tuple fields. To give an example, the statement
l.select(1, '*', 5)
would select all member tuples whose first
field is equal to '1' and whose third field is equal to '5'. The
'*'
character is used as a wildcard to indicate that any value is
acceptable in that field.
You generally build tuplelist
objects in the same way
you would build standard Python lists. For example, you
can use the +=
operator to append a new list of items to
an existing tuplelist
, or the +
operator to concatenate
a pair of tuplelist
objects. You can also call the append
,
extend
, insert
, pop
, and remove
functions.
To access the members of a tuplelist
, you also use standard list
functions. For example, l[0]
returns the first member of a
tuplelist
, while l[0:10]
returns a tuplelist
containing the first ten members. You can also use len(l)
to
query the length of a list.
Note that tuplelist
objects build and maintain a set of internal
data structures to support efficient select
operations. If
you wish to reclaim the storage associated with these data structures,
you can call the clean
function.
While you can use a tuplelist
anywhere you would normally use a
list, we suggest that you only use them when you wish to populate the
list with tuples and use the sub-list selection facilities provided by
select.
Subsections