Network-Based Controllability and Observability Analysis in PythonThe nocad toolbox

Chapter 8
Placement of additional drivers and sensors

A configuration with the minimum number of inputs and outputs is rarely a good one: the states are far from the inputs and outputs, so the effect of an input arrives after many integrations and a disturbance is seen late. In the network this distance is the relative degree. This chapter shows that the relative degree equals the network distance plus one, defines the cost of a configuration used in the NOCAD papers, and presents the methods of the third NOCAD module that add driver and sensor nodes: grassroot and retrofit set covering, centrality-based retrofit, and two simulated annealing methods, mCLASA and the fuzzy-clustering-based GDFCMSA.

8.1 Problem and idea

The relative degree of an output with respect to an input counts the integrations between them, and it matters for control design: it fixes the delay with which an input acts on an output, it is the order of the derivative that input–output linearization needs, and a large relative degree makes a loop sluggish and sensitive to uncertainty [17, 18]. Daoutidis and Kravaris [18] showed that, for generic parameters, it can be read from the structure of the system as a path length. A minimal configuration of a chain of N states needs one input and one output and has relative degree N; an additional driver in the middle halves the largest distance (fig. 8.1). The placement problem is to add as few driver or sensor nodes as possible so that every state lies within a required distance, or to place a given number of them so that the distances are as small as possible. Leitold, Vathy-Fogarassy and Abonyi formulated both problems on the network and solved them by set covering, centrality and simulated annealing [2, 20].

Figure 8.1

Figure 8.1. An additional driver halves the largest distance. Numbers below the nodes are the control depths ρiC; the relative degree of an output at xi with respect to the nearest input is ρiC+1.

8.2 Theory

8.2.1 Relative degree and network distance

The relative degree rkl of output yk= 𝐜k𝐱 with respect to input ul (acting through 𝐛l) is the smallest r with 𝐜k𝐀r−1𝐛l≠0: the input appears in the r-th derivative of the output and not earlier.

Proposition 8.1 (Daoutidis and Kravaris [18]). Let ul act on the driver node d and yk read the sensor node s. For generic values of the free parameters, rkl=ℓds+1, where ℓds is the length of the shortest path from d to s (rkl=∞ if there is none).

Proof. The entry (𝐀t)sd is the sum, over all walks of length t from d to s, of the products of the edge weights along the walk. It vanishes identically for t<ℓds. For t=ℓds the walks are the shortest paths; distinct shortest paths use distinct sets of edges, so their products are distinct monomials in the free parameters and their sum is a non-zero polynomial, which is non-zero for almost all parameter values. □

When disturbances may act on every state, the worst case over the states matters. With ρi the control depth ρiC (distance from the nearest driver node) or the observation depth ρiO (distance to the nearest sensor node) of section 4.2.5, the relative order of a configuration is maxiρi, and the NOCAD papers measure its quality by

cost(𝒮,β)=βmaxiρi+(1−β)1 N∑i=1Nρi,(8.1)

which weighs the worst state against the average [20]. States that no configured node reaches are given the distance N, as in the MATLAB code.

8.2.2 Set covering

Let Rv(r) be the set of states that node v reaches within r steps. Every state lies within distance rmax of a configuration 𝒮 iff the sets Rv(rmax), v∈𝒮, cover all states: the smallest such configuration is a minimum set cover. Set cover is NP-hard, and the greedy algorithm, which repeatedly takes the set that covers most uncovered states, is within a factor H(maxv|Rv|)≤1+ln⁡N of the optimum [64]. Grassroot set covering applies it to the whole network. It ignores the matching condition and can lose controllability: in a star x1→{x2,x3,x4} the single node x1 covers every state within one step, but two leaves remain unmatched. Retrofit set covering keeps the nodes of a matching-based design and covers only what they leave uncovered. Since adding dedicated inputs to a structurally controllable system keeps it controllable, every configuration that contains a valid design is valid; this holds for retrofit, for the centrality-based method and for the annealing methods below.

8.2.3 Centrality-based retrofit

The MATLAB function analyseComponents assigns the states to their nearest configured node (the control regions of section 4.2.5) and, in every region whose largest depth exceeds rmax, adds the node with the largest product of normalized betweenness and out-closeness in the subnetwork of the region: a node through which many shortest paths pass and from which the region is reached quickly. nocad repeats the rounds on the re-partitioned network until the bound holds, which always terminates and agrees with the recursive MATLAB version when regions do not interact.

8.2.4 Simulated annealing: mCLASA and GDFCMSA

