# Adaptive Behaviour for a Self-Organising Video Surveillance System Using a Genetic Algorithm
## 2 Schedule Encoding and Fitness Function  
The genome we used is a two-dimensional binary array. Each line represents a camera and each column a time-slot in a periodic time window. A \"1\" indicates that the corresponding camera is in operation (i.e., streaming video) during a certain time-step while a \"0\" means that it is in stand-by mode. Overlapping coverage is encoded as a three-dimensional binary matrix of size \(w\times d\times n\), with \(w\) and \(d\) the width and depth of the monitored area (in meters), and \(n\) the number of cameras. If the one \(m^{2}\) cell centred on coordinates \((x,y)\) is within the field of view of a camera, then the corresponding entry is set to \"1\". This information, while assumed to be known in our study a priori, could be generated relatively easily, be, e.g., moving a physical target over the area and recording which cameras are able to track it simultaneously (solutions to this are proposed in the literature, see, e.g., in [24]). By cross-referencing this matrix with the activation schedule (genome), we determine whether a cell is being monitored by zero, one or more than one camera at any point in time. The area outside the field of view of any active cameras (\"blind spots\") is measured by subtracting the surface being monitored (by all devices, taking any overlap into account, i.e., every m\({}^{2}\) is only counted once) from the total area under surveillance. The fitness function \(F\) only takes three global input variables: \(A\) (the total activation time for all cameras, equivalent to the number of 1's in the schedule matrix; unit = \(s\)), \(B\) (the area of all \"blind spots\" over the duration of the periodic time-window; unit = \(m^{2}s\)) and \(C\) (the overlapping coverage, i.e., the area being monitored by more than one camera over the duration of the periodic time-window; unit = \(m^{2}s\)). Each variable's impact on the overall fitness is weighted by tunable parameters \(\alpha\), \(\beta\), and \(\gamma\), respectively,  
\[F=\alpha A+\beta B+\gamma C \tag{1}\]  
As all three input variables are to be minimised we are also interested in minimising \(F\): the lower the value of \(F\) the fitter the schedule. Our method is illustrated in Figure 1, for a simple 2-cameras example. The two boxes below the images represent two possible genomes, the images show the camera activation (over 4 times steps) defined in the genome on the left. In these genomes, the first line corresponds to the activation schedule of the first camera (horizontal orientation) and the second line to that of the second camera (vertical orientation). The red perimeter identifies the coverage area of each camera. Greyed squares are \"blind spots\" (not monitored), and orange squares are overlapping areas (monitored by more than one camera). For example, to optimise coverage we might set the weighting parameter values to, e.g., \(\alpha=2\), \(\beta=1\) and \(\gamma=2\). Under these settings, the schedule on the left in Figure 1 results in a fitness value \(F\) of 126 and is thus outperformed by the schedule on the right (score of 116). However, if we were more interested in saving resources, we might set \(\alpha\) to, e.g., 10 (while leaving the other parameters unchanged). Then, the schedule on the left scores 158 while the one on the right comes in at 164 (and thus the one on the left is better). In order to make weighting more transparent and considering that the values for \(A\), \(B\), and \(C\) are dependent on experimental parameters such as the size of the area to be monitored, the number of cameras, the length of the periodic time window, etc., we defined secondary, dimensionless variables \(A^{\prime}\), \(B^{\prime}\), and \(C^{\prime}\) as follows:  
\[X^{\prime}=\frac{X}{max(X)}\]  
where \(max(X)\) stands for the maximum possible value of the corresponding variable.