Network-Based Controllability and Observability Analysis in PythonThe nocad toolbox

Appendix A
API reference

This appendix lists every public class and function of nocad, module by module, with the first sentence of its docstring. The lists are generated from the __all__ attribute of each module by book/build_api_appendix.py, so they are complete by construction; the full signatures, parameters, and attributes are in the online documentation and in the docstrings (help(nocad.InputOutputDesign)). The conventions of the API are described in section 2.3, the notation of the docstrings in table 2.1.

A.1 nocad.design: Input and output design

Name

Kind

Description

METHODS

constant

Names of the accepted methods

maximum_matching_pf

function

Maximum matching corrected by the path-finding method (MATLAB maximumMatchingPF)

maximum_matching_ss

function

Maximum matching with signal sharing (MATLAB maximumMatchingSS)

maximum_matching_min

function

Matching whose unmatched nodes are a minimum set of dedicated driver nodes

control_matching

function

Control matching and the nodes receiving a shared input signal

driver_nodes

function

Driver nodes of a network (nodes that receive an input signal)

sensor_nodes

function

Sensor nodes of a network: the driver nodes of the reversed network

n_driver_nodes

function

Number of driver nodes ND

generate_matrices

function

State-space matrices of a controllable and observable system on a network

generate_matrices_pf

function

MATLAB generateMatricesPF: generate_matrices with path finding

generate_matrices_ss

function

MATLAB generateMatricesSS: generate_matrices with signal sharing

input_matrix

function

Input matrix 𝐁: one column per dedicated driver node; shared nodes receive the signal of the first input

output_matrix

function

Output matrix 𝐂: one row per dedicated sensor node; shared nodes are added to the first output

InputOutputDesign

class

Design inputs and outputs that make a network controllable and observable

A.2 nocad.matching: Matchings, node roles, and edge classes

Name

Kind

Description

Matching

class

A matching of a directed network

maximum_matching

function

Maximum matching of a directed network (Hopcroft–Karp)

matching_size

function

Size of a maximum matching, i.e. the generic rank of 𝐀

node_roles

function

Role of every node across all maximum matchings (Jia et al. 2013)

edge_classes

function

Class of every edge across all maximum matchings (Liu et al. 2011)

all_maximum_matchings

function

Enumerate the maximum matchings of a small network (for teaching and tests)

NODE_ROLES

constant

Names of the classes

EDGE_CLASSES

constant

Names of the classes

A.3 nocad.components: Strongly connected components

Name

Kind

Description

Condensation

class

Condensation of a network

strongly_connected_components

function

Label of the strongly connected component of every node

components

function

MATLAB NOCAD components: component index of every node and component sizes

condensation

function

Contract every strongly connected component to a node

source_components

function

Node sets of the source (root) SCCs: no incoming edge from outside

sink_components

function

Node sets of the sink (top) SCCs: no outgoing edge to the outside

topological_order

function

Order of the nodes in which every edge between components points forward

is_trivial_component

function

A single node without a self-loop is a trivial component (no cycle inside)

A.4 nocad.structural: Controllability and observability tests

Name

Kind

Description

structural_rank

function

Generic (structural) rank of a matrix: the size of a maximum matching between its rows and columns through non-zero entries

is_structurally_controllable

function

Lin’s structural controllability test

is_structurally_observable

function

Structural observability: structural controllability of the dual pair (𝐀𝖳,𝐂𝖳)

accessible_states

function

Boolean mask of the states reachable from the inputs in the graph of (𝐀,𝐁)

controllability_matrix

function

Kalman controllability matrix [𝐁,𝐀𝐁,…,𝐀N−1𝐁] (dense)

observability_matrix

function

Kalman observability matrix [𝐂;𝐂𝐀;…;𝐂𝐀N−1] (dense)

controllable_subspace_dimension

function

Dimension of the controllable subspace of a numerical pair

generic_controllable_dimension

function

Generic dimension of the controllable subspace of a structured pair

is_controllable

function

Controllability of (𝐀,𝐁)

is_observable

function

