Chapter 2
Foundations: controllability and observability of structured
systems
This chapter collects the notions the rest of the book builds on: linear state-space models, controllability and observability with the tests of Kalman and of Popov, Belevitch and Hautus, structured systems and their generic properties, the network of the state variables, and Lin’s theorem, which reduces structural controllability to two conditions on that network. It also fixes the notation of the book and the conventions of the nocad API, and shows on two small examples why the network must be built from the state equations and where structural results end.
2.1 Problem and idea
A linear time-invariant system with state variables, inputs and outputs is written as
| (2.1) |
with , , and . The entry tells how strongly the state variable influences the rate of change of . Forgetting the values and keeping only whether an entry is zero leaves a directed network: the nodes are the state variables, and an edge is drawn whenever (fig. 2.1). The adjacency matrix of this network, whose row lists the successors of , is the transpose of . Inputs become extra nodes with edges into the states they act on, outputs extra nodes with edges from the states they measure.
The idea of the structural approach is that many properties of eq. (2.1) depend on this network only, for almost all values of the non-zero entries. Controllability is such a property: Lin showed that it holds for almost all values if and only if every state can be reached from an input and no group of states depends on fewer states and inputs than it contains [5]. Both conditions are cheap to test on the network, which is what makes the analysis of large systems possible.
2.2 Theory
2.2.1 Controllability and observability
The system eq. (2.1) is controllable if for every initial state and every target there is an input that drives the state to in finite time, and observable if the initial state can be determined from the input and the output over a finite interval. Kalman’s criterion [4] reduces both to rank conditions,
| (2.2) |
The column space of is the controllable subspace: the states that the inputs can reach from the origin. Observability of is controllability of the dual pair , so every result on controllability has an observability counterpart obtained by reversing all edges of the network. The Popov–Belevitch–Hautus (PBH) test gives the same answer mode by mode: is controllable iff for every eigenvalue of ; an eigenvalue that violates the condition is an uncontrollable mode.
Numerically, the Kalman matrix is a poor object: its columns are the powers of applied to , which grow or shrink geometrically, and its rank is ill-determined for systems of more than a few dozen states. nocad computes the dimension of the controllable subspace with an orthogonal Krylov iteration instead: the space spanned by is built one orthonormal direction at a time, and the iteration stops when maps the current block into the space already found (algorithm 2.1). This is the controllability staircase of numerical linear algebra.
2.2.2 Structured systems
A structured matrix is a matrix whose entries are either fixed zeros or free parameters. A property of a structured system holds generically if it holds for all values of the free parameters except those on a proper algebraic variety, a set of measure zero. Controllability is generic in this sense: if it holds for one numerical realization of the pattern, it holds for almost all of them, and the system is then called structurally controllable [5, 6]. The generic rank of a structured matrix is the rank of almost all its realizations; it equals the largest number of non-zero entries no two of which share a row or a column, the size of a maximum matching between the rows and the columns through the non-zero entries (König–Egerváry; see [8]). Likewise, the dimension of the controllable subspace takes one value for almost all realizations, its generic dimension, which Hosoe characterized by a graph-theoretic formula [27]. nocad evaluates it by algorithm 2.1 on a random realization of the pattern: with probability one the generic value is attained.
2.2.3 The network of the state variables
The state network has the state variables as nodes and an edge for every ; a diagonal entry is a self-loop. Its adjacency matrix is . The system graph adds the inputs with edges for and the outputs with edges for . A state that receives an edge from an input is a driver node, a state that sends an edge to an output a sensor node. Paths, cycles, and strongly connected components are used in their usual sense: a strongly connected component (SCC) is a maximal set of nodes that can all be reached from each other, a source SCC receives no edge from outside, and a sink SCC sends none. Table 2.1 summarizes the notation of the book.
| Symbol | Meaning | Code |
| numbers of states, inputs, outputs | n_states | |
| state-space matrices; iff appears in | A, B, C, D | |
| adjacency matrix of the state network, row : successors of | adj | |
| , | state network and the reversed network | adj, adj.T |
| matching: edges without common start or end node | Matching | |
| out-copy and in-copy of in the bipartite representation | — | |
| driver nodes and their number | driver_nodes_ | |
| sensor nodes and their number | sensor_nodes_ | |
| strongly connected components | condensation | |
| length of the shortest path ( if none) | geodesic_distances | |
| relative degree of with respect to | relative_degree_matrix | |
| control and observation depth of | control_depth | |
| weight of the worst case in the placement cost | beta |
2.2.4 Lin’s theorem
Two structural defects make a system uncontrollable for all parameter values. A state is inaccessible if no input can reach it in the system graph: its value is not influenced by the inputs at all. A set of states contains a dilation if the set of nodes (states or inputs) with an edge into is smaller than : . Then the rows of that belong to have their non-zeros in only columns, the matrix cannot have full rank, and some combination of the states in cannot be steered independently. The simplest dilation is a star: one node feeding and , which have no other parents (fig. 2.2).
Definition 2.1 (structural controllability [5, 6]). The structured pair is structurally controllable iff (i) every state is accessible from an input in and (ii) contains no dilation, equivalently .
Condition (ii) is a matching condition: means that a matching in the bipartite graph between the columns (states and inputs) and the rows (states) covers every row, so that every state can be assigned a distinct parent. Lin also gave a constructive form of the theorem. A stem is a directed path that starts at an input; a bud is a directed cycle together with one extra edge, the distinguished edge, that enters it from a node outside the cycle; a cactus is a stem with buds attached to it, each bud attached through its distinguished edge to a node of the stem or of a bud attached earlier.
Remark 2.1 (cactus theorem). is structurally controllable iff the system graph is spanned by a disjoint union of cacti [5]. A design found by maximum matching contains such a spanning set: its matched edges form the stems and the cycles, and an unmatched edge anchors every cycle (section 4.2.3).
Lin’s two conditions are tested in linear time: a breadth-first search from the driver nodes decides accessibility, and a maximum bipartite matching between the columns and the rows of decides the generic rank (algorithm 2.2). Observability is tested on the reversed network with the outputs as inputs.
In a nutshell: Structural controllability
- A structured system is structurally controllable if almost all realizations of its pattern are controllable.
- Lin’s theorem: every state accessible from an input, and (no dilation).
- Equivalently, the system graph is spanned by disjoint cacti: stems from the inputs with buds attached.
- Both conditions are checked in time; observability is the same test on the reversed network.
- Special parameter values (identical subsystems) can still destroy controllability: check numerically when symmetries are expected.
2.3 Using it in nocad
The conventions of the package mirror those of the MATLAB toolbox and of the book. A network is passed as its adjacency matrix adj (a NumPy array, a SciPy sparse matrix, a NetworkX DiGraph, or a square pandas DataFrame); nocad.as_adjacency converts any of these to a boolean sparse matrix. Functions of a network take adj; functions of a system take the state matrix Aadj.T and the input or output matrix: driver_nodes(adj) but is_controllable(A, B). Nodes are numbered from zero. Estimators follow the scikit-learn style: parameters in the constructor, fit(adj) returns the estimator, results are attributes with a trailing underscore. Plotting functions take an optional ax and return the axes; layout algorithms return node positions that can be reused across panels.
nocad.is_controllable(A, B, method="structural") / is_observable(A, C, ...)
method="structural": Lin’s test on the zero patterns (exact, linear time); "kalman": dimension of the controllable subspace of the given numerical matrices (algorithm 2.1); "generic": the same on a random realization of the patterns. Related functions: is_structurally_controllable, structural_rank, controllable_subspace_dimension, generic_controllable_dimension, pbh_uncontrollable_modes, adjacency_to_state_matrix.
The water tanks of section 2.4 are built and designed as follows:
variants = { "physical (pipes only)": make_water_tanks(3, "branch", "physical"), "free outflow (self-loops)": make_water_tanks(3, "branch", "free_outflow"), "connected vessels (loops + pairs)": make_water_tanks(3, "branch", "connected"), } for name, tanks in variants.items(): A = nocad.adjacency_to_state_matrix(tanks.adj).toarray().astype(int) # A = W^T design = nocad.InputOutputDesign().fit(tanks.adj) print(f"{name:34s} drivers={design.driver_nodes_ + 1} sensors={design.sensor_nodes_ + 1}")
and Lin’s test is compared with the numerical test on a star:
for name, net in (("star", star), ("star with self-loops", loops)): A = net.T # state matrix of the network print(f"{name:22s} structurally controllable: {is_structurally_controllable(A, b)}") A_same = loops.T.copy() A_same[np.arange(1, n_leaves + 1), np.arange(1, n_leaves + 1)] = -1.0 # identical leaves print("identical leaves, Kalman dimension:", controllable_subspace_dimension(A_same, b)) A_diff = A_same.copy() A_diff[np.arange(1, n_leaves + 1), np.arange(1, n_leaves + 1)] = [-1.0, -2.0, -3.0] print("distinct leaves, Kalman dimension:", controllable_subspace_dimension(A_diff, b))
2.3.1 Import, export and role annotations
Networks come from other software and results go back to it, so nocad keeps the names of the nodes and converts in both directions. A NetworkX graph, a pandas data frame or an igraph graph can be passed wherever a network is expected; its node names become the labels of every table and figure, and an estimator stores them as labels_. Positions may be NetworkX pos dictionaries, and default_layout offers the NetworkX layouts besides the layouts of chapter 4. The function nocad.annotate collects in two pandas tables everything the toolbox knows about a configuration: for every node whether it is a driver or sensor node and through which input or output, its role across all maximum matchings, its driver or sensor type, its strongly connected component and level in the hierarchy, its control and observation depth and region, and its part in the cacti; for every edge whether it is matched, its class across all maximum matchings, its part in the cacti and its connection type. Every export carries these columns as attributes, so that other tools can filter and style the network by the same roles, and every file written by nocad is read back with its configuration (table 2.2).
| format | extension | read | write | typical use |
| GraphML | .graphml | yes | yes | yEd, Cytoscape, NetworkX, igraph |
| GEXF | .gexf | yes | yes | Gephi, with role colors and positions |
| GML | .gml | yes | yes | igraph and other network tools |
| Cytoscape JSON | .cyjs | yes | yes | Cytoscape and Cytoscape.js, with role classes and positions |
| node-link JSON | .json | yes | yes | D3.js and web applications |
| DOT | .dot | — | yes | Graphviz; components of one level share a rank |
| Pajek | .net | yes | yes | Pajek |
| edge list | .edgelist | yes | yes | plain text with the node order in a header |
| CSV, TSV | .csv, .tsv | yes | yes | spreadsheets; node table in *_nodes.csv |
| Excel | .xlsx | yes | yes | node, edge and summary sheets |
| MATLAB | .mat | yes | yes | the NOCAD MATLAB toolbox: and labels |
| NumPy | .npz | yes | yes | compact binary storage |
nocad.io and nocad.annotation
read_network(path) and write_network(obj, path, layout="hierarchy") (aliases of io.read, io.write); from_networkx(G, weight), to_networkx(adj, labels, annotate=True), from_igraph, to_igraph, from_pandas_edgelist, to_pandas, from_state_space(A, B, C, D), from_control(sys) and to_control(design) for python-control, read_mat, write_mat, to_dot; annotate(adj, design, drivers, sensors, centrality, robustness) returns nodes, edges and graph; InputOutputDesign.annotate(), .to_networkx() and .write(path) do the same for a fitted design; nocad.viz.plot_annotation(adj, column) colors the nodes by any column.
A process network built in NetworkX is designed, annotated, exported and read back:
design = nocad.InputOutputDesign("minimum").fit(G) # node names are kept print("drivers:", [design.labels_[v] for v in design.driver_nodes_], " sensors:", [design.labels_[v] for v in design.sensor_nodes_]) ann = design.annotate() # node and edge tables (pandas) print(ann.nodes[["label", "io_role", "control_role", "scc", "control_level", "control_depth", "control_cactus"]].to_string(index=False)) out = pathlib.Path(tempfile.mkdtemp()) for ext in (".graphml", ".gexf", ".cyjs", ".dot", ".csv", ".xlsx", ".mat"): files = design.write(out / f"process{ext}") # annotations become attributes print(f"{ext:9s}", ", ".join(f"{p.name} ({p.stat().st_size} B)" for p in files)) net = nocad.read_network(out / "process.graphml") # the configuration comes back print("read back:", net.labels, "drivers", net.drivers.tolist(), "sensors", net.sensors.tolist())
2.4 Examples
2.4.1 Pipes are not state equations
Three tanks, the first feeding the other two, are read in three ways (fig. 2.3). The physical topology has one edge per pipe; it contains a dilation at and two sinks, so two inputs and two outputs are needed. If the outflow of every tank depends on its own level, every state has a self-loop. A self-loop lets a state be matched by itself, which removes the dilation: one input at controls all three tanks. The two sinks remain, and with them the two outputs. If the tanks are connected vessels, the flow through a pipe depends on the levels at both ends, every pipe contributes a pair of edges, and the network becomes strongly connected: one input and one output suffice. Figure 2.4 repeats the comparison for up to ten tanks. The physical reading needs an input and an output for nearly every tank, the dynamical readings need one input, and only the connected vessels also need just one output.
Open in ColabExample plot_01_state_space_network.py in the gallery
2.4.2 Structurally controllable, numerically not always
A hub driving three leaves is the textbook dilation (fig. 2.5, left): one input at the hub cannot control the leaves independently, and Lin’s test fails. Self-loops on the leaves remove the dilation and the pattern becomes structurally controllable (right). Whether a particular realization is controllable depends on the values: when the three leaves have the same dynamics (), the input acts on them identically and the controllable subspace has dimension two only, whereas distinct values () give the full dimension four. Figure 2.6 quantifies the effect. When the leaf dynamics are drawn from a small set of values, coincidences are frequent and many realizations are uncontrollable. With continuous random values every realization is controllable, as the generic nature of the property promises.
Open in ColabExample plot_04_structural_vs_numeric.py in the gallery
2.4.3 A named process network, from NetworkX and back
The process of the snippet above, a reactor with a cooling jacket and a separator whose bottom stream is recycled, has seven states named after the variables they stand for. The exact minimum needs one input, at the separator level hS, and one output, at the product concentration cP. The annotated graph that design.to_networkx() returns carries enough information for NetworkX to draw the hierarchy on its own (fig. 2.7): the multipartite layout takes the levels of the condensation from the control_level attribute, the colors from io_role, the thick edges from control_matched. Every node is intermittent, since the self-loops and the recycle leave many maximum matchings. Figure 2.8 shows two further columns of the table with plot_annotation on a NetworkX layout: the control depth, which reaches four at the jacket temperature TJ, and the part of the control cactus, a stem hScScP with the other states on buds hanging from it. For the frontal neurons of C. elegans the same tables show at once that the ten critical neurons all start stems, and that the two driver nodes which are not source neurons are internal dilations.
Open in ColabExample plot_05_interoperability.py in the gallery
2.5 Further reading
Kalman’s paper [4] and any textbook of linear systems cover the rank tests. Lin [5] introduced structural controllability for single inputs, Shields and Pearson [6] extended it to several inputs, and Hosoe [27] gave the generic dimension of the controllable subspace. Reinschke [7] and Murota [8] develop the graph and matroid theory of structured systems, and the survey of Dion, Commault and van der Woude [9] collects the generic properties of structured systems and their graph characterizations. The role of the balance equations in the structure of process models is explained by Hangos and Cameron [26].