1 Introduction

With the advent of the Internet of Things (IoT), a plethora of smart devices appeared in our daily lives and in our homes. IoT devices are necessary for unlocking the potential of regular homes to become smart homes, but not sufficient. Single devices can achieve limited results; they must interact with each other and combine their output data for delivering the complex features offered by a typical smart home. This is particularly critical for Ambient Assisted Living (AAL) applications, which aim to assist disabled people and elderly ones, enabling them to retain their independence.

As noted by Benmansour et al. (2015), the largest body of research on smart homes focused on mono-occupant scenarios, assuming only one person in the environment. Less work about multi-occupancy has been done until today, but more will be done in the future. Taking into consideration multi-occupancy is extremely important for AAL applications, and smart homes in general. Elderly and sick people require help from visiting nurses; people in general have guests for birthday parties and movie nights. Such events introduce a considerable amount of variability that can easily disrupt mono-occupancy systems, and that multi-occupancy systems will have to recognise and manage.

One of the most important building blocks for developing multi-occupancy systems, is the capability of counting people. People counting enables smart homes to combine more effectively ground truths and to reason more efficiently about inferred data. For example, a context-aware system might need to know that two people are hosted in a smart home to correctly interpret observed data. Such information can be an external input, or inferred by the context-aware system itself.

Researchers developed reliable techniques for vision-based human detection and counting, such as Paul et al. (2013), Raghavachari et al. (2015), Sun et al. (2020), but such techniques require cameras, which are expensive and can invade privacy. On the other end, binary sensors are cheap and, positioned strategically, can be used for counting people, even though they can produce only two states. Renoux et al. (2018) showed that it is possible to perform online counting of people, reasoning about the activation patterns of simple binary sensors.

Break-beam sensors are among the cheapest binary sensors, and their working principle is simple. Whenever a person walks in front of the sensor, the beam is interrupted and the sensor changes its output bit. By using two of them sequentially, it is possible to assess the walking direction, inferring if people are entering or exiting, and keeping an updated people counter.

Potentially, a single binary sensor can count infinite people, assuming sufficient geographical information. Imagine a factory that organises educational visits. Typically, there is an entrance, a predefined route, and an exit which is different from the entrance. If we place a break-beam sensor at the entrance, and we assume that none ever walks out of the entrance, a single binary sensor can count vast numbers, if we store the increasing counter. This can happen only because we have sufficient spatial knowledge. We know how people move in the factory, where the break-beam sensor is deployed, and that the counter can only increase throughout time - maintaining de facto memory about past events.

If one of the aforementioned conditions is not met, the capability of counting more than one person is lost. Lacking spatial knowledge and the walking path constraints prevents from detecting if a single person goes back and forth x times. If the system lacks the capability of retaining memory, any activation of the break-beam sensor is an independent event that does not add up to the previous ones and is simply lost. In other words, if we miss such conditions and we take a random snapshot of a binary sensor, at any time of the day, the only certain knowledge that we can obtain is if the sensor is currently active, or not.

In this paper, we investigate theoretical bounds for real-time people counting, when solely relying upon snapshot observation of active sensors. The main objective is to propose a technique that, given a set of binary sensors, defines a theoretical lower-bound on the calculable number of occupants, demonstrating that it is possible to define such a lower-bound. While our goal is different from performing people counting, the inferred knowledge could be used as a preprocessing phase for narrowing down the range of acceptable solutions for probabilistic reasoners, as we discuss in Sect. 6.

First, we claim that the problem of identifying the minimum number of countable people (in this paper also defined as certain count) can be reduced to a maximum independent set (MIS) graph problem. Second, we claim that identifying the minimum number of countable people for specific sets of active sensors, equals to identifying the maximal independent sets of a graph. These claims entail that it is possible to identify a theoretical lower-bound of countable people, under specific conditions. Last, we show that through reduction to a MIS problem, sensors deployment can be efficiently planned to increase the theoretical lower-bounds.

1.1 Outline

The paper is organised as follows. In Sect. 2 we provide an overview of relevant related work. In Sect. 3 we define all the items for the scope of this paper, while in Sect. 4 we show how an environment, such as a smart-home, should be mapped to an undirected graph. In Sect. 5 we prove the relation between a graph maximum independent and the lower-bound of countable people, within that graph. In Sect. 6 we expand our approach and we show that maximal independent sets can be used to identify the lower-bound of countable people, in case of sub-optimal activation patterns. In Sect. 7 we tighten some assumptions, discussing how they affect counting accuracy, and how this knowledge can help to deploy sensor networks in a smarter way. Last, in Sect. 8 we discuss the tractability of the maximum independent set problem and the maximal independent set problem used in this paper, and in Sect. 9 we draw our conclusions.

2 Related work

