DemandVector¶
Class Description¶
- class paminco.net.demand.DemandVector(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 DemandVector object can be instantiated in several ways:
- DemandVector(dv)
where
dv
is a DemandVector.- DemandVector(M)
where
M
is matrix (ndarray or spmatrix) with node indices as rows and commodities as columns.- DemandVector(it)
where
it
an iterable with elements that are tuples or dicts.
- Parameters
- sharedShared
Shared object for all network objects.
- dataDemandVector, ndarray, spmatrix, or iterable
(Processed) commodity data.
- copybool, default=True
Whether to copy data in
data
.- is_labelbool, default=True
Whether commodity nodes are given as labels or ids in data if data is iterable.
- 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.
commodities
List [len k] of commdodities: CommoditySingleSourceSink or CommodityMultiSourceSink.
source_lbl
List [len k] of str or ndarray: source labels per commodity.
sink_lbl
List [len k] of str or ndarray: sink labels per commodity.
source_id
List [len k] of int or ndarray: source indices per commodity.
sink_id
List [len k] of int or ndarray: sink indices per commodity.
rate
List [len k] of float or ndarray: node in/outflow per commodity.
total_rate
np.ndarray (k, ): total flow per commodity.
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 |
|
Decompose all CommodityMultiSourceSink. |
|
Reset cache values. |
Map labels -> ids for all commodities. |
|
Map ids -> labels for all commodities. |
|
Get a copy where rate of every commodity is scaled by |
Attributes¶
Number of commodities in demand vector. |
|
Shared object for network objects. |
|
Whether is comprised only of commodities with single sink / source. |
|
List [len k] of float or ndarray: node in/outflow per commodity. |
|
List [len k] of str or ndarray: source labels per commodity. |
|
List [len k] of str or ndarray: sink labels per commodity. |
|
List [len k] of int or ndarray: source indices per commodity. |
|
List [len k] of int or ndarray: sink indices per commodity. |
|
np.ndarray (k, ): total flow per commodity. |