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

DemandVector.__call__(*args, **kw)

Get demand as sparse matrix of shape (n, k).

DemandVector.sparse([dtype])

Get demand as sparse matrix.

Load / Save

DemandVector.make_save_dict([prefix, save_dict])

Generate dict to save object with numpy.savez.

DemandVector.save_to_numpy(file, **kwargs)

Save object into a single file in uncompressed .npz format.

DemandVector.from_npz(data[, shared, prefix])

Construct object from .npz file.

DemandVector.add_to_etree(root[, name])

Add demand data to xml.etree.ElementTree.Element.

DemandVector.from_xml()

Misc

DemandVector.delete_nodes(nodes)

Delete all commodities that are made up by nodes.

DemandVector.to_single_pairs([as_label])

Decompose all CommodityMultiSourceSink.

DemandVector.reset_cache([hard])

Reset cache values.

DemandVector.map_node_label_to_id()

Map labels -> ids for all commodities.

DemandVector.map_node_id_to_label()

Map ids -> labels for all commodities.

DemandVector.scaled_copy([f])

Get a copy where rate of every commodity is scaled by f.

Attributes

DemandVector.k

Number of commodities in demand vector.

DemandVector.n

DemandVector.shared

Shared object for network objects.

DemandVector.dtype_int

DemandVector.dtype_float

DemandVector.all_single

Whether is comprised only of commodities with single sink / source.

DemandVector.rate

List [len k] of float or ndarray: node in/outflow per commodity.

DemandVector.source_lbl

List [len k] of str or ndarray: source labels per commodity.

DemandVector.sink_lbl

List [len k] of str or ndarray: sink labels per commodity.

DemandVector.source_id

List [len k] of int or ndarray: source indices per commodity.

DemandVector.sink_id

List [len k] of int or ndarray: sink indices per commodity.

DemandVector.total_rate

np.ndarray (k, ): total flow per commodity.