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 from numpy.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

DemandVectorSP.__call__(*args, **kw)

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

DemandVectorSP.sparse([dtype])

Get demand as sparse matrix.

Load / Save

DemandVectorSP.make_save_dict([prefix, ...])

Generate dict to save object with numpy.savez.

DemandVectorSP.save_to_numpy(file, **kwargs)

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

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

Construct object from .npz file.

DemandVectorSP.add_to_etree(root[, name])

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

DemandVectorSP.from_xml()

Misc

DemandVectorSP.delete_nodes(nodes)

Delete all commodities that are made up by nodes.

DemandVectorSP.to_single_pairs([as_label])

Returns self.

DemandVectorSP.reset_cache([hard])

Reset cache values.

DemandVectorSP.map_node_label_to_id()

Map labels -> ids for all commodities.

DemandVectorSP.map_node_id_to_label()

Delete all commodities that are made up by nodes.

DemandVectorSP.scaled_copy([f])

Get a copy where every commodity is scaled by f.

Attributes

DemandVectorSP.k

Number of commodities in demand vector.

DemandVectorSP.n

DemandVectorSP.shared

Shared object for network objects.

DemandVectorSP.dtype_int

DemandVectorSP.dtype_float

DemandVectorSP.all_single

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

DemandVectorSP.rate

ndarray (k, ) of flow: rates.

DemandVectorSP.source_lbl

ndarray (k, ) of str: source labels.

DemandVectorSP.sink_lbl

ndarray (k, ) of str: sink labels.

DemandVectorSP.source_id

ndarray (k, ) of int: source indices.

DemandVectorSP.sink_id

ndarray (k, ) of int: sink indices.

DemandVectorSP.total_rate

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