Migration from the MATLAB toolbox#

The MATLAB/Octave NOCAD toolbox (github.com/abonyilab/NOCAD) is organized in three modules. Every function maps onto nocad as listed below. Node indices are 0-based in Python; matchedBy becomes matched_by with -1 for unmatched nodes. As in MATLAB, functions of a network take the adjacency matrix and functions of a system the state matrix \(\mathbf{A}=\mathbf{W}^{\mathsf T}\).

Module 1: network mapping#

MATLAB

nocad

components

nocad.components.components, condensation

maximumMatching

nocad.maximum_matching

maximumMatchingPF

nocad.maximum_matching_pf

maximumMatchingSS

nocad.maximum_matching_ss

—

nocad.maximum_matching_min (exact minimum, new)

generateMatricesPF

nocad.generate_matrices_pf / generate_matrices(adj, "path_finding")

generateMatricesSS

nocad.generate_matrices_ss / generate_matrices(adj, "signal_sharing")

Module 2: system characterisation#

MATLAB

nocad

numOfNodes, numOfEdges, density

nocad.measures.num_nodes, num_edges, density

allShortestPaths, diam

nocad.distances.all_shortest_paths, diameter

degreeIn, degreeOut, degree

nocad.measures.degree_in, degree_out, degree

degreeScott, degreeVariance

nocad.measures.degree_scott, degree_variance

degreeFreeman

nocad.measures.degree_freeman

pearsonDir, sumSq

nocad.measures.pearson_dir

degreeCorrel

nocad.measures.degree_correlation

percentLoopSym

nocad.measures.percent_loop_sym

closenessCentrality

nocad.measures.closeness_centrality

nBetweenness, betweenness

nocad.measures.node_betweenness, edge_betweenness

pageRank

nocad.measures.pagerank

isControllable, isObservable

nocad.is_controllable, nocad.is_observable

degreeRel

nocad.relative_degree

controlCentrality, observeCentrality

nocad.control_centrality, observe_centrality

driverNodes, sensorNodes

non-zero rows of B / columns of C

driverType, sensorType

nocad.driver_types, sensor_types

clusterControl, clusterObserve

nocad.distances.control_distance_matrix, observation_distance_matrix

driverSimilarity, sensorSimilarity

nocad.measures.driver_similarity, sensor_similarity

jaccard, simWeighting

nocad.measures.jaccard, sim_weighting

reachC, reachO, reachability

nocad.measures.reach_c, reach_o, reachability

endpointSim, similarity

nocad.measures.endpoint_similarity, edge_similarity

getNumNodes

nocad.n_driver_nodes, nocad.sensor_nodes

addEdges

nocad.connection.add_edges

heatmaps

nocad.dynamics_heatmap + nocad.viz.plot_dynamics_heatmap

getConfig, matricesToStruct

nocad.measures.get_config, system_measures / measures_tables

Module 3: improvement and robustness#

MATLAB

nocad

setCover, setCoverExcept

nocad.placement.set_cover, set_cover_except

greedyscp

nocad.placement.greedy_set_cover

analyseComponents, measures

nocad.placement.centrality_retrofit

mCLASArMax, mCLASAaddMax

Placement(method="mclasa", r_max=...) / n_add=...

GDFCMSArMax, GDFCMSAaddMax

Placement(method="gdfcmsa", r_max=...) / n_add=...

getCost

nocad.placement_cost

getSensors

nocad.driver_nodes / nocad.sensor_nodes

isCont, isObs

nocad.is_structurally_controllable with a dedicated B

evolveOperability, extendData

nocad.placement.improve_configuration

robust

nocad.node_removal_robustness, robustness_table

Exchanging data with the MATLAB toolbox#

nocad.io.write_mat(path, design) (or write_network(design, "file.mat")) stores A, B, C, D, the adjacency matrix adj, the node labels and the 1-based drivers and sensors for MATLAB; nocad.io.read_mat reads a file with A (and optionally B, C, D) as a state-space model or any square matrix as a network.

Differences#

  • Controllability tests. isControllable took the structural rank of the numerically formed Kalman matrix. That value is an upper bound of the generic rank, so it can report a dilation-ridden system as controllable. nocad uses Lin’s exact graph test (method="structural"), a numerical test on the given values ("kalman") or on a random realization ("generic"). On the example of the manual this changes the robustness of the improved configuration: removing \(x_8\) leaves \(x_4\) as the only driver with two children that have no other parent, a dilation, so \(x_8\) is a critical node too (robustness 5/9, not 6/9).

  • Control centrality is the generic dimension of the controllable subspace (random realization, orthogonal Krylov iteration); method="sprank" reproduces the MATLAB value.

  • Percentage of symmetric edges. The manual defines it per edge (40 % in its example); the MATLAB code counted node pairs (25 %). nocad follows the manual.

  • Annealing. The replacement node is never one that is already configured; the run keeps the best configuration it visited.

  • Driver types. Besides the MATLAB closure test, a driver node is internal if some maximum matching leaves it unmatched (Kőnig’s theorem); the closure test alone misses dilations inside large balanced components.

  • New in nocad: the exact minimum of dedicated inputs, node roles and edge classes, control profiles, edge-removal robustness, the visualization module, import/export with role annotations and the bundled networks.