Observability of (𝐀,𝐂); dual of is_controllable

pbh_uncontrollable_modes

function

Eigenvalues λ of 𝐀 with rank[𝐀−λ𝐈,𝐁]<N (PBH test)

control_centrality

function

Control centrality: generic dimension of the controllable subspace from one node

observe_centrality

function

Observe centrality: control centrality of the dual system (MATLAB observeCentrality)

random_realization

function

Random numerical realization of a zero pattern: magnitudes in [low, high], random signs

A.5 nocad.profiles: Driver types and control profiles

Name

Kind

Description

driver_types

function

Type of every driver node (MATLAB driverType)

sensor_types

function

Type of every sensor node (MATLAB sensorType): driver types of the dual system

control_profile

function

Control profile (ηs,ηe,ηi) of a network (Ruths and Ruths 2014)

observation_profile

function

Observation profile: the control profile of the reversed network

DRIVER_TYPES

constant

Names of the classes

A.6 nocad.distances: Distances and relative degree

Name

Kind

Description

geodesic_distances

function

Matrix of shortest-path lengths ℓij from xi to xj

all_shortest_paths

function

MATLAB allShortestPaths (weighted Dijkstra on the given weights)

diameter

function

Longest finite geodesic distance (MATLAB diam)

relative_degree

function

Relative degree (order) of a configuration (MATLAB degreeRel)

relative_degree_matrix

function

Relative degrees rkl between every sensor (row) and driver (column)

control_depth

function

Distance ρiC of every state from the nearest driver node (inf if not reachable)

observation_depth

function

Distance ρiO of every state to the nearest sensor node (inf if it cannot reach one)

control_regions

function

Nearest driver node of every state (-1 if unreachable): network Voronoi cells

observation_regions

function

Nearest sensor node of every state (-1 if it reaches none)

placement_cost

function

Cost of a driver or sensor configuration (MATLAB getCost)

control_distance_matrix

function

MATLAB clusterControl: number of derivations ℓ+1 needed by driver j (column) to influence state i (row); zero for non-driver

observation_distance_matrix

function

MATLAB clusterObserve: derivations ℓ+1 needed by sensor j (column) to observe state i (row); zero for non-sensors and states

A.7 nocad.connection: Connection types

Name

Kind

Description

CONNECTION_TYPES

constant

Patterns of the seven connection types (loop on source, loop on target, reverse edge)

connection_type

function

Type ("a"–"g") of the connection between xi and xj

connection_type_counts

function

Number of connected node pairs of every type

add_node_dynamics

function

Add self-loops (self-influence) to the given nodes (all nodes by default)

add_edge_dynamics

function

Add the reverse of the given edges (all edges by default): interactions

apply_connection_type

function

Turn every edge of the network into a connection of the given type

free_loops

function

Nodes without a self-loop

free_symmetric

function

Edges xi→xj that are missing while xj→xi exists, as (i, j) pairs

add_edges

function

Add n_loops random self-loops and n_sym random reverse edges (MATLAB addEdges)

dynamics_heatmap

function

Driver and sensor counts as self-influence and interactions are added (MATLAB heatmaps)

connection_type_study

function

Share of driver and sensor nodes when every edge is turned into each connection type

A.8 nocad.measures: System characterisation

Name

Kind

Description

closeness_centrality

function

Out-, in- and total closeness of every node (MATLAB closenessCentrality)

degree

function

Total degree (in + out), self-loops excluded

degree_correlation

function

Mean degree of the neighbors of every node (MATLAB degreeCorrel)

degree_freeman

function

Freeman’s degree centralization ∑i(dmax−di)∕((N−1)(N−2))

degree_in

function

In-degree of every node, self-loops excluded

degree_out

function

Out-degree of every node, self-loops excluded

degree_scott

function

Scott’s normalized degree di∕(2(N−1)) for directed networks

degree_variance

function

Population variance of the total degrees

density

function

Density |E|∕N2 (self-loops are possible edges)

edge_betweenness

function

Edge betweenness as a sparse matrix aligned with the adjacency matrix

