Network-Based Controllability and Observability Analysis in PythonThe nocad toolbox

Chapter 3
Maximum matching and the design of inputs and outputs

Lin’s theorem tells whether a given set of inputs makes a system controllable; this chapter turns it into a design method. A maximum matching of the state network gives the minimum number of driver nodes and, by its unmatched nodes, one place for them (the minimum input theorem of Liu, Slotine and Barabási). Matchings alone, however, overlook source components that are perfectly matched by cycles. The chapter presents the two remedies of the NOCAD toolbox, signal sharing and path finding, and an exact formulation that computes the minimum number of dedicated inputs with one more matching. Sensors follow by duality.

3.1 Problem and idea

Condition (ii) of Lin’s theorem asks for a matching that assigns a distinct parent to every state; an input can serve as the parent of one state. If a matching M of the state network already assigns parents to |M| states, the remaining N−|M| states, the unmatched ones, each need an input of their own. The fewer unmatched nodes, the fewer inputs, so the matching should be as large as possible: a maximum matching. This is the minimum input theorem [10].

The theorem settles condition (ii); condition (i), accessibility, is a separate matter. Every source component of the condensation must contain a driver node, because nothing outside it can reach it. If a source component contains an unmatched node, that node is a driver node and the component is reached. If all its nodes are matched, the matching covers it by cycles, and the minimum input theorem places no input in it at all (fig. 3.1). Liu and co-authors repaired this by sending the signal of an existing input into such a component as well (signal sharing) [11]. Leitold, Vathy-Fogarassy and Abonyi observed that the defect comes from cycles of the matching that close inside a source component: by exchanging one matched edge, the cycle can be opened into a path that continues into an unmatched node outside, so that one new driver node controls both the component and the node outside, and every input drives a single state (path finding) [1].

Figure 3.1

Figure 3.1. A perfectly matched source component and its two remedies. (a) The maximum matching (green) covers the cycle {x1,x2} and leaves only x3 unmatched; the cycle is not reached by the input. (b) Signal sharing feeds the cycle with the signal of u1. (c) Path finding exchanges the matched edge x2→x1 for x2→x3: the stem now starts at x1, runs through the cycle and continues to x4.

3.2 Theory

3.2.1 Matchings in directed networks

A matching M⊆E of a directed network is a set of edges no two of which share a start node or an end node; a node is matched if an edge of M ends in it and unmatched otherwise. Splitting every node xi into an out-copy xi+ and an in-copy xi− and every edge xj→xi into an undirected edge {xj+,xi−}gives the bipartite representation B(𝒢); directed matchings of 𝒢 are exactly the matchings of B(𝒢). In a matching, every node has at most one incoming and one outgoing matched edge, so the matched edges form vertex-disjoint directed paths and cycles; every path starts at an unmatched node. The size of a maximum matching equals the generic rank of 𝐀, and the Hopcroft–Karp algorithm finds one in O(|E|N) time [28]. (The MATLAB toolbox obtained the matching from the Dulmage–Mendelsohn decomposition [29, 30].)

Definition 3.1 (minimum input theorem [10]). The minimum number of inputs that make 𝒢 structurally controllable, when an input may act on several states, is ND=max(N−|M∗|,1), where M∗ is a maximum matching; the unmatched nodes of M∗ are a set of driver nodes.

The theorem relies on the freedom to let one input act on several states: in a perfectly matched source component the extra signal needed for accessibility comes from an existing input. The number of driver nodes is unique, their positions are not: a network generally has many maximum matchings, and chapter 5 studies what they have in common. Sensor nodes are obtained by the same construction on the reversed network 𝒢𝖳, since observability of (𝐀,𝐂) is controllability of (𝐀𝖳,𝐂𝖳) [11].

3.2.2 Signal sharing

Let 𝒞 be a source component all of whose nodes are matched. Signal sharing gives every unmatched node a dedicated input and adds one node of every such component to the first input. The input matrix then has max(N−|M|,1) columns, the first of which may contain several non-zeros. The number of inputs is minimal in the sense of the minimum input theorem; the number of driver nodes is larger by the number of shared components. Because the shared nodes depend on which maximum matching was found, the number of driver nodes can vary between runs.

3.2.3 Path finding