To the best of our knowledge, there are no other literature works that investigate the theoretical bounds of people counting algorithms deployed in binary sensor networks. However, the number of papers that propose different algorithms and sensors for performing people counting demonstrates that the problem is relevant for the research community. In this section, we give a brief overview of relevant works that face the challenge of counting people. First, we focus on PIR sensors, given their high correlation with our work. Then, we provide different examples of people counting techniques that use different approaches. Teixeira et al. (2010) surveyed the main methods for evaluating occupancy at different levels of precision, such as detection, counting, identity, and so on. The authors also classified such methods and organised them in a taxonomy.

More recently, Sun et al. (2020) reviewed different occupancy measurement systems and differentiated such systems based on the type of sensors. Most notably, with regard to cameras the authors noted two things. First, using only depth images can preserve privacy, but the false positive rate increases; second, RGB-D images allow for high accuracy, at the expense of privacy and computational complexity. Last, they highlighted that PIR sensors provide only binary information, that the noise must be filtered, and that the accuracy is affected by the distance between sensors and people. Wu and Wang (2019) further discuss PIR sensors drawbacks. They argue that PIR sensors are basically motion detectors, which respond only to incident radiation variation. Hence, they are subject to misleading lighting swings, energy waste, false negative detection rates, and inaccurate occupancy estimation. To achieve true presence detection, the authors proposed an optical shutter driven by a Lavet motor PIR (LAMPIR) sensor. Their experiments show that the LAMPIR sensor can detect with high accuracy both stationary and moving occupants.

The binary nature of PIR sensors, however, does not prevent them to count a considerable number of human beings. In 2012, Wahl et al. (2012) showed that unmodified PIR sensors can be used in pairs to observe passage gateways. Later in 2016, Raykov et al. (2016) applied non-parametric machine learning algorithms to data extracted from a single PIR sensor. Assuming a single room and a controlled environment, their approach proved to be capable of counting occupants with a deviation of \(\pm 1\) individual. Akhter et al. (2019) proposed a pedestrian counting device composed of three pairs of PIR sensors, whose Fresnel lenses are specially tuned for monitoring human beings and excluding domestic animals. Paired with their proposed algorithm, the experiments show that their approach is capable of achieving a counting with 95% of accuracy. Notably, the authors mention that they opted for PIR sensors because they are cost-effective and consume low energy, which is a relevant advantage over solutions that use expensive sensors, such as the camera-based ones.

Renoux et al. (2018) proposed a two-step probabilistic approach which applies to different binary sensors. First, their algorithm estimates the number of people in the environment by means of a Constraint Satisfaction Problem (CSP) solver. The CSP solver is based on the network topology, as well as the sensors’ activation pattern. Second, a Hidden Markov Model (HMM) refines the estimate, while taking into consideration the uncertainty of the sensors. Furthermore, Tsou et al. (2020) designed a people counting device that combines an array of 16 PIR sensors. Positioned on the ceiling over an entrance, this device collects passing-bys data which is first used for collecting training data for a Convolutional Neural Network (CNN). Then, the authors use the same device for testing the performance of the CNN, showing that it can achieve up to 92.75% accuracy.

Regarding more complex - and more expensive - sensors, extensive research has been conducted in the field of security cameras and visual surveillance. Hou and Pang (2011) proposed a method that estimates the number of people from low resolution images of crowded scenes. In their approach, the authors subtract the background and process the foreground pixels, and they show that \(\approx 80\%\) of their tests were able to estimate the correct number of people within a percentage error of 15%. Also Wang et al. (2015) tackled the problem of performing people counting on crowded camera images. The authors used a CNN as a framework for learning counting features and fed the deep model with negative samples for improving the robustness.

Barandiaran et al. (2008) created a counting method that relies upon an overhead mounted camera. The camera image is split in vertical slices and, by multiple line analysis, the approach counts people with 95% accuracy. An overhead mounted camera was also used by Zhang et al. (2012) but, instead of a regular RGB camera, their work uses a Microsoft Kinect camera which provides both RGB and depth images. Using a water filling inference algorithm, the authors achieve a counting accuracy of 99.72%.

Using security cameras for counting people can be expensive and, most importantly, not privacy-friendly. Beyond PIR sensors, researchers explored the feasibility of performing people counting with other sensors. For example, Singh and Aksanli (2019) proposed a framework to detect and track people non-intrusively within an environment. Their approach uses only ambient low-resolution thermal sensors, allowing to preserve privacy and spare users’ active participation. Choi et al. (2017) investigated the use of impulse radio ultra-wideband radar sensors (IR-UWBs) for counting people. The authors prove that it is possible to estimate the number of people by evaluating the cumulative signal patterns, instead of detecting the signal of each person within the total signal received by the radar. In another work, Choi et al. (2018) use two IR-UWB sensors for a framework that performs bidirectional passing people counting.

