1 Introduction

Sensors are hardwares that sense physical phenomena like temperature, light, movement, and humidity to produce signal carrying information about the sensed issue. Low-power requirements and low costs of the sensors have made their use widespread. Wireless sensor networks (WSNs) consist of multiple sensors that communicate with each other and allow all these network traffic to be monitored from a central location. WSNs are used in military applications, smart cities applications, smart home applications, and fault detection at electrical grids as well as target tracking and border crossing security applications (Akyildiz et al. 2007; Allam and Dhunny 2019; Gholizadeh-Tayyar et al. 2020; Jiang et al. 2019; Karabulut et al. 2017; Sharma and Nagar 2020). Problems, such as coverage problem (CP), data routing problem (DRP), sink placing/routing problem (SPP/SRP), and activity scheduling problem (ASP), are some of the known optimization problems of WSNs.

The CP is the problem of determining the optimum sensor positions to ensure maximum usage of the sensing capabilities of the sensors and that the sensor field can be observed long enough even after some of the sensors fail (Çabuk et al. 2021; Karabulut et al. 2017). The second fundamental problem, which is DRP, is defined as the problem of transmission of the data that are collected by the sensors to the main stations called sinks with the minimum possible energy consumption either directly or through other sensors (Güney et al. 2010). The third problem is called as SPP if the sinks are stationary and SRP if the sinks are mobile. SPP aims to determine the stationary sink places, while SRP determines the sink routes that maximizes the network lifetime (Xiao et al. 2017). SPP and/or SRP are relevant for WSN lifetime optimization as optimum data routes are also determined according to sink places/routes. The last fundamental problem, which is ASP, is the problem of switching some sensors to active and some sensors to passive modes without disrupting the desired monitoring tasks. Optimizing the scheduling of the sensors significantly contributes to WSN life by balancing the energy loads among the sensors (Bhalaji and Venkatesh 2019). Thus, scheduling the activities of the sensors prevents the early depletion of the sensor batteries and ensures the continuity of the connection to the sinks.