A matched source component 𝒞 is covered by cycles of M. If an edge xj→xk leaves 𝒞 toward an unmatched node xk, the node xj is matched inside 𝒞 by an edge xj→xi. Removing xj→xi from M and adding xj→xk keeps the size of the matching, makes xi unmatched, and matches xk: the cycle through xj is opened into a path that starts at the new driver node xi and continues into xk, so one input controls both. If no such edge exists, one matched edge inside 𝒞 is removed and its end node becomes a driver node. The method processes the components one after the other (algorithm 3.1); a component whose nodes already continue outward through a matched edge, or that contains an unmatched node, needs nothing. The number of driver nodes is the number of unmatched nodes plus the number of matched source components that cannot be opened toward an unmatched node; when several components point to the same unmatched node, only one of them can use it [1].

Algorithm\special {t4ht^+}

3.2.4 The exact minimum of dedicated inputs

Path finding is greedy: the components claim unmatched nodes in the order they are visited, and the initial maximum matching decides which nodes are unmatched in the first place. Both choices can cost driver nodes. The exact minimum follows from Lin’s theorem directly. A set 𝒟 of driver nodes with dedicated inputs makes 𝒢 controllable iff (ii) the unmatched nodes of some matching M of 𝒢 lie in 𝒟 (an input is the parent of one node) and (i) every source component contains a node of 𝒟. Hence

|𝒟|≥(N−|M|)+(β−h(M)),(3.1)

where β is the number of source components and h(M) the number of source components that contain an unmatched node of M. Extend the bipartite graph B(𝒢) by one slack out-vertex sk per source component 𝒞k, joined to the in-copies of the nodes of 𝒞k, and call the extended graph B′. A matching of B′ consists of a matching M of 𝒢 and, for some source components, a distinct node of the component left unmatched by M; its size is |M|+h(M) at most. Every pair (M,h) is realized this way, so the bound eq. (3.1) is minimized by a maximum matching M′ of B′:

NDmin=N+β−|M′|.(3.2)

The bound is attained by the unmatched nodes of M plus one node of every source component that M′ leaves unhit; in such a component one matched edge is removed, so that every driver node is the start of a stem, as in path finding (algorithm 3.2). The same count was derived by Commault and Dion [31] and, as the minimum number of dedicated inputs, by Pequito, Kar and Aguiar [32]; the extended matching makes it one call of the Hopcroft–Karp algorithm.

Algorithm\special {t4ht^+}

In a nutshell: Input and output design by matching

  • Unmatched nodes of a maximum matching are driver nodes (minimum input theorem); sensors come from the reversed network.
  • Perfectly matched source components need extra care: signal sharing (one input, several nodes) or path finding (open a cycle into a stem).
  • Path finding gives dedicated inputs; it is greedy and may exceed the minimum when components compete for the same unmatched nodes.
  • The exact minimum N+β−|M′| needs one matching of the bipartite graph extended by a slack vertex per source component.
  • Every design is checked by Lin’s theorem: InputOutputDesign.is_controllable().

3.3 Using it in nocad

nocad.InputOutputDesign(method="path_finding")

method: "path_finding", "signal_sharing", "minimum" (exact, algorithm 3.2) or "matching" (unmatched nodes only, for comparison). fit(adj) sets A_, B_, C_, D_ (sparse), control_matching_, observation_matching_, driver_nodes_, sensor_nodes_, shared_driver_nodes_, n_inputs_, n_drivers_, n_outputs_, n_sensors_; methods matrices(), is_controllable(), is_observable().

functions of nocad.matching and nocad.design

maximum_matching(adj) returns a Matching with matched_by, matched, unmatched, edges, size; all_maximum_matchings(adj) enumerates them for small networks; maximum_matching_pf, maximum_matching_ss and maximum_matching_min return the corrected matchings in the format of the MATLAB functions; driver_nodes(adj, method), sensor_nodes(adj, method) and generate_matrices(adj, method) give the nodes and the matrices directly.

The matching of the four-node example of the NOCAD manual:

adj = load_four_node_example().adj 
m = nocad.maximum_matching(adj) 
print("size of the matching:", m.size) 
print("matched edges (start, end):", (m.edges + 1).tolist()) 
print("unmatched (driver) nodes:", m.unmatched + 1)
   

The three designs of the cycle with a tail, as input matrices:

