*2.2. Procedure 2—Optimal Sensor Placement*

Let a set *S* of potential contamination events considered in the analysis, each of which featuring a certain location, starting time, duration, and total mass, be defined. In this context, sensor placement was formulated as a bi-objective optimization problem [51], in which the first objective function is *f3* = *Nsens* (number of installed sensors), as a surrogate for the installation cost for WDN monitoring, while the second objective function is:

$$f\_4 = pop = \frac{\sum\_{r=1}^{S} pop\_r}{S} \tag{5}$$

The objective function *f* <sup>4</sup> is related to the contaminated population *popr* before the first detection of the generic *r*-th contamination event. This corresponds to the sum of the inhabitants served by the contaminated nodes and can be evaluated using the EPANET quality solver [52], using an unreactive contaminant. The EPANET quality solver can be applied to the flow field obtained following procedure 1. If the *r*-th event is not detected, *popr* includes all the nodes crossed by the contamination till the whole contaminant mass leaves the WDN. Though numerous objective functions can be used for the optimal installation of sensors, the population exposed to contamination was chosen as the objective function to minimize along with the number of sensors. This choice was made because, compared to other potential objective functions (such as detection likelihood and sensor redundancy), the population exposed to contamination represents more directly the impact of contamination, which is the most meaningful from the viewpoint of risk assessment and mitigation. The time interval Δ*treact* for the activation of emergency operations is set to 0 hr hereinafter for simplifying purposes. This means that contamination is assumed to stop instantaneously after its detection. However, Δ*treact* can be set to other values without loss of validity of the whole methodology. The function *f4* is therefore the average value pop of *popr*. In the bi-objective optimization, functions *f3* and *f4* are minimized simultaneously through the NSGAII genetic algorithm [46]. In fact, the minimization of the former reduces the sensor cost while the minimization of the latter impacts positively on the system security. In the population individuals of NSGAII, the number of genes is equal to the number of network nodes where sensors can be installed. Each gene can take on the two possible values 0 and 1, which stand for absence and presence of the sensor in the node associated with the gene, respectively.

In this paper, four options for sensor locations on the partitioned network were tested:


In the last two cases, the idea is to take advantage from the study of WDN topology in order to define which nodes are potential candidates for sensor installation, according to their connectivity centrality. In this paper, the most central nodes were defined using the betweenness centrality [53], defined starting from the shortest paths in a graph. The shortest path σ*(s, t)* between two nodes *s* and *t* is the connecting path with the lowest number of links (or the minimum sum of the weights associated with its links in the case of weighted graph). The betweenness centrality of a node *i* is defined as the sum of the ratios of the number of shortest paths between nodes *s* and *t* passing through *i* to the total number of shortest paths between nodes *s* and *t*. It is a measure of the influence of a node *i* over the flow of information between other nodes. In this paper, for each cluster, the nodes with the highest value of betweenness centrality were selected as possible sensor locations alone (*Option 3*) or in combination with boundary nodes (*Option 4*). *Options 2*, *3*, and *4* aim to investigate the possibility of limiting the search for optimal sensor locations to the hydraulically upstream nodes of the flow meter-fitted boundary pipes and to the most central nodes of each district. This choice leads to significant computational simplifications, due to the reduction in the search space. This offers the possibility of better facing the problem of optimal sensor placement also for big-size WDNs (for which the number of all potential scenarios makes the problem computationally intractable). Furthermore, the strategy of locating all or some sensors in the same stations as boundary flowmeters offers easiness and cheapness of inspection and maintenance.