Continuous surveillance is particularly important for border monitoring/border security applications where WSNs are used. An important part of ensuring the security of a country can be fulfilled by protecting its borders against potential external threats. Similar threats against important government buildings such as embassy, ministry buildings can be eliminated by taking the surroundings of the buildings into close continuous surveillance by WSNs. Some of the potential threats are intrusion through the borders for weapons and drug smuggling purposes, or for terrorism actions. Defense against such threats must be made in the border area. With a WSN installed in the border zone, timely detection of intruders can be realized in a lower cost and easier way than traditional monitoring methods (camera, video recorder, observation towers, etc.) (Arfaoui and Boudriga 2019; Beasley 2022; Haywood et al. 2022; Lessin et al. 2018; Muruganandam et al. 2023; Ozkan and Kaya 2021; Singh et al. 2023; Wang et al. 2020). In this study, it is assumed that the regions where the sensors are placed have a grid structure and the sensors are placed at the corner points of all cells of the grid. Using routing optimization methods, we ensure that the collected data are sent to the sinks with the minimum possible energy consumption. In addition, sinks are moved to the best locations with respect to WSN lifetime and optimum data paths are determined accordingly. Moreover, sensors’ activities are planned with the aim of minimizing the energy consumption of the sensors by switching some sensors into active and some into passive without interfering the task of detecting intruders who may enter the border zone. Not only the early depletion of the sensors’ batteries are prevented and the continuity of the data transfer to the sinks is ensured by proper activity schedules of the sensors, but also intruder detection is always guaranteed throughout the network lifetime. For that purpose, we provide a mathematical model that guarantees the detection of the intruder independent of the entering time of the intruder to the grid and the independent of the route he/she selects in the study. (For successful optimization implementations, see for instance (Bojan-Dragos et al. 2021; Precup et al. 2020 and Bacigalupo et al. 2020). Successful results have been obtained on the generated border zone instances as shown in the computational results section.

Contribution of the study to the literature can be summarized as follows:

• A mathematical model is developed that ensures the detection of the intruder independent from the route the intruder selects or the time the intruder enters the route. Usage of a mathematical model for timely intruder detection by the help of a WSN is a novelty that has not been studied in the literature before.

• Sensor placement, activity scheduling of the sensors, data routing, and mobile sink routing WSN design issues have been integrated in a monolithic manner in very few studies before (see, Keskin et al. 2014; Keskin 2017 and Keskin et al. 2015). In this study, we not only integrate all design issues in a single MILP model, but also combine these design issues with the idea of timely detection of the intruders.

• We develop a Lagrangean solution strategy specific to the offered mathematical model and illustrate the efficiency of it over the generated border zone instances. We share the generated border zone instances and codes of the model and the Lagrangean heuristic via a dedicated website for the use of the interested researchers.

The remainder of this article is organized as follows. In the next section, a brief review of related literature is given. In the third part, the mathematical model that combines ASP, SRP with DRP and guarantees detection of any intruder independent of the entrance time and route is presented. In the fourth section, a Lagrangean heuristic strategy is explained. In the fifth section, the test bed and the numerical results are given. Finally, the paper is summarized and the studies that are planned to be done in the future are stated.

2 Literature review

There are many studies on the WSN design in the literature. Most of these studies focus on a subset of the above-mentioned optimization problems (CP, DRP, ASP, and SPP/SRP). Although this assumption simplifies the solution of the problem, it produces low-quality solutions, since it does not guarantee the best possible results for the solution. For example, in Altinel et al. (2008), the authors try to find a solution by considering only the coverage problem (CP). Similarly, in the studies (Wang et al. 2005; Keskin et al. 2011), the Sink Routing Problem (SRP) is solved assumed that sensor locations, activity scheduling, and the data flow scheme are known. It is assumed that the installed sensors are always active through the entire lifetime. Besides, there are studies combining SRP and DRP assuming that sensors’ locations and activity schedules are known. Some of these studies (Gandham et al. 2003; Alsalih et al. 2007) search for energy-efficient base stations by optimizing the data flow routes for each period. However, in all of these studies, time is divided into periods of equal lengths and each period is handled independently. Alternatively, Luo and Hubaux (2005) propose a Mixed Integer Linear Programming (MILP) model for optimizing the sink routing and data routing problem simultaneously for multiple periods. Another issue to be considered in such studies is the energy problem of the sensors. In addition to providing mathematical programming models, the aforementioned studies are concerned more with the energy issues rather than directly maximizing the network lifetime. Alternatively, Papadimitriou and Georgiadis (2005) try to maximize the lifetime by a linear programming model integrating the DRP and SRP. Gatzianas and Georgiadis (2008) develop a distributed heuristic solution strategy for the mathematical model of Papadimitriou and Georgiadis (2005) which is based on the Lagrangean decomposition of Madan and Lall (2006) that is developed for a model with static sinks. In another study on this subject, that is (Yun and Xia 2010), the model of Papadimitriou and Georgiadis (2005) is expanded into two new models for delay-tolerant applications. Yun et al. (2012) and Behdani et al. (2012) develop decomposition strategies which provide base station routes based only on local sensor data for one of the models of Yun and Xia (2010). Besides, Güney et al. (2010) extend the model of Papadimitriou and Georgiadis (2005), so that the model works for more than one sinks. Luo and Hubaux (2009) also work on the same model and introduce multiple mobile sinks. Basagni et al. (2014) propose a model by combining DRP and SRP to track the routes of an autonomous underwater vehicle. The approach of Basagni et al. (2014) is different from other studies, since it is generally assumed that if the sink is close, each sensor can transfer the data directly to the sink, and if the sink is remote, then the data can be transferred via other sensors, while Basagni et al. (2014) assume only direct transmission.

In the literature, studies integrating more than two WSN design issues are rarely encountered. Such a study is performed in Güney et al. (2012) by integrating CP on top of the models of Güney et al. (2010). This study is also the first one in the literature to integrate CP, SLP, and DRP. In the solution method, the authors propose that sensor and sink locations are determined by a taboo search algorithm outside, while data paths are searched for given sensor and sink locations inside. On the other hand, studies [(Türkoğulları et al. 2010a, 2010c) and (Türkoğulları et al. 2010b)] manage to integrate ASP into CP, SLP, and DRP by expanding the model made by Güney et al. (2012). Although the same model is used in these studies, different solution strategies are produced. First, Türkoğulları et al. (2010c) offer a Lagrangean heuristic approach and determine the positions and duty cycle of the sensors later. Türkoğulları et al. (2010a) determine the best combination of the active sensor sets to prolong the network lifetime. Finally, Türkoğulları et al. (2010b) use a column generation algorithm for the solution of the same model. In another study, Castaño et al. (2015) introduce a model by integrating several sensor roles and produce columns to find the appropriate set of active sensors. Lersteau et al. (2016) propose a mathematical model that aims to find activity scheduling of WSNs to keep track of a target. In other words, active sensor sets must be able to detect targets that may pass through their area. Keskin et al. (2014) combine CP, ASP, and SRP with DRP in an MILP model and the authors propose two different heuristic solution methods. Both methods used in the article have been shown to outperform the commercial solver Gurobi (2020). Keskin et al. (2015) also work on the same model but with static sinks. The authors combine simulated annealing with a Lagrangean heuristic that work in a nested manner. Keskin (2017) extends the model to multiple mobile sinks and proposes a heuristic solution strategy depending on column generation. Finally, Kim et al. (2016) introduce new approaches for the sleep–wake scheduling of the sensors with three intuitive methods to maximize the lifetime of wireless sensors.

To have a clearer picture of the literature, we present a summary of the literature in Table 1 with respect to content and the applied solution strategies. Note that ID abbreviates for the intruder detection, LP for the linear program, ILP for the integer linear program, NLP for the nonlinear program, CG for the column generation, BD for the Bender’s decomposition, H and MH for the heuristic and metaheuristic (in the sense of construction heuristics and/or heuristics/metaheuristics that employ random jump strategies), and AI/ML/DL, respectively, for the artificial intelligence/machine learning/deep learning in Table 1.

Table 1 Summary of the content and used methods of the literature studies

One may extract from Table 1 that there is no study in the literature that combines CP, DRP, SPP/SRP, ASP with ID, and by this study, we are filling this gap. In other words, this study, with its combined nature of CP, DRP, SPP/SRP, and ASP with ID, handles with a unique problem that has not been studied in the literature. Another derivation of Table 1 is that studies including integer programming mathematical models (ILP or MILP) usually go for the decomposition of the model by the help of Lagrange or CG techniques to obtain easy to solve smaller submodels and produce feasible solutions making use of the solutions of the smaller submodels. In this study, we also follow the same way of thinking and employ a Lagrangean decomposition and use it as a heuristic which we give details later.

After this comprehensive review of the related literature, one may observe that a mathematical model which ensures detection of the intruder independent of the route he selects and the time of the violation, and simultaneously optimizes the lifetime while combining DRP, ASP, and SRP for more efficient WSN design is an important contribution to the literature. That model is proposed and explained in detail in the next section.

3 Mathematical model

We first provide the definitions of sets and parameters used in the mathematical model in Table 2, and the decision variables used in the mathematical model in Table 3 in the following and then give the formulation of the mathematical model named as Wireless Sensor Network Design with Intruder Detection (WSNDID). Note that WSNDID given by (113) is not an unconstrained mathematical model but an MILP model which is a basic instrument of operations research discipline. We refer interested readers to the seminal work (Wolsey 1998) about integer programming.

Table 2 Definition of sets and parameters used in the model
Table 3 Definition of decision variables of the model

Now, we give the formulation of WSNDID in the following:

$$ \max \sum\limits_{{t \in {\mathcal{T}}}} {w_{t} } $$
(1)

subject to

$$ w_{t} \ge w_{t + 1} \;\;\;\;\;t \in {\mathcal{T}}/\left\{ T \right\} $$
(2)
$$ q_{it} \le w_{t} \;\;\;i \in {\mathcal{I}},t \in {\mathcal{T}} $$
(3)
$$ \sum\limits_{{j:i \in {\mathcal{I}}_{j} }} {x_{jit} + hq_{it} } = \sum\limits_{{j \in {\mathcal{I}}_{i} }} {x_{ijt} } + \sum\limits_{{n \in {\mathcal{N}}_{i} }} {y_{int} } \;\;\;\;\;\;\;i \in {\mathcal{I}},t \in {\mathcal{T}} $$
(4)
$$ \sum\limits_{{t \in {\mathcal{T}}}} {\left( {c^{r} \sum\limits_{{j:i \in {\mathcal{I}}_{j} }} {x_{jit} } + c^{s} q_{it} + \sum\limits_{{j \in {\mathcal{I}}_{i} }} {c_{ij}^{t} x_{ijt} } + \sum\limits_{{n \in {\mathcal{N}}_{i} }} {c_{in}^{t} y_{int} } } \right) \le E} \;\;\;\;i \in {\mathcal{I}} $$
(5)
$$ \sum\limits_{{i:n \in {\mathcal{N}}_{i} }} {y_{int} } \le Mz_{nt} \;\;\;n \in {\mathcal{N}},t \in {\mathcal{T}} $$
(6)
$$ \sum\limits_{{n \in {\mathcal{N}}}} {z_{nt} } = P\;\;\;\;\;\;t \in {\mathcal{T}} $$
(7)
$$ \sum\limits_{{j \in {\mathcal{I}}_{i} }} {x_{ijt} } \le Mq_{it} \;\;\;\;i \in {\mathcal{I}},t \in {\mathcal{T}} $$
(8)
$$ \sum\limits_{{j:i \in {\mathcal{I}}_{j} }} {x_{jit} \le Mq_{it} } \;\;\;\;\;i \in {\mathcal{I}},t \in {\mathcal{T}} $$
(9)
$$ \sum\limits_{{i:k \in {\mathcal{K}}_{i} }} {q_{it} \ge a_{kt} } \;\;\;k \in {\mathcal{K}},t \in {\mathcal{T}} $$
(10)
$$ \sum\limits_{l = 1}^{{{\text{min}}\left\{ {\left| r \right|,T - t + 1} \right\}}} {a_{{k_{r}^{l} \left( {t + l - 1} \right)}} \ge 1} \;\;\;\;r \in {\mathcal{R}},t \in {\mathcal{T}} $$
(11)
$$ x_{ijt} ,y_{int} \ge 0\;\;\;\;i,j \in {\mathcal{I}},n \in {\mathcal{N}},t \in {\mathcal{T}} $$
(12)
$$ w_{t} ,z_{nt} ,q_{it} ,a_{kt} \in \left\{ {0,1} \right\}\;\;\;\;\;i \in {\mathcal{I}},n \in {\mathcal{N}},k \in {\mathcal{K}},t \in {\mathcal{T} } $$
(13)

In the objective function (1), network lifetime, which is defined as the summation of the period lengths, is maximized. Constraint (2) states that \({w}_{t}\) variables possess a non-increasing structure to avoid the network is being alive at period \(t+1\) after being dead at period \(t\), and to eliminate the symmetrical solutions which expand the solution space unnecessarily. Constraint (3) simply avoids sensors becoming active in periods in which the network is dead. Hence, all sensors become inactive after the network dies. Constraint (4) forces the sum of the total data from nearby sensors and the data produced by the sensor to equal the total data sent by the sensor to nearby sensors and nearby sinks, and this constraint is written for each period and for each sensor. Therefore, the constraint (4) for each sensor guarantees the balance of the data flow for the entire duration of the network. Constraint (5) guarantees that the total energy spent by each sensor to receive, collect, and process data and to transmit data during the lifetime of the network is less than or equal to the initial energy of the sensors battery. Constraint (6) prevents data transmission to sink points where there is no sink for the current period, and the constraint is written for each period. The constraint (7) states that each sink must be somewhere in each period. Constraints (8) and (9), respectively, state that the amount of outflow from and inflow to an inactive sensor cannot be positive. Constraint (10) is put for each coverage point \(k\in \mathcal{K}\) and for each period \(t\in \mathcal{T}\) and simply detects whether or not the coverage point \(k\) is observed by active nearby sensors during period\(t\). Basically, active sensors that are able to cover the point \(k\) at period \(t\) are counted that number is put as an upper bound on the \({a}_{kt}\) variable which indicates whether or not point \(k\) is observed at period \(t\) meaning that if there is no active nearby sensor to point \(k\) at period \(t\), then \({a}_{kt}\) variable is forced to be equal to 0. Next constraint numbered as (11) is the trademark point of this study. By this constraint, we ensure to detect an intruder independent of the path he chooses, and independent of the period of time he enters the route. The assumption we make to discretize the time plays a critical role in the structure of this constraint. We assume that the time periods possess two minutes lengths and an intruder passes from one surveillance point to a neighboring coverage point in 2 min, i.e., in a single period of time. Therefore, we basically assume that the travel time that passes between two neighboring coverage points of any route is equal to a single period of time. If, for instance, the distance between two neighboring coverage points is taken as 100 m, 2 min travel time between two neighboring coverage points becomes reasonable. Now, constraint (11) is put for each route and for any possible entering time to the route. To better visualize the constraint, suppose a route is consisted of coverage points 1, 5 and 8. A constraint \({a}_{11}+{a}_{52}+{a}_{83}\ge 1\) is put to detect an intruder that enters the route at period 1. The intruder that enters the route will be at point 1 at period 1, at point 5 at period 2, and at point 8 at period 3. Hence, if at least one of\({a}_{11}\), \({a}_{52}\) and \({a}_{83}\) is 1, then we ensure the detection of the intruder. If intruder enters the route at period 2, then the constraint \({a}_{12}+{a}_{53}+{a}_{84}\ge 1\) does the job in a similar manner. Hence, we have a similar constraint for each route and for each entering period to guarantee the detection of the intruder. Finally, constraint (12) and constraint (13) are put for usual nonnegativity and binary restrictions on the variables.

Since WSNDID is a highly complex structure, solving medium-to-large instances of WSND may require prohibitively large computation time. It is commonly known that generic mixed-integer linear programs are NP-hard problems and WSNDID is also NP-hard. Therefore, there is solution strategy that exactly solves instances of WSNDID in polynomial time. [Interested readers should consult the seminal work of Wolsey (1998).] This reinforces the need to use a heuristic solving method to solve relatively larger instances. Then, we propose a new heuristic based on Lagrangean relaxation of the formulation in which we relax the coupled constraints to reach a formulation that is easy to solve.

4 Lagrangean heuristic

In this section, we explain the details of the Lagrangean heuristic. First, we elaborate why we choose Lagrangean relaxation as solution method in a subsection. Next, we construct the Lagrangean subproblem by explaining selection and relaxation scheme of the coupling constraints in the next subsection. Then, we give details of subgradient algorithm employed for optimization of Lagrange multipliers. Finally, we provide a subprocedure that works as a heuristic to restore feasible solutions from the Lagrangean subproblem solutions.

4.1 Justification of using Lagrange relaxation

To be able to cover a sufficient number of solutions, common solution strategies such as metaheuristics that search the solution space within a neighborhood must be able to evaluate the quality of the nearby solutions in a relatively short amount of time. Nevertheless, in every iteration of the applied metaheuristic, we must fix binary decisions of WSNDID and solve the remaining LP model to optimality after leaping to an adjacent solution. Because of this, the time spent evaluating each surrounding solution is equivalent to the time spent solving the aforementioned LP, which could be excessive for large instances. Consequently, we can only explore a very small portion of the solution space and must stop searching before the metaheuristic converges, because the solution space for all of the binary decisions in the WSNDID is rather huge. In the end, this results in comparatively shorter network lives. Finally, and perhaps most importantly, the quality and viability of the many variable sets of the complex MILP models, such as WSNDID, are interdependent. For example, a sensor cannot function if it is not located at the first hand. In a similar vein, choices about sink movement and sensor positions should be made, so that every sensor can transmit its data to a sink location. Strict limitations serve to regularize the dependencies between the various decision variables. In such a framework, it would most likely become impractical to attempt a random modification of a variable’s value in an attempt to leap to a nearby feasible solution. As a result, it takes a long time to either find a feasible neighbor at each iteration or restore feasibility at each hop. Therefore, in applications like WSNDID where feasible solutions are largely surrounded by infeasible ones, heuristic techniques using random jump strategies are not expected to succeed. It is well recognized in the literature on operations research that effective heuristic tactics for complex MILP models, like WSNDID, typically rely on the notion of breaking the model down into smaller subproblems as opposed to creating a feasible solution and then refining it by random jumps. There are only a limited number of decomposition ideas in the literature which are Lagrangean relaxation, Dantzig Wolfe decomposition, and Berder’s decomposition. On the other hand, variants of branch-and-bound strategies focus on decomposition of the solution space rather than decomposition of the model itself. Lagrangean relaxation and Dantzig Wolfe decomposition strategies have similar feasible solution generation performances, since similar subproblems are generated by both of them. On the contrary, applying a successful Bender’s decomposition requires strengthening of the subproblems by generating strong valid inequalities. We do not choose Bender’s decomposition as the solution strategy, since nobody can guarantee that needed strong inequalities would be generated. Finally, branch-and-bound strategies constitute the main solution technique of the commercial MILP solvers. Therefore, by running the commercial solver for WSNDID instances, we would already have the performance of the branch-and-bound like algorithms on the WSNDID instances and we will show the superiority of the results found by the Lagrangean heuristic strategy over the same instances in the numerical results section.

4.2 Lagrangean subproblem

In Lagrangean relaxation, the coupling constraints of the WSNDID are relaxed in an attempt to ease the solution. Observe that the only constraint that does not depend on time index \(t\) is constraint (5) implying that if that constraint is relaxed, then the remaining formulation can be decomposed for each \(t\in \mathcal{T}\). However, the constraint (2) includes variable \({w}_{t+1}\) while the constraint (11) includes variable \({a}_{{k}_{r}^{l}(t+l-1)}\) which are variables belonging to periods different than \(t\) (depending upon the value of \(l\) for \({a}_{{k}_{r}^{l}(t+l-1)}\)). Hence, we should relax constraints (2) and (11), since, otherwise, the decomposed subproblems will not be independent as some of them will share same variables. Hence, we relax constraints (2), (5), and (11) and penalize them in the objective function by multiplying amount of their violations with nonnegative Lagrange coefficients \({\varvec{\theta}}\), \({\varvec{\gamma}}\) and \({\varvec{\beta}}\). We let WSNDID \(({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\) represent the Lagrangean subproblem

$$ \begin{aligned}& {\text{WSNDID}}\left( {{\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}}} \right): \hfill \\& {\text{max}} \sum\limits_{{t \in {\mathcal{T}}}} {w_{t} } + \mathop \sum \limits_{{t \in {\mathcal{T}}\backslash \left| {\mathcal{T}} \right|}} \theta_{t} \left( {w_{t} - w_{t + 1} } \right) + \sum\limits_{{i \in {\mathcal{I}}}} {\gamma_{i} } \left( {E - \sum\limits_{{t \in {\mathcal{T}}}} {} E_{it} } \right) \hfill \\&\quad + \sum\limits_{{r \in {\mathcal{R}}}} {\sum\limits_{{t \in {\mathcal{T}}}} {\beta_{rt} } } \left( {\sum\limits_{l = 1}^{{{\text{min}}\left\{ {\left| r \right|,T - t + 1} \right\}}} {} a_{{k_{r}^{l} \left( {t + l - 1} \right)}} - 1} \right) \hfill \\ \end{aligned} $$
(14)

subject to (3, 4, 610, 12, 13);

where \({E}_{it}\) represents the summation \({c}^{r}{\sum }_{j:i\in {\mathcal{I}}_{j}}{x}_{jit}+{c}^{s}{q}_{it}+{\sum }_{j\in {\mathcal{I}}_{i}}{c}_{ij}^{t}{x}_{ijt}+{\sum }_{n\in {\mathcal{N}}_{i}}{c}_{in}^{t}{y}_{{\text{int}}}\) for all \(i\in \mathcal{I},t\in \mathcal{T}\) and \(UB({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\) denotes the optimal objective function value of the Lagrangean subproblem for a given Lagrange multiplier set \(\left\{{\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}}\right\}\).

To obtain the objective function, in a more compact manner, one needs to find the coefficient of \({w}_{t},{E}_{it}\), and \({a}_{kt}\) variables. Suppose, for now, the coefficient of the \({a}_{kt}\) variable is defined as \({\mu }_{kt}\). Then, we have the following Lagrangean subproblem:

$$ \begin{aligned}& {\text{WSNDID}}\left( {{\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}}} \right): \hfill UB\left( {{\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}}} \right)\\& \quad = {\text{max}}\sum\limits_{{t \in {\mathcal{T}}}} {\left( {1 + \theta_{t} - \theta_{t + 1} } \right)w_{t} } - \sum\limits_{{i \in {\mathcal{I}}}} {\sum\limits_{{t \in {\mathcal{T}}}} {\gamma_{i} E_{it} } } \hfill \\&\qquad + \sum\limits_{{t \in {\mathcal{T}}}} {\sum\limits_{{k \in {\mathcal{K}}}} {\mu_{kt} a_{kt} } } + \sum\limits_{{i \in {\mathcal{I}}}} {\sum\limits_{{t \in {\mathcal{T}}}} {\gamma_{i} E} } - \sum\limits_{{r \in {\mathcal{R}}}} {\sum\limits_{{t \in {\mathcal{T}}}} {\beta_{rt} } } \hfill \\ \end{aligned} $$
(15)

subject to (3, 4, 610, 12, 13).

The value of \({\mu }_{kt}\), that is the coefficient of \({a}_{kt}\) variables for \(k\in \mathcal{K},t\in \mathcal{T}\) are calculated by Algorithm 1 for each \(k\in \mathcal{K},t\in \mathcal{T}\).

figure a

Algorithm 1 Calculation of \({\mu }_{kt}\)

Now, Lagrangean subproblem WSNDID \(({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\) can be decomposed further into subproblems for each \(t\in \mathcal{T}\). We call subproblem for \(t\in \mathcal{T}\) WSNDID \({}_{t}({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\) and its optimal objective function value \(U{B}_{t}({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\). Mathematically

WSNDID \({ }_{t} \left( {{\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}}} \right)\):

$$ UB_{t} \left( {{\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}}} \right) = {\text{max}}\left( {1 + \theta_{t} - \theta_{t + 1} } \right)w_{t} - \sum\limits_{{i \in {\mathcal{I}}}} {\gamma_{i} E_{it} } + \sum\limits_{{k \in {\mathcal{K}}}} {\mu_{kt} a_{kt} } $$

subject to (3, 4, 610, 12, 13) for \(t\) only.

Note that WSNDID \({}_{t}({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\) can be solved relatively easier, since the size of it is considerably lower than the size of WSNDID \(({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\). Also observe that the terms \(\sum_{i\in \mathcal{I}}\sum_{t\in \mathcal{T}}{\gamma }_{i}E\) and \(-\sum_{r\in \mathcal{R}}\sum_{t\in \mathcal{T}}{\beta }_{rt}\) that are in the objective function of the Lagrangean subproblem WSNDID \(({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\) are constant and not put in the objective functions of the subproblems WSNDID \({}_{t}({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\). Now

$$UB({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})=\sum_{t\in \mathcal{T}}U{B}_{t}({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})+\sum_{i\in \mathcal{I}}\sum_{t\in \mathcal{T}}{\gamma }_{i}E-\sum_{r\in \mathcal{R}}\sum_{t\in \mathcal{T}}{\beta }_{rt}$$
(16)

holds.

4.3 Optimization of Lagrange multipliers

\(UB({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\) Is greater than the optimal objective value of WSNDID for any value of \(\{{\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}}\}\). One has to solve the Lagrangean dual problem

$$Z=\underset{{\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}}\ge 0}{{\text{min}}}UB({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})$$
(17)

to find the best (lowest) upper bound. We refer to subgradient optimization for that purpose. Subgradient optimization is known to converge to the optimum Lagrange multiplier values (See Theorem 10.4 of Wolsey (1998)). At each iteration \(n\) of the procedure, the current upper bound \(U{B}^{n}({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\) is calculated from the solution of subproblems WSNDID \({}_{t}({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\) for \(t\in \mathcal{T}\). Then, the Lagrangean multipliers \({{\varvec{\theta}}}^{n},{{\varvec{\gamma}}}^{n},{{\varvec{\beta}}}^{n}\) are re-calculated making use of the value best available lower bound \(L{B}^{*}\). The lower bounds of \(L{B}^{n}\) are computed at each \(n\) iteration, thereby producing a feasible solution to the original problem from solving the subproblems. \(U{B}^{*}\) and \(L{B}^{*}\) are reported at the end of the subgradient optimization. There are three termination criteria the first one of which terminates the algorithm when \(U{B}^{*}-L{B}^{*}<{\epsilon }_{1}\) where \({\epsilon }_{1}\) is a nonnegative value. The second stopping criterion depends on step size parameter \(\phi \); if the value of the best upper bound \(U{B}^{*}\) does not improve after several consecutive \(N\) iterations, the value of \(\phi \) is halved. When \(\phi \) falls below the threshold \({\epsilon }_{2}\), the algorithm stops. Finally, we suggest setting an upper limit on the number of iterations as a final termination criteria, so that no time is wasted unnecessarily. The upper bound on the number of iterations is given by \(iterlim\) in the main part of the algorithm 2.

figure b

Algorithm 2 Lagrangean Heuristic

4.4 Restoring feasible solutions

Main limitation of the Lagrangean heuristics in general is the necessity of the creation of a feasible solution at each iteration of the heuristics. Note that the solutions coming from the Lagrangean subproblems do not necessarily have to be feasible for the original model, since some set of constraints of the original model are relaxed to obtain the subproblems. Hence, one has to transform the solution coming from the subproblems with minimum possible alterations, so that they constitute a feasible solution for the original model. This mechanism (restoring a feasible solution from the subproblem solutions) itself is called as a heuristic too. If this heuristic is able to produce good-quality feasible solution(s) in relatively small amount of time, then the Lagrangean heuristic is expected to be successful. Therefore, success of the Lagrangean heuristics depends mostly on the performance of the feasible solution restoration from the subproblem solutions.

A feasible solution is formed at each iteration of Lagrangean heuristic from the Lagrangean subproblem solutions as stated above. Since constraints (2), (5) and (11) are relaxed in the Lagrangean subproblem, values of variables coming from subproblems WSNDID \({}_{t}({\varvec{\theta}},{\varvec{\gamma}},{\varvec{\beta}})\) for \(t\in \mathcal{T}\) are probably not feasible for the original WSNDID problem. Nevertheless, a feasible solution can still be obtained using the solution coming from the solution of the Lagrangean subproblem. We first order the periods, so that the lengths of the periods are ordered from largest to smallest. This is necessary to make the solution obey with constraint (2). Then, for each sensor node, we check whether the total energy spent by the sensor throughout all the periods exceeds its battery energy or not and starting from last period and coming toward the first period we keep making the sensor passive at the periods until the total energy spent by the sensor decreases below the initial battery energy. By doing so, we make sure that constraint (5) is satisfied. At the final stage, for each route, say route \(r\), and for each period, say \(t\), we test whether route \(r\) is covered for an intruder if the intruder selects to enter the route at period \(t\). If the route is not covered, then among the sensors capable of covering route \(r\) (if intruder starts the route at \(r\)), we find the one having the largest \(E-\sum_{t\in \mathcal{T}}{E}_{it}\) value. Suppose we let that sensor be called \(\widehat{i}\) and the related period (the period in which sensor \(\widehat{i}\) is able to cover route \(r\) for an intruder starting the route at \(t\)) be called \(\widehat{t}\). Then we make sensor \(\widehat{i}\) be active at period \(\widehat{t}\) to cover the route, i.e., we let \({q}_{\widehat{i}\widehat{t}}=1\). After that stage, we ensure that the constraint (11) will be satisfied. However, by making passive constraints active in an attempt to satisfy (11), it is possible to violate constraint (5) by forcing some constraints to be active more than they should. Hence, at the end, the values of the integer variables are fixed in the original WSNDID problem from the values of them already at hand (coming from the solution of the subproblems and updated during the procedure explained here), and if the remaining linear program is feasible, then its optimal objective function value constitutes a proper lower bound, the feasible solution and the lower bound are recorded for the corresponding step, and if the remaining LP is infeasible, then we bypass the current step without a feasible solution. These steps are formally summarized in Algorithm 3.

figure c

5 Computational results

In this section, we first explain the selection of parameters used in the formulation of the mathematical model, and then, we illustrate the efficiency of the heuristic for the generated test instances. Subproblems are solved by the commercial MILP solver Gurobi.

5.1 Test bed

We suppose that sensor area possesses a grid structure and a sensor is placed on each corner point of the grid. Horizontal and vertical distances between neighboring sensors are taken as 100 m. We suppose that sensor area is a mountainous terrain making it difficult to pass through 100 m so fast. Hence, we assume that it takes 2 min time for an intruder to pass through between neighboring coverage points. Six different border zone instances with 20, 36, 56, 72, 88, and 108 number of sensors are assumed and the grid sizes become \(4\times 5\), \(6\times 6\), \(7\times 8\), \(8\times 9\), \(8\times 11\), and \(9\times 12\), respectively. On the other hand, center point of each grid square is assumed to be a coverage point and a sink visit point at the same time. Hence, there are four sensors that are available to sense each coverage point. That makes the coverage point grids \(3\times 4\), \(5\times 5\), \(6\times 7\), \(7\times 8\), \(7\times 10\), and \(8\times 11\), respectively. An intruder can pass from a coverage point to a neighboring one, but we assume that he/she does not go back to a point that he/she passed before, i.e., he/she does not waste time. The coverage points that present at the left-hand side of the sensor area are called as the entering points and the sensors that are present at the right-hand side of the sensor area are called as the leaving points. A route is a collection of coverage points that, respectively, begins from an entering point and ends at a leaving point and any consecutive coverage points in the route are neighbors, meaning that they lay near to each other in the sensor area. Moreover, there may be natural barricades in the sensor area avoiding transition between some neighboring coverage points. With 20% probability, any connection between neighboring coverage points is randomly selected to be closed in the application. All the instances and codes are available on line via the link https://drive.google.com/drive/folders/1O9UX0KaU3WRIPjmzYEU2C5Lom00LJqGY?usp=sharing. We give the sensor area with 108 sensors as an example in Fig. 1.

Fig. 1
figure 1

Sensor area for the Instance with 108 sensors

As can be observed from Fig. 1, sensor points are represented by dots, while coverage points are shown by triangles. If there is a natural barricade avoiding passing between two neighboring coverage points, then border line between the grid squares are drawn by red lines. Consequently, there are possible 1768 routes for that instance that begins from an entering point and ends at a leaving point and no route contains two coverage points; consequently, if there is a natural barricade between them and, similarly, no route contains a coverage point more than once, since going back is not allowed. Moreover, at each period, we place three sinks for all instances, i.e., \(P=3\). Finally, the number of periods are taken as 100.

We take sensing range and communication ranges of the sensors, respectively, as 75 and 100 m. Moreover, we assume that sensors have 100 J symbolic battery energies and each sensor produces 4096 bits data per hour, i.e., \(h=4096\) bits/hour which is equal to 136.53 bit per period. Note that a period length is taken as 2 min. As proposed in Heinzelman et al. (2000), the energy consumed by the transmission sensor is linearly proportional with the square of transmission distance added by a constant part. Mathematically, the amount of energy that a sensor in \(i\) consumes to transfer to a sensor in \(j\) is equal to \({c}_{ij}^{t}={\kappa }_{1}\)+\({\kappa }_{2}{d}_{ij}^{2}\), where \({\kappa }_{1}\) is the constant energy segment, \({\kappa }_{2}\) is the partial weight relative to the distance, and \({d}_{ij}\) represents the Euclidean distance between points \(i\) and\(j\). We choose \({\kappa }_{1}\) as \(50\) \({\text{mJ}}/{\text{bit}}\) and \({\kappa }_{2}\) as \(100\mathrm{\mu J}/({\text{bit}}\cdot {m}^{2})\). Also assume that the amount of energy used to receive the data bits is \(50mJ\), that is, \({c}^{r}=50{\text{mJ}}/{\text{bit}}\). Ultimately, the amount of energy the sensor expends to capture and process a unit of data (for example, a bit) during a unit of time (for example, an hour) becomes 50\(\mathrm{\mu J}/({\text{hour}}\cdot {\text{bit}})\), \({{\text{c}}}^{{\text{s}}}=\) 50\(\mathrm{\mu J}/({\text{time}}\cdot {\text{bit}})\). For selection of parameter values, see study (Heinzelman et al. 2000).

5.2 Performance of the heuristic

In this section, we assess the solutions found by the the state-of-the- art MILP solver Gurobi (2020) and the Lagrangean heuristic on the mentioned instances. We code WSNDID and Lagrangean heuristic in Visual Studio environment by C# language and we carry out all experiments on a single core of a Dell computer having four Intel i7 core and 32 gigabytes of RAM operating within Windows Server Edition 2003.

Note that we write a constraint (11) for each route and for each period of time which makes an enormous number of constraints. Hence, to come up with the optimal solution from Gurobi solver, the size of the model should be made smaller by reducing the number of constraints especially the ones that are of the constraint (11) type. To reduce the number of these constraints, we make use of the following interesting observation. Suppose that there are two routes one of which is totally included in the other one. Then, as we know detection of an intruder is guaranteed in the smaller route, then we is also sure that he/she will be detected at the longer one. Hence, we can delete the constraint (11) written for one of the routes for each period without harming the reality that the intruder is still guaranteed to be detected. By making these eliminations, the number of routes are reduced by 33.03% on the average. After the route elimination phase, we let Gurobi run for at most 3 h for the model and we report the lifetime values found in the allowed computation time. Similarly, we set 3 h running time limitations for the heuristic as well. We illustrate the network lifetimes found by Gurobi and the heuristic in Fig. 2.

Fig. 2
figure 2

Lifetimes of the networks

One may observe from the figure that the network lifetimes found by the heuristic increases proportional with the network size contrary to the expectations. As the size of the graph increase, it becomes more convenient for the heuristic to find sensors to be scheduled in such a way that the intruder is always monitored. Hence, since there are more options for sensor schedules for the solver, it becomes possible to balance the energy among the sensors for larger amount of periods which eventually extends the network lifetime. On the other hand, solver’s performance decreases rapidly as the size of the problem instance increases. For each of the instances, both solution alternatives use the entire allotted computation times including the smallest instance with 20 number of sensors. Hence, we choose not to report computation times. Moreover, we also do not report the upper bound value reported by the solver as well as the Lagrangean upper bound at the end of the computation times, since they are always 100 which is the highest possible value, since the number of periods is set to 100.

Therefore, to evaluate the efficiency of the schedules found by the heuristic better, we test it by comparing results of the heuristic against random sensor schedules. For that purpose, we define a parameter \(\alpha \). Then, we generate random schedules for each test instance and for each period taking the \(\alpha \) value as the probability of each sensor to be active. Moreover, we iterate \(\alpha \) from 0 to 100% one by one. Namely, for each value of \(\alpha \), we generate a sensor schedule for each period by generating a random number from (0, 1) interval and we make the sensor active if the generated number is less than \(\alpha \) value. After obtaining the schedules, we calculate two measures to quantify the quality of the generated instances. First, we count the number of routes that are captured by the random schedule for each period, and for each possible entry time of the intruder. we then calculate the percentage of the routes that are monitored by the random sensor schedule over the total number of possible intruder routes for each entry time. That measure is going to tell us how much the random schedule is successful in detecting the intruder. The second measure is the network lifetime. It should be noted that by making each sensor active for each period, we can be sure that the intruder is detected for sure implying a 100% detection rate, but since all the sensors spend energy (since they are all kept in active mode), that solution will last for a very little amount of time or will not last at all. Hence, the network lifetime should also be considered along with the detection rate to evaluate the quality of a sensor schedule. From these two measures, which are detection rate and the network lifetime, we generate another measure to quantify the quality of the sensor schedule and name it as efficiency. The efficiency measure is calculated as the product of detection rate and the network lifetime. Hence, for each value of \(\alpha \) (we have 101 \(\alpha \) values changing from 0 to 100%), we have three measures of sensor schedule quality calculated for the random sensor schedules. Moreover, to obtain a comparison basis of the quality of the random schedules, we have to obtain the efficiency measure of the heuristic result as well. It is easy to see that as constraint (11) requires that each intruder route is monitored independent of the intruder entry time, the detection rate of the heuristic result is 100%. Hence, the efficiency measure, which is product of detection rate and the network lifetime, of the sensor schedule produced by the heuristic is equal to the network lifetime. We also calculate the \(\alpha \) value corresponding to the heuristic result as well. For that purpose, looking at the values of the \({q}_{it}\) variables coming from the model, we count the number of sensors that are active at each period, and sum up these numbers for all periods. Then, \(\alpha \) value is equated to the division of the founded sum by the 100 \(\times \) total number of sensors. Here, total number of sensors is multiplied by 100, since the number of periods is 100. We report all the values in Table 4 in the following.

Table 4 Quality of the random schedules and schedule generated by the model: all results

There are two main parameters given in Table 3 which are number of sensors (ranging from 20 to 108 in Table 3) and \(\alpha \) value (which represents the probability of each sensor to be active and ranging from 0 to 100 in Table 3). Different values are assigned to these parameters to observe how their different values affect the overall performance measures which are detection rate, lifetime, and efficiency (which can be obtained by multiplying lifetime and efficiency rates). One may observe by examining random sensor activity schedule results that, contrary to heuristic results, lifetime generally decreases as the number of sensors increases. On the other hand, increasing the number of sensors generally increases the detection rate of the intruder. Likewise, as the increase in the \(\alpha \) value increases the probability of the sensors being active in any period, the probability of the intruder being caught increases naturally leading to a rise in detection rate performance measure, while the lifetime decreases as the probability of the active sensors being connected decreases by the increase in the number of active sensors.

As the results given in Table 4 are too cumbersome, we provide a summary of them in Fig. 3. Consequently, the efficiency of the model result is illustrated together with the quality measures of the random sensor schedules in Fig. 3.

Fig. 3
figure 3

Quality of the random schedules and schedule generated by the model: summary

First observation to be made looking at Fig. 3 is that the efficiency of the model result gets better and better as the number of the sensors increase. Hence, the model can be said to produce good sensor schedules for relatively larger instances. Moreover, the model result is more efficient than all the sensor schedules for all \(\alpha \) values for the instances with 56, 72, 88, and 108 number of sensors. In addition, one may see that efficiency of random schedules is better than efficiency of the model result for only a very few number of \(\alpha \) values for the instances with 20 and 36 number of sensors. However, this better efficiency values obtained for a few number of \(\alpha \) values is obtained at the cost of lower detection rates. The efficiency value of the heuristic result can be improved even more if we does not force 100% detection rates constraint (11). In summary, it is clear that the heuristic result generated after solving instances of the offered model has better qualities than the random sensor schedules, although a 100% detection rate is imposed on the heuristic result. Therefore, one may refer to the offered heuristic algorithm for real-life application of WSNs for intruder detection.

6 Conclusions and discussion

We devise a mathematical model integrating the data and mobile sink routing problem with the activity scheduling problem to maximize WSN lifetime. We offer a Lagrangean heuristic as a solution method. We envisage a sensor area with a grid structure and a sensor is located at each connection point of the grid area. On the other hand, coverage points, which make the routes, are assumed to be on the centroids of the grid squares. Hence, it is like we put the sensors to cover the possible routes. As there may be natural barricades avoiding passage between some coverage points in reality, we randomly select some connections and avoid them to be a part of any route. Therefore, a route is an order of the neighboring coverage points starting and ending with, respectively, entering and leaving points not including two neighboring coverage points if a barricade is randomly assigned in between. The main contribution of the paper is that, while handling the activity scheduling problem together with the data and sink routing problems, we ensure the detection of any intruder independent of the route he/she selects and the period of time he/she enters the rote throughout the network lifetime.

This study can be extended by putting aforementioned theoretical approach in practice and testing the heuristic under real conditions. Another way is to test this approach in some real-life WSN simulators, such as TOSSIM (Levis et al. 2003) and OMNeT +  + (Varga and Hornig 2008). Moreover, employing Bender’s decomposition on WSNDID is an interesting research possibility which we plan to implement in the future. Valid inequalities generated during Bender’s decomposition process can also be used to analyze the polyhedral characteristics of the WSNDID formulation.