Recently, Wang et al. (2020) proved that it is possible to leverage the channel state information (CSI) of commercial WiFi devices for detecting humans’ respiration rates and, consequently, estimate the number of people in a room. Their experiments show that their technique is capable of achieving an accuracy of \(\approx 87\%\) when deployed in restricted areas, such as cars and offices.

3 Definitions

In this section, we give an overview of the definitions that are necessary for the scope of this work. Throughout the paper, unless otherwise specified, a graph is always assumed to be an undirected graph \(G = (V,E)\).

Definition 1

(Configuration) A configuration is a set of simultaneously active sensors.

Definition 2

(Independent Set) For an undirected graph \(G = (V,E)\), a set \(S \subseteq V\) is an independent set if there is no pair of vertices \((v_1,v_2) \in S\) such that \((v_1,v_2)\) are adjacent.

In other terms, no edge \(e \in G\) can connect any vertex \(v \in S\). For example, the simple coloured subset of the graph shown in Fig. 1 is an independent set composed of 2 vertices, not adjacent to each other.

Fig. 1
figure 1

An example of an independent set of a graph. No coloured vertex is adjacent to another coloured vertex

Definition 3

(Maximal Independent Set) For an undirected graph \(G = (V,E)\), an independent set \(S \subseteq V\) is a maximal independent set if, for every \(v \in V\), either \(v \in S\) or \(N(v) \cap S \ne \emptyset\), where N(v) denotes the neighbours of v.

We can say that a maximal independent set (MIS) is an independent set which is not a subset of any other independent set. Figure 2 shows an example of a maximal independent set of a graph. In this case, the vertex in the centre composes alone a maximal independent set, since that there are no larger independent sets that contain this vertex.

Fig. 2
figure 2

An example of a maximal independent set of a graph, composed of only one vertex. Intuitively, there is no other independent set that is also a superset of this set

Definition 4

(Maximum Independent Set) For an undirected graph \(G = (V,E)\), a maximal independent set \(S \subseteq V\) is maximum if it contains the maximum number of vertices possible for a maximal independent set, for that graph.

A single graph G can contain multiple independent sets, multiple maximal independent sets, and even multiple maximum independent sets.

The number of vertices in a maximum independent set is known as the independence (or stability) number, \(\alpha (G)\). Sometimes it is referred as the vertex independence number, to distinguish it from the edge independence number. In simple terms, identifying a maximum independent set equals to a colouring graph problem, where the following rules must be followed:

  • Each vertex has a different colour from the adjacent (i.e., connected) ones;

  • We colour as many vertices as possible with the same colour (i.e., we maximise \(\alpha (G)\)).

As an example, Fig. 3 shows an intuitive maximum independent set. This is the only configuration for this graph G that allows to have an independent set composed of 3 vertices. It is also worth noting that this subset and the subset shown in Fig. 2 are the only two maximal independent sets of this graph. In the next section, we show how a smart home maps to a graph, explaining the semantics of vertices and edges regarding this work, as well as the necessary assumptions.

Fig. 3
figure 3

An example of a maximum independent set of a graph, showing that it is unfeasible to colour more than 3 vertices of this graph without violating the non-adjacency property of an independent set

4 Mapping the smart home

To determine how many people we can distinctly count within a smart home, we need to analyse it and map it to a graph. As a case study, we use the Ängen smart home, depicted in Fig. 4. Ängen is a research facility used in E-carehome by Alirezaie et al. (2017), an interdisciplinary Swedish project that brings together experts from different fields.

Fig. 4
figure 4

Ängen map

Each Ängen room is equipped with one motion sensor. The motion sensors are deployed as shown in Fig. 4, so that there are no blind spots in the room they monitor. However, we must consider that the motion sensors might detect (erroneously) activities from an adjacent room, due to their physical deployment. This can easily happen if a sensor is positioned next to a door, and a person moving in the adjacent room casts a shadow and triggers the motion sensor. Taking as an example Fig. 4, a person moving next to the motion sensor in the kitchen could also trigger the motion sensor in the living room, given that the two sensors are positioned in each others’ line of sight. In Fig. 4, this possibility is depicted with a solid grey line.

Last, we take into account that motion sensors might exhibit a considerable delay, such that a person moving from a room to another could simultaneously activate two sensors. Using again the running case study shown in Fig. 4, even though the motion sensor in the closet is not precisely in line of sight with the living room sensor, a person quickly moving from one room to the other might create an overlapping activation for both sensors. Similarly to the previous example, this possibility is depicted in Fig. 4 with a solid grey line. As a direct consequence of this, n active sensors do not automatically relate to n occupants. According to these considerations, we make three assumptions:

Assumption 1

Motion sensors detect every human being moving in the room they are deployed in.

Assumption 2