node_betweenness

function

Betweenness of every node: the number of shortest paths that pass through it

num_edges

function

Number of edges |E| (self-loops included)

num_nodes

function

Number of state variables N

pagerank

function

PageRank in percent, as in MATLAB pageRank

pearson_dir

function

Degree assortativity of a directed network (Pearson correlation over the edges)

percent_loop_sym

function

Percentage of nodes with a self-loop and of edges whose reverse edge also exists

driver_similarity

function

Similarity of every pair of driver nodes (MATLAB driverSimilarity)

edge_similarity

function

Similarity of every pair of edges (MATLAB similarity)

endpoint_similarity

function

Endpoint similarity of every edge (MATLAB endpointSim)

jaccard

function

Jaccard similarity of two sets given as boolean (or 0/1) vectors; 0 if both are empty

reach_c

function

MATLAB reachC: row i marks the states that node i can influence, computed from the state-transition matrix

reach_o

function

MATLAB reachO: row i marks the states that node i can observe

reachability

function

Reachability matrix: R[i, j] is True iff xj can be reached from xi (every node reaches itself)

sensor_similarity

function

Similarity of every pair of sensor nodes (MATLAB sensorSimilarity)

sim_weighting

function

Agreement of the distances of two nodes to their common states (MATLAB simWeighting)

get_config

function

Which measures system_measures computes (MATLAB getConfig); all by default

measures_tables

function

The measures of system_measures as pandas DataFrames

system_measures

function

Compute the measures of the system characterisation module

A.9 nocad.placement: Placement of additional inputs and outputs

Name

Kind

Description

PLACEMENT_METHODS

constant

Names of the accepted methods

Placement

class

Place additional driver or sensor nodes to bound the relative order

improve_configuration

function

Compare the five placement methods for drivers and sensors (MATLAB extendData)

anneal

function

One simulated annealing run with n_add additional nodes

annealing_placement

function

Add nodes by mCLASA or GDFCMSA (MATLAB mCLASArMax, GDFCMSArMax, ...addMax)

centrality_retrofit

function

Centrality-based retrofit (MATLAB analyseComponents)

greedy_set_cover

function

Greedy (Chvátal) set cover

reach_within

function

Boolean matrix R[i, j]: xj is reachable from xi in at most rmax steps (every node reaches itself)

set_cover

function

Grassroot set covering (MATLAB setCover): nodes whose rmax-step reach covers the network

set_cover_except

function

Retrofit set covering (MATLAB setCoverExcept): keep selected and cover the rest

configuration_cost

function

Cost, maximal and mean relative order of a configuration (unreachable = N)

A.10 nocad.robustness: Robustness

Name

Kind

Description

node_removal_robustness

function

Controllability and observability after the removal of every single state variable

robustness_table

function

Robustness of several configurations (MATLAB robust over the five methods)

edge_removal_robustness

function

Controllability and observability after the removal of every single edge

A.11 nocad.annotation: Role annotations

Name

Kind

Description

annotate

function

Node and edge tables with the controllability and observability role of every element

node_table

function

Node table of annotate

edge_table

function

Edge table of annotate

component_levels

function

Longest-path levels of the strongly connected components

NODE_COLUMNS

constant

dict constant

EDGE_COLUMNS

constant

dict constant

A.12 nocad.io: Import and export

Name

Kind

Description

from_networkx

function

Network of state variables from a NetworkX graph

to_networkx

function

NetworkX digraph of a network, with the annotations as node and edge attributes

from_igraph

function

Network from a python-igraph graph (vertex attribute name gives the labels)

to_igraph

function

python-igraph graph with the annotations of to_networkx as attributes

from_pandas_edgelist

function

Network from an edge-list DataFrame (one row per edge xj→xi)

to_pandas

function

Node and edge tables (pandas DataFrames) of annotate

from_state_space

function

Network of a state-space model: 𝐖= 𝐀𝖳

from_control

function

Network of a python-control StateSpace system (state names become labels)

to_control

function

python-control StateSpace system with the structure of a design

read

function