adj = make_cycle_example().adj  # x1 <-> x2 -> x3 -> x4 
for method in ("signal_sharing", "path_finding", "minimum"): 
    A, B, C, D = nocad.generate_matrices(adj, method) 
    print(f"{method:15s} B^T =", B.toarray().astype(int).T.tolist())
   

3.4 Examples

3.4.1 A three-cycle with a tail

The four-node network of the NOCAD manual (fig. 3.2) has matchings of size three: one node stays unmatched and one input suffices. There are two maximum matchings (fig. 3.3). The first covers the cycle x1→x2→x3→x1 and leaves the tail x4 unmatched. The second runs the stem from x1 through the cycle into x4. Both are valid designs: with the input at x4 the cycle is a source component that receives nothing, which path finding repairs by exchanging x3→x1 for x3→x4, the second matching. Nodes x1 and x4 are driver nodes in some minimum driver set, x2 and x3 in none.

Figure 3.2

Figure 3.2. A maximum matching in two pictures: matched edges on the network (left) and in the bipartite representation (right), where the unmatched in-copy x4− marks the driver node. Edge colors in the bipartite view: critical (green) edges are in every maximum matching, ordinary (orange) edges in some (chapter 5).

Open in ColabExample plot_02_maximum_matching.py in the gallery

Figure 3.3

Figure 3.3. The two maximum matchings of the four-node network leave different nodes unmatched: the number of driver nodes is unique, their positions are not.

The share of driver nodes of random networks falls with the mean degree (fig. 3.4), the classical result of Liu, Slotine and Barabási [10]. Sparse networks contain many source and sink nodes and many dilations; heterogeneous (scale-free) networks need more driver nodes than Erdős–Rényi networks of the same mean degree.

Figure 3.4

Figure 3.4. Share of driver nodes of Erdős–Rényi and scale-free networks with 300 nodes against the mean degree.

3.4.2 Signal sharing, path finding and the exact minimum

For the cycle x1↔x2 feeding the chain x3→x4 (fig. 3.5), the maximum matching covers the cycle and leaves x3 unmatched. Signal sharing therefore uses one input acting on two states, x3 and x1 (𝐁𝖳=[1,0,1,0]), whereas path finding and the exact minimum use one input acting on x1 alone (𝐁𝖳=[1,0,0,0]).

Figure 3.5

Figure 3.5. The three designs of a cycle with a tail. Signal sharing feeds the matched source cycle with the signal of the input at x3 (dotted); path finding and the exact minimum open the cycle into a stem that starts at x1.

Open in ColabExample plot_03_path_finding_signal_sharing.py in the gallery

Two cycles that compete for the same unmatched node show where the greedy method loses (fig. 3.6). The cycle {x1,x2} points to x5 and x6, the cycle {x3,x4} only to x5. Path finding opens the first cycle toward x5; the second has nothing left to claim, so it is cut, and x6 keeps its own input: three dedicated inputs. The exact minimum lets the first cycle continue to x6 and the second to x5: two inputs. Signal sharing also uses two inputs, but drives four nodes.

Figure 3.6

Figure 3.6. Two source cycles compete for x5: path finding needs three dedicated inputs, the exact minimum two; signal sharing uses two inputs and four driver nodes.

Figure 3.7 repeats the comparison on sparse random networks with an increasing share of self-loops, which turn single nodes into strongly connected components. Signal sharing needs the fewest inputs: with self-loops on every node the matching is perfect and a single shared input remains. Counted in driver nodes with dedicated inputs, path finding stays within a few percent of the exact minimum.

Figure 3.7

Figure 3.7. Inputs and driver nodes of random networks (200 nodes, mean degree 1.5) as self-loops are added: signal sharing minimizes the inputs, path finding and the exact minimum the dedicated driver nodes.

3.5 Further reading

The minimum input theorem is due to Liu, Slotine and Barabási [10], its observability counterpart and signal sharing to [11], path finding to Leitold, Vathy-Fogarassy and Abonyi [1, 3]. Commault and Dion [31] and Pequito, Kar and Aguiar [32] characterize the minimal numbers of additional and of dedicated inputs; Olshevsky [33] shows that the corresponding numerical problem, the minimal controllability problem for a given matrix, is NP-hard, which underlines the value of the structural formulation. Hopcroft and Karp [28] give the matching algorithm, Dulmage and Mendelsohn [29] and Pothen and Fan [30] the decomposition behind the MATLAB implementation.