Motion sensors might detect movements from adjacent rooms and might exhibit delays.

Assumption 3

The environment does not host animals nor children.

In particular, the first assumption implies that motion sensors are placed in a way that there are no blind spots and that any human being moving in the room would be detected. However, as stated in the second assumption, a sensor might be placed in a way that it detects also some movements from adjacent rooms. Moreover, sensors might exhibit relevant delays, such that a moving person might cause an overlap of active sensors. With these assumptions in mind, the next step is to define the rules for mapping an environment to a graph. For doing so, we follow two rules:

Rule 1

A vertex \(v_x\) represents a binary sensor deployed in the environment.

Rule 2

An edge \(e_{x,y}\) between two vertices \(v_x\) and \(v_y\) represents the possibility that a single person activates sensor \(v_x\) and sensor \(v_y\), simultaneously.

Following these two rules, let us depict the Ängen map as a graph \(G=(V,E)\). First, we identify each motion sensor as a graph vertex, hence creating V. Second, we connect every pair of vertices \(<v_A,v_B>\) with an edge e, if there is a chance that a person could activate \(v_A\) and \(v_B\) at the same time. The result should look similar to Fig. 5.

Fig. 5
figure 5

Ängen map as a graph

Analysing the figure, we realise that a person moving from the kitchen to the bathroom must pass through the living room, activating three motion sensors in total. Walking this path, the person might activate two pairs of sensors at a time (i.e, \(<{\text{kitchen,living~room}}>\), and \(<{\text{living~room,bathroom}}>\)), following our previous assumptions about sensors adjacency and delay. For the scope of this paper, an active sensor is represented as a coloured vertex in our figures.

Ängen features different kinds of sensors, not only motion sensors. For example, the smart TV is equipped with a on/off sensor; chairs and sofas are equipped with pressure sensors which detect whether a person is sitting or not. For the sake of clarity, besides the motion sensors, we assume that only two pressure sensors are available in Ängen. Both pressure sensors are installed on two different chairs, positioned in the kitchen. To supplement the three assumptions previously made, we add two assumptions for pressure sensors:

Assumption 4

Pressure sensors’ thresholds are adjusted to trigger only on adult human beings’ weight.

Assumption 5

No object with a weight comparable to an adult human being is positioned on pressure sensors.

In this paper, we focus on motion and pressure sensors because, under the aforementioned assumptions, these sensors are strong indicators that a human being is currently present in the room. This does not apply to other binary sensors, such as TV on/off sensors and door open/close ones which could remain triggered for hours without any human intervention. A television left on is not as a strong indicator as a motion sensor which is detecting movement; a cabinet door open in the kitchen yields less occupancy probability than 60 kg sitting on a chair pressure sensor.

Next step in the mapping graph, we introduce the remaining sensors as new vertices, as we did for the motion sensors. Since we assume that a motion sensor detects every movement that happens in its room, it is appropriate to connect all new sensors to the motion sensor of the room they belong to. In our example in Fig. 6, we connect the two chairs pressure sensors to the kitchen motion sensor.

Last, if two sensors might identify the same person at the same time, we draw an edge between the vertices depicting them, regardless if they are situated in the same room or not. As shown in Fig. 6, not only we draw an edge between the kitchen motion sensor and the sensor pressure 1 and pressure 2, but we also draw edges between the pressure sensors and the living room motion sensor. This correctly depicts the aforementioned case of a person sitting in the kitchen, activating kitchen and living room motion sensors.

Fig. 6
figure 6

Ängen map as a graph, kitchen pressure sensors added

5 People counting lower-bounds

In this section, taking into account the assumptions described in the previous Sect. 4, we prove that any independent set of n vertices guarantees a minimal counting of n people. We also prove that the scenarios that allow for the highest counting lower-bounds, correspond to the maximum independent sets of a graph.

We recall that, for the scope of this paper, an active sensor is represented as a coloured vertex of a graph. Let us also recall the definition of maximum independent set, previously given in Sect. 3. A maximum independent set \(S \subseteq V\) is a maximal independent set which contains the maximum number of vertices possible for the graph G(VE).

Theorem 1

For every set of sensors represented as an undirected graph G(VE), every independent set of n vertices in G represents a minimum counting of n people. Similarly, every possible counting of n people can be expressed as an independent set of n vertices in G.

Proof

Let us assume an undirected graph G(VE). By Definition 2, a set \(S_{ind} \subseteq V\) is an independent set if, and only if, \(\not \exists e_{x,y} \in E\), such that \(v_x \in S_{ind}\), \(v_y \in S_{ind}\). By Rule 2, \(\forall (v_x,v_y) \in S_{ind}\), \(S_{ind}\) does not represent any possibility that a single person activates \((v_x,v_y)\) simultaneously.