Read a network (and a stored configuration) from a file

write

function

Write a network, a design or an annotated configuration to a file

read_mat

function

Read a MATLAB file: state-space matrices A, B, C, D or a network matrix

write_mat

function

Write A, B, C, D, the adjacency matrix adj, labels and the 1-based drivers / sensors for the NOCAD MATLAB toolbox

to_dot

function

Graphviz DOT source of an annotated network

FORMATS

constant

dict constant

A.13 nocad.viz: Visualization

Name

Kind

Description

hierarchy_layout

function

Layered layout of the condensation of a network

control_cacti

function

Decompose a controllability certificate into stems and buds (Lin’s cacti)

cactus_layout

function

Positions for drawing control cacti (see control_cacti)

bipartite_layout

function

Two-column layout of the bipartite representation with matched edges horizontal

cycle_order

function

Order the nodes of a strongly connected component along a greedy walk over its edges, so that consecutive nodes on the circle are mostly joined by edges

plot_scc_hierarchy

function

Draw the network level by level on its condensation (see hierarchy_layout)

plot_bipartite_matching

function

Bipartite representation with a maximum matching and the edge classes

plot_control_cacti

function

Draw the control (observation) cacti of a design (see control_cacti)

plot_structure_matrix

function

Zero pattern of the system matrix [ 𝐀 𝐁 𝐂 0 ] in block-triangular

depth_colormap

function

Discrete sequential colormap for depths 0..max_depth (blues for control, oranges for observation)

plot_depth_map

function

Network colored by control depth ρiC (or observation depth ρiO)

plot_distance_matrix

function

Distances between the configured nodes (columns) and the states (rows)

plot_operability_plane

function

Every state in the plane of its control depth and observation depth

plot_node_roles

function

Network colored by the role of every node across all maximum matchings

plot_edge_classes

function

Network with every edge colored by its class across all maximum matchings

plot_robustness_map

function

Network with the critical nodes of a configuration (from node_removal_robustness)

plot_annotation

function

Network with every node colored by a column of the annotation table

plot_control_profiles

function

Control profiles (ηs,ηe,ηi) in a ternary diagram (Ruths and Ruths 2014)

plot_dynamics_heatmap

function

Heat maps of the driver and sensor counts of dynamics_heatmap

plot_placement_history

function

Relative order (or cost) against the number of added nodes for several methods

plot_operability_summary

function

Four panels that summarize the operability of a network

A.14 nocad.plotting: Plotting primitives

Name

Kind

Description

PALETTE

constant

Fixed categorical color palette (Okabe–Ito)

ROLE_COLORS

constant

Fixed colors of node roles and edge kinds

default_layout

function

Node positions for a network drawing

LAYOUTS

constant

tuple constant

as_pos_dict

function

NetworkX-style pos dictionary from an (N, 2) array

draw_network

function

Draw a directed network with arrows, self-loops and input/output stubs

plot_network

function

Draw a network with its driver and sensor nodes and, optionally, a matching

role_colors

function

Node colors by role (driver, sensor, both, other)

legend_handles

function

Legend entries for the role colors

A.15 nocad.datasets: Data sets

Name

Kind

Description

NETWORKS

constant

Names of the bundled networks and their groups

list_networks

function

Names of the bundled networks, optionally of one group ("I", "II", "III")

load_network

function

Load a bundled network

load_nocad_example

function

The nine-state example network of the NOCAD manual (toolboxExample.m)

load_four_node_example

function

Four-node example of the NOCAD manual (a 3-cycle with a tail): x1->x2->x3->x1, x3->x4

make_random_network

function

Random directed network

make_water_tanks

function

Networks of water tanks with different connection types

make_heat_exchanger_network

function

Network of the state variables of a heat exchanger network (HEN)

make_hen_case_study

function

A heat exchanger network with 6 hot and 2 cold streams, 10 exchanger cells and 2 coolers

make_cycle_example

function

Two-node cycle x1↔x2 feeding a chain: the path-finding example

make_competing_cycles

function

Two source cycles competing for the same unmatched node