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 |
|
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 (dense) |
|
observability_matrix | function |
Kalman observability matrix (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 (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 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 from to |
|
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 between every sensor (row) and driver (column) |
|
control_depth | function |
Distance of every state from the nearest driver node (inf if not reachable) |
|
observation_depth | function |
Distance 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 needed by driver (column) to influence state (row); zero for non-driver |
|
observation_distance_matrix | function |
MATLAB clusterObserve: derivations needed by sensor (column) to observe state (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 and |
|
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 that are missing while 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 |
|
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 for directed networks |
|
degree_variance | function |
Population variance of the total degrees |
|
density | function |
Density (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 (self-loops included) |
|
num_nodes | function |
Number of state variables |
|
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 marks the states that node can influence, computed from the state-transition matrix |
|
reach_o | function |
MATLAB reachO: row marks the states that node can observe |
|
reachability | function |
Reachability matrix: R[i, j] is True iff can be reached from (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]: is reachable from in at most steps (every node reaches itself) |
|
set_cover | function |
Grassroot set covering (MATLAB setCover): nodes whose -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 ) |
|
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 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 (or observation depth ) |
|
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 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 feeding a chain: the path-finding example |
|
make_competing_cycles | function |
Two source cycles competing for the same unmatched node |