In simple terms of graph theory, if the set of coloured vertices corresponds to an independent set, we can conclude that each sensor is counting at least a different person from every other sensor. Independent sets of n vertices ensure that, at least, n people are counted and present in the smart home. This is a lower-bound, since that a binary sensor alone (such as a motion sensor) cannot detect more than one person at a time. If two or more people perform the same actions in the same room, it is likely that they will be detected as a single person. Therefore, n binary sensors in an independent set equal to n people or more.

Theorem 2

For every set of sensors represented as an undirected graph G, the lower-bound of simultaneously countable people equals to the independence number \(\alpha (G)\), and the configuration that allows it corresponds to the maximum independent set.

Proof

Let us assume an undirected graph G(VE), and the maximum independent set \(S_{max}\{v_0,..,v_{n-1}\}\). Let us also assume, ad absurdum, that the set \(S_{abs}\{v_0,..,\) \(v_{n-1},v_n\} \supset S_{max}\) represents a minimum counting of n people. By definition, \(S_{max}\) is the largest independent set possible within G. \(S_{abs}\) is a superset of \(S_{max}\), so \(S_{abs}\) is a non-independent set. A non-independent set implies that \(\exists e_{x,y} \in E\), such that \(v_x \in S_{abs}\), \(v_y \in S_{abs}\). However, an edge \(e_{x,y}\) means that a single person might activate \(v_x\) and \(v_y\) simultaneously; \(v_x\) and \(v_y\) active at the same time do not ensure a count of two distinct people. In conclusion, \(S_{abs}\) has n vertices but does not represent a lower-bound of n countable people.

Following Theorem 2, the minimum number of people that we can certainly count equals to the maximum independent set. We define this as a certain count. The subtle implication of Theorem 2 is that we can ensure that at least \(\alpha (G) = n\) distinct people are in the smart home, if such people activate simultaneously the sensors, according to the maximum independent set. If we also assume that the smart home hosts \(m = \alpha (G) = n\) people, this would result in an exact count of every person in the smart home.

Example 1

(Independent Set) If Ängen were composed only of motion sensors, as shown in Fig. 5, then the theoretical lower-bound of countable people would equal the independence number \(\alpha (G) = 6\), as shown in Fig. 7. In particular, we could certainly count at least 6 people in two cases. If 6 people were moving in hall, kitchen, bedroom 2, bathroom, closet, and balcony; or if 6 people were moving in bedroom 1, kitchen, bedroom 2, bathroom, closet, and balcony. The independence number provides a lower-bound of 6 people, under the condition that the active sensors correspond to the maximum independent set.

Fig. 7
figure 7

Ängen map as a graph, maximum independent set highlighted

A lower-bound higher than 6 is impossible, in this scenario. Multiple people in the same room do not increase the lower-bound, since that a motion sensor exhibits a binary behaviour (i.e., on/off) and can count only one person at a time. The same applies if the coloured vertices describe a non-independent set, as shown in the following example.

Example 2

(A Non-Independent Set) Adding a person to bedroom 1 in Fig. 7, as shown in Fig. 8, would introduce a doubt: is there really someone in bedroom 1, or a person in the hall triggering the motion sensor? In this case, the people count would remain 6, but this uncertainty can even decrease the guaranteed people count. The next example proves this possibility.

Fig. 8
figure 8

With both bedroom 1 and hall coloured, it is impossible to tell if there is one person per each room, or if one person is triggering both motions sensors

Example 3

(Another Non-Independent Set) If we take Fig. 7 and colour the living room, we obtain Fig. 9; a lot of different scenarios could explain this configuration. There might be one person per each room, or only one person in the living room that, in a specific position, is activating every motion sensor.

Fig. 9
figure 9

In this situation, uncertainty is high. There could be one person per each coloured room, or only one person in the living room that is triggering all the sensors

Fig. 10
figure 10

Ängen map as a graph, kitchen pressure sensors added, maximum (and maximal) independent set coloured

Therefore, the maximum independent set provides a related lower-bound, the independence number \(\alpha (G)\), under the strict condition that the active sensors correspond to the maximum independent set. No information about eventual upper-bounds can be inferred.

If we take into account the extended Ängen graph in Fig. 6 and we analyse the maximum independent set shown in Fig. 10, the independence number grows from 6 to 7. It is worth noting that drawing 2 edges, from the living room to the 2 pressure sensors, does not change the independence number, in this specific scenario. This is because the living room would not be in the maximum independent set in any case, due to the edges that connect it to other rooms. However, even if it does not alter this specific final result, it is useful to explicit all the potential connections to depict a solid representation of a smart home. As discussed in the next section, the maximum independent set shown in Fig. 10 is not the only maximum independent set. This graph has a second one, shown in Fig. 11.

