DemandVectorSP¶
Class Description¶
- class paminco.net.demand.DemandVectorSP(data, shared=None, dtype_int=None, dtype_float=None, copy: bool = True, is_label: bool = True)[source]¶
Class that builds on a number of commodities k.
- A DemandVectorSP object can be instantiated in several ways:
- DemandVectorSP(dv)
where
dv
is a DemandVectorSP.- DemandVectorSP(arr)
where
arr
is array_like. The resulting array fromnumpy.array(arr)
is expected to look like:[source_1, sink_1, rate_1] ... [source_k, sink_k, rate_k]
- Parameters
- dataDemandVector or array_like
Commodity data in processed or unprocessed form.
- sharedShared, optional
Shared object for all network objects.
- copybool, default=True
Whether to copy data in
data
.- is_labelbool, default=True
Whether commodity nodes are given as labels or ids in data.
- Attributes
k
Number of commodities in demand vector.
shared
Shared object for network objects.
all_single
Whether is comprised only of commodities with single sink / source.
rate
ndarray (k, ) of flow: rates.
total_rate
np.ndarray (k, ): total flow per commodity.
source_lbl
ndarray (k, ) of str: source labels.
sink_lbl
ndarray (k, ) of str: sink labels.
source_id
ndarray (k, ) of int: source indices.
sink_id
ndarray (k, ) of int: sink indices.
Methods¶
Value¶
|
Get demand as sparse matrix of shape (n, k). |
|
Get demand as sparse matrix. |
Load / Save¶
|
Generate dict to save object with numpy.savez. |
|
Save object into a single file in uncompressed |
|
Construct object from |
|
Add demand data to xml.etree.ElementTree.Element. |
Misc¶
|
Delete all commodities that are made up by |
|
Returns self. |
|
Reset cache values. |
Map labels -> ids for all commodities. |
|
Delete all commodities that are made up by |
|
Get a copy where every commodity is scaled by f. |
Attributes¶
Number of commodities in demand vector. |
|
Shared object for network objects. |
|
Whether is comprised only of commodities with single sink / source. |
|
ndarray (k, ) of flow: rates. |
|
ndarray (k, ) of str: source labels. |
|
ndarray (k, ) of str: sink labels. |
|
ndarray (k, ) of int: source indices. |
|
ndarray (k, ) of int: sink indices. |
|
np.ndarray (k, ): total flow per commodity. |