With a fixed number K+ of additional nodes, eq. (8.1) is a medoid problem on the network: the configured nodes are medoids and every state belongs to its closest one [65]. The K nodes of the matching-based design stay fixed; the additional ones move. Simulated annealing [66] proposes to replace a randomly chosen additional node by another state, accepts the move if it does not increase the cost, and otherwise with probability exp⁡(−Δ∕T), while the temperature decreases geometrically from Tmax=10 to Tmin=0.01. The two methods differ in the proposal [20]:

To meet a bound rmax, the number of additional nodes is increased one at a time, with several independent runs for each, until the best configuration found satisfies it (algorithm 8.1).

Algorithm\special {t4ht^+}

In a nutshell: Placement

  • Generically, relative degree = network distance +1; the relative order of a configuration is the largest depth of a state.
  • Cost: βmaxiρi+(1−β)meaniρi.
  • Grassroot set covering bounds the relative order with few nodes but may lose controllability; retrofit set covering, centrality-based retrofit and annealing keep the matching-based nodes and therefore controllability.
  • mCLASA and GDFCMSA solve the medoid problem for a given number of additional nodes; GDFCMSA guides its moves by geodesic fuzzy memberships.

8.3 Using it in nocad

nocad.placement.Placement(kind="drivers", method="gdfcmsa", r_max=None, n_add=None, beta=0.5, n_iter=500, n_runs=10, base="path_finding", random_state=None)

kind: "drivers" or "sensors"; method: "set_cover" (grassroot), "retrofit", "centrality", "mclasa", "gdfcmsa"; give r_max (bound) or n_add (number of nodes). fit(adj) sets base_nodes_, nodes_, n_added_, cost_, max_order_, mean_order_, depth_ and, for the annealing methods, history_.

functions

relative_degree_matrix(adj, drivers, sensors, classical), relative_degree, placement_cost(dist, nodes, beta); nocad.placement.configuration_cost(adj, nodes, kind, beta), improve_configuration(adj, r_max) (all five methods for drivers and sensors, MATLAB extendData), set_cover, set_cover_except, centrality_retrofit, anneal, annealing_placement, reach_within; nocad.viz.plot_placement_history.

Relative degrees and costs of the NOCAD example:

R = nocad.relative_degree_matrix(adj, design.driver_nodes_, design.sensor_nodes_) 
print("classical relative degrees (rows: sensors, columns: drivers):\n", R) 
print("relative order of the configuration:", nocad.relative_degree(adj, design.driver_nodes_, design.sensor_nodes_)) 
for drivers in ([7], [3, 7]): 
    cost, mx, mean = configuration_cost(adj, drivers, kind="drivers", beta=0.5) 
    print(f"drivers {np.add(drivers, 1)}: cost {cost:.4f}, max {mx:.0f}, mean {mean:.4f}")
   

The three heuristics with bound two:

results = {} 
for method in ("set_cover", "retrofit", "centrality"): 
    p = Placement(kind="sensors", method=method, r_max=2).fit(hen.adj) 
    results[method] = p 
    print(f"{method:10s} sensors={len(p.nodes_):2d} added={p.n_added_:2d} max={p.max_order_:.0f} " 
          f"mean={p.mean_order_:.2f} cost={p.cost_:.3f}")
   

The annealing methods for an increasing number of sensors:

for method in ("mclasa", "gdfcmsa"): 
    p = Placement(kind="sensors", method=method, r_max=0, n_iter=400, n_runs=5, random_state=0).fit(hen.adj) 
    hist[method] = p.history_ 
    print(method, p.history_[["n_added", "cost", "max_order", "mean_order"]].round(3).to_string(index=False))
   

All five methods at once, with their robustness:

table = improve_configuration(adj, r_max=2, beta=0.5, n_iter=300, n_runs=5, random_state=0) 
shown = table.assign(nodes=table.nodes.apply(lambda v: " ".join(f"x{i + 1}" for i in v))) 
print(shown[["kind", "method", "nodes", "cost", "max_order", "mean_order", "structural"]].round(4).to_string(index=False)) 
configs = {m: (table.query("kind == ’drivers’ and method == @m").nodes.iloc[0], 
               table.query("kind == ’sensors’ and method == @m").nodes.iloc[0]) for m in table.method.unique()} 
labels = [f"x{i + 1}" for i in range(9)] 
print(nocad.robustness_table(adj, configs, labels=labels).round(3).to_string(index=False))
   

8.4 Examples

8.4.1 Relative degrees and the cost