The maximum independent set algorithm is a powerful approach, applicable beyond the goal of discovering the lower-bound for people counting. In case of a non-independent set configuration of n-vertices (i.e., that does not ensure a count of n-people), we can apply the maximum independent set algorithm and determine the minimum counting possible for the configuration. However, as we discuss later in this paper in Sect. 8, the maximum independent set algorithm is a NP-hard problem. Running this algorithm every time that a configuration corresponds to a non-independent set would be too expensive. In the next section, we show an approach that relies on maximal independent sets for listing succinctly and preemptively every configuration that ensures a minimum counting. Furthermore, we discuss how this allows to transform a problem of independent set recognition into a more intuitive problem of set inclusion.

6 People counting and lower-bounds for specific configurations

Identifying the maximum independent sets allows us to extrapolate the lower-bound of countable people in a smart home, and the optimal configurations that make it possible. Unfortunately, maximum independent sets do not answer another relevant question: does a specific set of active sensors guarantee a minimum people count? In this section, we show that this question can be answered by verifying if a configuration is an independent set. Besides, we show that this can be done by comparing the observed configuration with the maximal independent sets of the topology, since that listing the maximal independent sets is a succinct way of listing every possible independent set of a graph. In fact, we argue that determining the maximal independent sets is a form of preprocessing, which provides deterministic boundaries to counting reasoners and relieves part of their runtime computational burden.

For example, it is expected that a person moving in the kitchen, a person moving in the bathroom, and one in the balcony would guarantee a count of 3 people. The sensors are positioned far away from each other, and there is no possibility for less than 3 people to activate them, simultaneously. This counting is neither reflected in Fig. 10, nor in Fig. 11. The same goes if a person is moving in bedroom 1 and another one is moving in the living room: it is expected to be possible to distinctly count 2 people, but this possibility is not depicted in any of the 2 maximum independent sets.

Referring to the same topology defined in Fig. 6, it is easy to see that a number of other independent sets can be defined, apart from the maximum independent set. First of all, we can swap the colouring of bedroom 1 and hall, achieving another maximum (and maximal) independent set, as shown in Fig. 11. As aforementioned, we can count at least n people when n coloured vertices (i.e., the active sensors) identify an independent set of the graph. The same does not apply to non-independent sets, as \(m < n\) people might activate n sensors simultaneously. Intuitively, listing every independent set allows to define every case that leads to certain minimum counting. Therefore, instead of analysing every new configuration from the ground up for determining if it is an independent set, it is sufficient to compare the configuration to every independent set. In case of positive matching, the configuration is confirmed to be an independent set and the minimum counting guaranteed equals to the number of vertices in the configuration (i.e., the active sensors). However, the number of independent sets can explode even for small graphs. For example, a simple Claw graph of 4 vertices has 8 independent sets. Therefore, it is necessary to find a more succinct way of listing the independent sets.

Fig. 11
figure 11

Ängen map as a graph, maximum (and maximal) independent set coloured

Let us recall the definition of a maximal independent set. An independent set is maximal if, and only if, it is not a subset of another independent set. Every independent set is either a maximal independent set, or a subset of a maximal independent set, and every subset of a maximal independent set is an independent set. As a consequence, listing all the maximal independent sets is a concise way of listing all the configurations that ensure a certain minimum count. If n sensors are active at the same time and they correspond to a set I, such that I is a maximal independent set, or a subset of a maximal independent set M (where \(M \subseteq V, G=(V,E)\)), we can achieve a count of n people. In other terms, we can guarantee that there is at least one person per each active sensor.

This observation has relevant implications. Assuming a configuration I of n active sensors, it is possible to quickly determine that at least n occupants are certainly present in the environment, if the active sensors belong to one of the maximal independent sets. This spares the computational expense of continuously reevaluating if a configuration is an independent set or not, every time that sensors activate/deactivate and form a new configuration. In other words, detecting maximal independent sets allows to transform a problem of set independency recognition, into a problem of set inclusion over a list of maximal independent sets, precomputed at deployment time. Even though finding every maximal independent set is computationally demanding, the sensors’ topology is static, hence the process must be undertaken only once. Therefore, listing the maximal independent sets is effectively a preprocessing phase that moves part of the computational burden from execution time to deployment time.

This could be beneficial for other approaches, such as the probabilistic reasoner proposed by Renoux et al. (2018). Knowing that an observed configuration of m vertices corresponds to an independent set (i.e., it is a maximal independent set, or a subset of a maximal independent set) guarantees that at least m people are currently performing relevant actions. This knowledge would provide a baseline threshold to the probabilistic reasoner which, instead of reasoning over an assumed starting range of \([0,\infty )\), would be able to restrict the acceptable solution to \([m,\infty )\), with \(m>0\). On the contrary, whenever the active sensors define a configuration which is not an independent set, a counting of m cannot be guaranteed and the context reasoner must work through the uncertainty.

