|
|
Trees | Indices | Help |
|
|---|
A class for storing sparse vector data.
An instance of this class has two attributes, ind and val. ind specifies the indices and val specifies the values. ind and val must be sequences of the same length. In general, ind may contain any identifier; for example, when a SparsePair object is passed to Cplex.linear_constraints.add, its ind attribute may be a list containing both variable names and variable indices.
| Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
| Method Details |
Constructor for SparsePair. Takes two arguments, ind and val; ind specifies the indices that the SparsePair refers to, and val specifies the float values associated with those indices; ind and val must have the same length. If ind or val is omitted, they will default to an empty list. >>> spair = SparsePair(ind=[0], val=[1.0])
|
Representation method of SparsePair. Example usage: >>> SparsePair(ind=[0], val=[1.0]) SparsePair(ind = [0], val = [1.0]) |
Tests that ind and val have the same length. Example usage: >>> spair = SparsePair(ind=[0, 1, 2], val=[1.0, 1.0, 1.0]) >>> spair.isvalid() True |
Extracts the indices and values sequences as a tuple. Returns ind and val as given in __init__. >>> spair = SparsePair(ind=[0, 1, 2], val=[1.0, 1.0, 1.0]) >>> ind, val = spair.unpack() |
|
|
Trees | Indices | Help |
|
|---|