optiwindnet.terse¶

Compact, self-describing encodings of solution and routeset links.

Module Contents¶

class optiwindnet.terse.LinkScope[source]¶

Bases: enum.StrEnum

Graph layer represented by TerseLinks.

Initialize self. See help(type(self)) for accurate signature.

TOPOLOGY[source]¶
ROUTESET[source]¶

Bases: collections.abc.Sequence[int]

Compact links plus the metadata needed to reconstruct their graph.

RADIAL and BRANCHED values use one parent target per non-root node. RINGED values use the flattened route representation. A topology value represents S; a routeset value additionally carries the clone mapping needed to reproduce G against its location graph. Either scope can be bound to an exact location geometry with nodeset_digest.

topology: optiwindnet.types.Topology[source]¶
scope: LinkScope[source]¶
T: int[source]¶
R: int[source]¶
B: int = 0[source]¶
C: int = 0[source]¶
D: int = 0[source]¶
clone2prime: tuple[int, Ellipsis] = ()[source]¶
nodeset_digest: bytes | None = None[source]¶
__post_init__()[source]¶
__len__() int[source]¶
__iter__() collections.abc.Iterator[int][source]¶
__getitem__(index)[source]¶
__array__(dtype=None, copy=None) numpy.ndarray[source]¶
__repr__() str[source]¶
tolist() list[int][source]¶

Return the encoded links as a plain list.

to_dict() dict[str, Any][source]¶

Return a versioned representation suitable for JSON serialization.

classmethod from_dict(data: collections.abc.Mapping[str, Any]) TerseLinks[source]¶

Restore a value created by to_dict().

classmethod from_topology(S: networkx.Graph, *, nodeset_digest: bytes | None = None) TerseLinks[source]¶

Encode solution topology S, optionally bound to a node set.

classmethod from_routeset(G: networkx.Graph) TerseLinks[source]¶

Encode routed solution G, including its clone mapping.

classmethod from_array(links: collections.abc.Sequence[int], *, topology: optiwindnet.types.Topology | str | None = None, R: int | None = None, T: int | None = None) TerseLinks[source]¶

Adapt a legacy topology array to a self-describing value.

to_topology(**graph_attrs) networkx.Graph[source]¶

Reconstruct topology S.

to_routeset(L: networkx.Graph, **graph_attrs) networkx.Graph[source]¶

Reconstruct routeset G against location graph L.