The Ängen running case study provides some relevant examples, which demonstrate the usefulness of listing preemptively every maximal independent set.

Example 4

(Kitchen and Bedroom 1) Let us assume that 2 people are moving in the first bedroom and in the kitchen, respectively. The motion sensors in these Ängen rooms are active at the same time, while every other sensor is off. This configuration of 2 active motion sensors is a subset of a maximal independent set of this topology, shown in Fig. 12. Following the observations described earlier in this section, these 2 active sensors compose an independent set and guarantee a counting of 2 people, at least.

Fig. 12
figure 12

Ängen map as a graph, maximal independent set coloured

Intuitively, these motion sensors are not in line of sight and are far away from each other (i.e., no edge connects the vertices). It is not feasible for a single person to activate both sensors at the same time, and this looks clear in Fig. 4. Therefore, it is reasonable to conclude that there must be at least one moving person per room, for a total of at least 2 people.

Notably, the scenario in Example 4 is not captured by the maximum independent sets, nor by any other maximal independent set of the topology, apart the maximal independent set shown in Fig. 12.

Example 5

(Kitchen, Bathroom, and Balcony) At the beginning of this section, we assumed that 3 people were moving in the kitchen, the bathroom, and the balcony, respectively. While these 3 vertices are not a subset of any of the maximum independent sets, we can easily verify that they are a subset of the maximal independent set shown in Fig. 13. These sensors, given their positions, cannot be activated together by less than 3 people, hence the counting of 3 people is correct.

Fig. 13
figure 13

Ängen map as a graph, maximal independent set coloured

Example 6

(Bedroom 1 and Living Room) Suppose that 2 motion sensors are contemporaneously active; one sensor is in the first bedroom and the second is in the living room. These two motion sensors are not in line of sight, nor close enough to be activated by one person moving from one room to another. Again, the vertices that represent these sensors in the Ängen topology, correspond to the maximal independent set shown in Fig. 14. Consequently, we infer that at least two people are in the smart home and that the rooms are hosting at least one person each.

Fig. 14
figure 14

Ängen map as a graph, maximal independent set coloured

Example 7

(Hall, Living Room, and Closet) In this example, the observed configuration is the triplet <hall,living room,closet>, which is a non-independent set composed of 3 vertices. By definition, this configuration do not guarantee that at least 3 people sit in the house: a single person moving in the living room could trigger all sensors at once. The simple way to verify that this set is not independent, would be to to analyse the neighbourhood of each vertex, in search for one of the other vertices of the configuration. This process can be simplified, knowing the maximal independent sets.

First, the configuration is composed of 3 vertices, meaning that the maximal independent set of 2 vertices, shown in Fig. 14, can be excluded a-priori. Then, one of the vertices that compose the triplet is the hall. This vertex appears only in Fig. 10 and in Fig. 13, which entails that the other maximal independent sets are also excluded. The second vertex of the triplet is the living room, which is not part of Fig. 10 nor Fig. 13. Therefore, we can conclude that the configuration <hall,living room,closet> is not an independent set and it does not guarantee a minimal count of 3.

Example 8

(Eight Active Sensors) Last, let us assume that the observed configuration is composed of 8 active sensors. After the preprocessing phase of the maximal independent sets, we know that it is possible to obtain at maximum an independent set of 7 vertices for this scenario. Therefore, it is possible to immediately determine that the current configuration is not an independent set, and that a minimum counting of 8 people cannot be guaranteed.

7 Tightening the assumptions

In the previous sections, we made two assumptions: a motion sensor might pick activities from adjacent rooms, which is likely to happen when sensors are placed near doors or in small rooms, and it might exhibit significant delays.

Let us tighten these assumptions, assuming that the sensors do not exhibit any delay, and that the motion sensors are deployed in such a way that only in-room activities are identified. Assumed this, the edges connecting every motion sensor can be safely removed, leading to the situation depicted in Fig. 15. Because the pressure sensors are situated in the kitchen and we assume that no movement in the kitchen can trigger the living room motion sensor, we can also remove the edges between the two pressure sensors and the living room.

Finding the lower-bound of countable people can be reduced to identifying the maximum independent set across multiple disconnected graphs. In this particular case, the independence number would grow up to \(\alpha (G) = 9\), which entails that under optimal conditions the smart home can count up to 9 different people, no more than that. Notably, leaving the edge between the kitchen and the living room would not lead to a lower independence number \(\alpha (G)\). Adding or removing the edge does not change the lower-bound of 9 countable people, in this particular example.

Fig. 15
figure 15

Ängen map as a graph, edges between rooms removed (i.e., motion sensors carefully deployed), maximum independent set coloured

Fig. 16
figure 16