With the input at x8, the relative degrees of outputs at x1,…,x9 are 5, 4, 5, 3, 4, 2, 3, 1 and 4; the first non-zero Markov parameter of a random realization gives the same numbers (fig. 8.2). The sensors x1 and x9 of the minimal design have relative degrees five and four; the relative order of the configuration is four. With the single driver x8 the cost with β=0.5 is 3.22 (largest depth four, mean 2.44); a second driver at x4 lowers it to 1.56 (largest depth two, mean 1.11), the improvement suggested in the NOCAD manual. Ranking all second drivers (fig. 8.3) shows that x4 and x5 tie as the best choice for every β, whereas the order of the others depends on the weight: with β=1 the drivers x1, x2, x3 and x6 tie, with β=0 the mean distance prefers x2.

Figure 8.2

Figure 8.2. Relative degree of an output at every state with respect to the input at x8: network distance plus one (blue) and the first non-zero Markov parameter of a random realization (green).

Open in ColabExample plot_01_relative_degree.py in the gallery

Figure 8.3

Figure 8.3. Cost of the configurations {x8,xk} for three values of β.

8.4.2 Heuristics

The minimal design of the heat exchanger network has three sensors and observation depths up to six. With the bound rmax=2 (fig. 8.4), grassroot set covering needs seven sensors (mean depth 0.95), retrofit set covering adds four to the three of the minimal design (mean depth 1.00), and the centrality-based retrofit adds five (mean depth 0.86, the lowest cost). As the bound is relaxed from zero, where every state needs a sensor, to six, the number of sensors falls from 22 to three for every heuristic (fig. 8.5); on this network all configurations remain observable. The star of section 8.2.2 shows the failure that grassroot set covering can cause: it returns the single driver x1, which leaves two leaves uncontrollable, while retrofit returns x1, x3 and x4.

Figure 8.4

Figure 8.4. Observation depth maps of the heat exchanger network for the sensors placed by grassroot set covering, retrofit set covering and centrality-based retrofit with rmax=2.

Open in ColabExample plot_02_heuristics.py in the gallery

Figure 8.5

Figure 8.5. Number of sensors needed by the three heuristics on the heat exchanger network against the bound rmax.

8.4.3 Simulated annealing

For the sensors of the heat exchanger network both annealing methods find the same best configurations for every number of additional sensors (fig. 8.6): the cost falls from 4.32 with the minimal design (largest depth six) to 1.46 with four additional sensors (largest depth two) and 0.77 with seven (largest depth one). The difference is in the effort (fig. 8.7): for four additional sensors, the mean final cost of twenty runs of GDFCMSA is lower than that of mCLASA for 50 to 200 iterations, and both reach the same value with 400 iterations.

Figure 8.6

Figure 8.6. Best cost (left) and largest relative order (right) of five annealing runs against the number K+ of additional sensors of the heat exchanger network; the curves of the two methods coincide.

Open in ColabExample plot_03_annealing.py in the gallery

Figure 8.7

Figure 8.7. Final cost of twenty runs with K+=4 against the number of iterations: mean and the 10–90% range.

8.4.4 Comparison of the five methods

On the NOCAD example with rmax=2, all five methods add one driver to x8, at x4 (four methods) or x5 (mCLASA), with the same cost 1.56. The two choices differ in robustness: with x5 the configuration tolerates seven of nine node removals, with x4 five. For the sensors, grassroot set covering replaces the matching-based sensor x1 by x2 and x7 (cost 1.44); the other methods keep x1 and x9 and add x4 or x7 (cost 1.39). On the heat exchanger network (fig. 8.8) the methods need between nine and twelve nodes for rmax=1 and five to seven for rmax=3; the centrality-based retrofit needs the most in three of the four cases, the annealing methods always need the fewest, and no configuration loses controllability or observability.

Figure 8.8

Figure 8.8. Number of driver and sensor nodes found by the five methods on the heat exchanger network for rmax=1 (left) and rmax=3 (right).

Open in ColabExample plot_04_method_comparison.py in the gallery

8.5 Further reading

The structural characterization of the relative degree is due to Daoutidis and Kravaris [18]; Isidori [17] explains its role in nonlinear control. The placement methods are from Leitold, Vathy-Fogarassy and Abonyi [2, 20], and their application to heat exchanger networks from [21, 22]. Greedy set cover is analyzed by Chvátal [64], simulated annealing introduced by Kirkpatrick, Gelatt and Vecchi [66], medoid clustering described by Kaufman and Rousseeuw [65], and geodesic fuzzy c-medoid clustering by Király, Vathy-Fogarassy and Abonyi [68]. Summers, Cortesi and Lygeros [70] and Pasqualetti, Zampieri and Bullo [16] study input placement from the energy point of view, a complementary, numerical criterion.