Restricted view on kitchen and living room. Adding or removing the dashed edge does not affect the number of people that can be counted

This is more clear if we focus our view on the living room and the kitchen, as shown in Fig. 16. If we deploy perfectly the motion sensors, we can remove the dashed edge between the kitchen and the living room. The maximum number of people that can be counted is 3, and this would happen with 2 people sitting in the kitchen and a third one moving in the living room. If we suppose a misplaced sensor, we draw the dashed edge between the vertices. However, 3 people could be still counted, in case that 2 people are sitting in the kitchen without activating the motion sensor, and another person is moving in the living room. Whether there is an edge between the kitchen and the living room or not, the lower-bound of countable people remains 3.

In general, deploying the motion sensors to remove as many edges as possible is helpful, because it minimises sources of uncertainty. We have shown that leaving or removing the dashed edge in Fig. 16 is irrelevant for the lower-bound, in that specific scenario. However, if the dashed edge is left and the two motion sensors are activated simultaneously, the reasoner is unable to tell whether two different people are moving, or both sensors are detecting the same person. In conclusion, separation of vertices allows a better understanding of on-going events and, in some cases, can increase the theoretical lower-bound for people counting.

8 Tractability of independent sets

This work relies on various independent set problems. Some of them admit simple solutions, others not. In this section, we provide a brief overview of the tractability of these problems, such as the independent set finding problem, the maximum independent set problem, and the maximal independent set problem.

First of all, for any graph G, in the worst case scenario a simple greedy algorithm can find a maximal independent set in O(v), where v is the number of vertices. With parallel algorithms, the performance increases considerably.

The problem of finding all the maximal independent sets of an undirected graph is equivalent to the problem of finding all the cliques in its complementary graph. This problem is commonly known as the clique problem. According to Moon and Moser (1965), every graph contains at most \(3^\frac{n}{3}\) maximal independent sets (and cliques). The Bron-Kerbosch algorithm (Bron and Kerbosch 1973) is the most known for solving the clique problem, and it runs in \(O(3^\frac{n}{3})\). More efficient algorithms exist for graphs that contain less cliques than \(3^\frac{n}{3}\), which is the case for many graphs. However, matching the upper bound number of \(3^\frac{n}{3}\) cliques per graph, the Bron-Kerbosch algorithm is efficient in the worst-case scenario.

Last, the maximum independent set problem is known to be in the NP-hard class of problems, as well as a difficult one to approximate. A number of algorithms and heuristics have been proposed, e.g. Tarjan and Trojanowski (1977) and Robson (1986), and recently it has been proven to be generally solvable in \(O(1.1996^{n})\) time and polynomial space by Xiao and Nagamochi (2017). For limited degree graphs MIS-i, where \(i = \alpha (G)\), the time further decreases (e.g., down to \(O(1.0836^{n})\) for MIS-3 graphs). The maximal independent set problem can be seen as a subroutine for the maximum independent set problem, where all maximal independent sets are listed and the largest ones are marked as maximum and stored.

9 Conclusion

Smart homes composed by simple sensors allow for counting a limited number of people, when relying upon snapshot observation of active sensors. However, the question about how many people can be exactly counted was left unanswered. In this paper, we proposed a simple technique based on graph theory, which helps to map a smart home and discover the lower-bound of simultaneously countable people, under certain conditions.

First, we proved that every independent set of n vertices, of an undirected graph G, represents a minimum count of n people, and vice versa. Then, we proved that the minimum number of simultaneously countable people equals to the independence number \(\alpha (G)\). We defined this as certain count and we showed that the configuration that allows so, corresponds to the maximum independent set(s) of such G graph.

As a consequence of our first proof, we showed that identifying all the maximal independent sets of a graph G provides a succinct and efficient way to depict every combination of active sensors that ensure minimum count. We provided notable examples using our Ängen running case study, showing which information can be gathered from different configurations. Then, we showed that our approach can help to identify and optimise a suboptimal deployment of sensors, so that the assumptions can be tightened and the theoretical lower-bound can be improved.

Our work highlights challenges and directions for future works. For example, it is of great interest to assess the scalability of our approach with growing numbers of vertices and different degrees of graph connectivity. Further investigations are also warranted for evaluating the applicability of our graph representation to different sensors, whether they are alternative binary sensors or devices that allow for multiple counting. Future research should analyse the introduction of new graph entities for representing temporal and geographical information linked to binary sensors, such as in the case of memory-retaining break-beam sensors placed at entrance doors. New graph entities might be also necessary for representing hybrid approaches that include personal devices, such as WiFi smartphones and wearable Bluetooth devices, for performing people counting. This is a question for future research to explore.

In conclusion, the broad implication of our work is that, with the proper tools, it is possible to reason preemptively on the counting capabilities of a framework, to detect inherent bounds, and lift some burden off the online reasoners.