# Set covering problem

Authors: Sherry Liang, Khalid Alanazi, Kumail Al Hamoud

## Introduction

The set covering problem is a significant NP-hard problem in combinatorial optimization. Given a collection of elements, the set covering problem aims to find the minimum number of sets that incorporate (cover) all of these elements. [1]

The set covering problem importance has two main aspects: one is pedagogical, and the other is practical.

First, because many greedy approximation methods have been proposed for this combinatorial problem, studying it gives insight into the use of approximation algorithms in solving NP-hard problems. Thus, it is a primal example in teaching computational algorithms. We present a preview of these methods in a later section, and we refer the interested reader to these references for a deeper discussion. [1] [2] [3]

Second, many problems in different industries can be formulated as set covering problems. For example, scheduling machines to perform certain jobs can be thought of as covering the jobs. Picking the optimal location for a cell tower so that it covers the maximum number of customers is another set covering application. Moreover, this problem has many applications in the airline industry, and it was explored on an industrial scale as early as the 1970s. [4]

## Problem formulation

In the set covering problem, two sets are given: a set ${\displaystyle U}$ of elements and a set ${\displaystyle S}$ of subsets of the set ${\displaystyle U}$. Each subset in ${\displaystyle S}$ is associated with a predetermined cost, and the union of all the subsets covers the set ${\displaystyle U}$. This combinatorial problem then concerns finding the optimal number of subsets whose union covers the universal set while minimizing the total cost.[1] [5]

The mathematical formulation of the set covering problem is define as follows. We define U = {${\displaystyle u_{i}}$, ….. ${\displaystyle u_{m}}$} as the universe of elements and S = {${\displaystyle s_{1}}$, ….,${\displaystyle s_{n}}$} as a collection of subsets such that ${\displaystyle s_{i}}$ ${\displaystyle \in }$U and the union of ${\displaystyle s_{i}}$ covers all elements in U (i.e. ${\displaystyle \cup }$${\displaystyle s_{i}}$ = U ). Addionally, each set ${\displaystyle s_{i}}$ must cover at least one element of ${\displaystyle U}$ and has associated cost ${\displaystyle c_{i}}$ such that ${\displaystyle c_{i}>0}$. The objective is to find the minimum cost sub-collection of sets X ${\displaystyle \in }$ S that covers all the elements in the universe ${\displaystyle U}$.

## Integer linear program formulation

An integer linear program (ILP) model can be formulated for the minimum set covering problem as follows:[1]

Decision variables

${\displaystyle y_{i}={\begin{cases}1,&{\text{if subset }}i{\text{ is selected}}\\0,&{\text{otherwise }}\end{cases}}}$

Objective function

minimize ${\displaystyle \sum _{i=1}^{n}c_{i}y_{i}}$

Constraints

${\displaystyle \sum _{i=1}^{n}y_{i}>=1,\forall i=1,....,m}$

${\displaystyle y_{i}\in \{0,1\},\forall i=1,....,n}$

The objective function ${\displaystyle \sum _{i=1}^{n}c_{i}y_{i}}$ is defined to minimize the number of subset ${\displaystyle s_{i}}$ that cover all elements in the universe by minimizing their total cost. The first constraint implies that every element ${\displaystyle i}$ in the universe ${\displaystyle U}$ must be be covered and the second constraint ${\displaystyle y_{i}\in \{0,1\}}$ indicates that the decision variables are binary which means that every set is either in the set cover or not.

Set covering problems are significant NP-hard optimization problems, which implies that as the size of the problem increases, the computational time to solve it increases exponentially. Therefore, there exist approximation algorithms that can solve large scale problems in polynomial time with optimal or near-optimal solutions. In subsequent sections, we will cover two of the most widely used approximation methods to solve set cover problem in polynomial time which are linear program relaxation methods and classical greedy algorithms. [2]

## Approximation via LP relaxation and rounding

Set covering is a classical integer programming problem and solving integer program in general is NP-hard. Therefore, one approach to achieve an ${\displaystyle O}$(log${\displaystyle n}$) approximation to set covering problem in polynomial time is solving via linear programming (LP) relaxation algorithms [1] [5]. In LP relaxation, we relax the integrality requirement into a linear constraints. For instance, if we replace the constraints ${\displaystyle y_{i}\in \{0,1\}}$ with the constraints ${\displaystyle 0=, we obtain the following LP problem that can be solved in polynomial time:

minimize ${\displaystyle \sum _{i=1}^{n}c_{i}y_{i}}$

subject to ${\displaystyle \sum _{i=1}^{n}y_{i}>=1,\forall i=1,....,m}$

${\displaystyle 0=

The above LP formulation is a relaxation of the original ILP set cover problem. This means that every feasible solution of the integer program is also feasible for this LP program. Additionally, the value of any feasible solution for the integer program is the same value in LP since the objective functions of both integer and linear programs are the same. Solving the LP program will result in an optimal solution that is a lower bound for the original integer program since the minimization of LP finds a feasible solution of lowest possible values. Moreover, we use LP rounding algorithms to directly round the fractional LP solution to an integral combinatorial solution as follows:

Deterministic rounding algorithm

Suppose we have an optimal solution ${\displaystyle z^{*}}$ for the linear programming relaxation of the set cover problem. We round the fractional solution ${\displaystyle z^{*}}$ to an integer solution ${\displaystyle z}$ using LP rounding algorithm. In general, there are two approaches for rounding algorithms, deterministic and randomized rounding algorithm. In this section, we will explain the deterministic algorithms.In this approach, we include subset ${\displaystyle s_{i}}$ in our solution if ${\displaystyle z^{*}>=1/d}$, where ${\displaystyle d}$ is the maximum number of sets in which any element appears. In practice, we set ${\displaystyle z}$ to be as follows:[5]

${\displaystyle z={\begin{cases}1,&{\text{if }}z^{*}>=1/d\\0,&{\text{otherwise }}\end{cases}}}$

The rounding algorithm is an approximation algorithm for the set cover problem. It is clear that the algorithm converge in polynomial time and ${\displaystyle z}$ is a feasible solution to the integer program.

## Greedy approximation algorithm

Greedy algorithms can be used to approximate for optimal or near-optimal solutions for large scale set covering instances in polynomial solvable time. [2] [3] The greedy heuristics applies iterative process that, at each stage, select the largest number of uncovered elements in the universe ${\displaystyle U}$, and delete the uncovered elements, until all elements are covered. [6] Let ${\displaystyle T}$ be the set that contain the covered elements, and ${\displaystyle U}$ be the set that contain the elements of ${\displaystyle Y}$ that still uncovered. At the beginning of the iteration, ${\displaystyle T}$ is empty and all elements ${\displaystyle Y\in U}$. We iteratively select the set of ${\displaystyle S}$ that covers the largest number of elements in ${\displaystyle U}$ and add it to the covered elements in ${\displaystyle T}$. An example of this algorithm is presented below.

Greedy algorithm for minimum set cover example:

Step 0: ${\displaystyle \quad }$ ${\displaystyle T\in \Phi }$ ${\displaystyle \quad \quad \quad \quad \quad }$ { ${\displaystyle T}$ stores the covered elements }

Step 1: ${\displaystyle \quad }$ While ${\displaystyle U\neq \Phi }$ do: ${\displaystyle \quad }$ { ${\displaystyle U}$ stores the uncovered elements ${\displaystyle Y}$}

Step 2: ${\displaystyle \quad \quad \quad }$ select ${\displaystyle s_{i}\in S}$ that covers the highest number of elements in ${\displaystyle U}$

Step 3: ${\displaystyle \quad \quad \quad }$ add ${\displaystyle s_{i}}$ to ${\displaystyle T}$

Step 4: ${\displaystyle \quad \quad \quad }$ remove ${\displaystyle s_{i}}$ from ${\displaystyle U}$

Step 5: ${\displaystyle \quad }$ End while

Step 6: ${\displaystyle \quad }$ Return ${\displaystyle S}$

## Numerical Example

Let’s consider a simple example where we assign cameras at different locations. Each location covers some areas of stadiums, and our goal is to put the least amount of cameras such that all areas of stadiums are covered. We have stadium areas from 1 to 15, and possible camera locations from 1 to 8.

We are given that camera location 1 covers stadium areas {1,3,4,6,7}, camera location 2 covers stadium areas {4,7,8,12}, while the remaining camera locations and the stadium areas that the cameras can cover are given in table 1 below:

Table 1
1 1,3,4,6,7
2 4,7,8,12
3 2,5,9,11,13
4 1,2,14,15
5 3,6,10,12,14
6 8,14,15
7 1,2,6,11
8 1,2,4,6,8,12

To reformulate the problem, we can list the stadium areas and the camera locations that cover each stadium area. For instance, stadium area 1 can be covered with camera location {1,4,7,8}, stadium area 2 can be covered with camera location {3,4,7,8}, while the rest are given in table 2 below:

Table 2
1 1,4,7,8
2 3,4,7,8
3 1,5
4 1,2,8
5 3
6 1,5,7,8
7 1,2
8 2,6,8
9 3
10 5
11 3,7
12 2,5,8
13 3
14 4,5,6
15 4,6

We can then represent the above information using binary values. If the stadium area ${\displaystyle i}$ can be covered with camera location ${\displaystyle j}$, then we have ${\displaystyle y_{ij}=1}$. If not,${\displaystyle y_{ij}=0}$. For instance, stadium area 1 is covered by camera location 1, so ${\displaystyle y_{11}=1}$, while stadium area 1 is not covered by camera location 2, so ${\displaystyle y_{12}=0}$. The binary variables ${\displaystyle y_{ij}}$ values are given in the table below:

Table 3
1 2 3 4 5 6 7 8
1 1 1 1 1
2 1 1 1 1
3 1 1
4 1 1 1
5 1
6 1 1 1 1
7 1 1
8 1 1 1
9 1
10 1
11 1 1
12 1 1 1
13 1
14 1 1 1
15 1 1

We introduce another binary variable ${\displaystyle z_{j}}$ to indicate if a camera is installed at location ${\displaystyle j}$. ${\displaystyle z_{j}=1}$ if camera is installed at location ${\displaystyle j}$, while ${\displaystyle z_{j}=0}$ if not.

Our objective is to minimize ${\displaystyle \sum _{j=1}^{8}z_{j}}$. For each stadium, there’s a constraint that the stadium area ${\displaystyle i}$ has to be covered by at least one camera location. For instance, for stadium area 1, we have ${\displaystyle z_{1}+z_{4}+z_{7}+z_{8}\geqslant 1}$, while for stadium 2, we have ${\displaystyle z_{3}+z_{4}+z_{7}+z_{8}\geqslant 1}$. All the 15 constraints that corresponds to 15 stadium areas are listed below:

Constraints 1 to 15:

${\displaystyle 1.z_{1}+z_{4}+z_{7}+z_{8}\geqslant 1}$

${\displaystyle 2.z_{3}+z_{4}+z_{7}+z_{8}\geqslant 1}$

${\displaystyle 3.z_{1}+z_{5}\geqslant 1}$

${\displaystyle 4.z_{1}+z_{2}+z_{8}\geqslant 1}$

${\displaystyle 5.z_{3}\geqslant 1}$

${\displaystyle 6.z_{1}+z_{5}+z_{7}+z_{8}\geqslant 1}$

${\displaystyle 7.z_{1}+z_{2}\geqslant 1}$

${\displaystyle 8.z_{2}+z_{6}+z_{8}\geqslant 1}$

${\displaystyle 9.z_{3}\geqslant 1}$

${\displaystyle 10.z_{5}\geqslant 1}$

${\displaystyle 11.z_{3}+z_{7}\geqslant 1}$

${\displaystyle 12.z_{2}+z_{5}+z_{8}\geqslant 1}$

${\displaystyle 13.z_{3}\geqslant 1}$

${\displaystyle 14.z_{4}+z_{5}+z_{6}\geqslant 1}$

${\displaystyle 15.z_{4}+z_{6}\geqslant 1}$

From constraint {5,9,13}, we can obtain ${\displaystyle z_{3}=1}$. Thus we no longer need constraint 2 and 11 as they are satisfied when ${\displaystyle z_{3}=1}$. With ${\displaystyle z_{3}=1}$ determined, the constraints left are:

${\displaystyle 1.z_{1}+z_{4}+z_{7}+z_{8}\geqslant 1}$

${\displaystyle 3.z_{1}+z_{5}\geqslant 1}$

${\displaystyle 4.z_{1}+z_{2}+z_{8}\geqslant 1}$

${\displaystyle 6.z_{1}+z_{5}+z_{7}+z_{8}\geqslant 1}$

${\displaystyle 7.z_{1}+z_{2}\geqslant 1}$

${\displaystyle 8.z_{2}+z_{6}+z_{8}\geqslant 1}$

${\displaystyle 10.z_{5}\geqslant 1}$

${\displaystyle 12.z_{2}+z_{5}+z_{8}\geqslant 1}$

${\displaystyle 14.z_{4}+z_{5}+z_{6}\geqslant 1}$

${\displaystyle 15.z_{4}+z_{6}\geqslant 1}$

Now if we take a look at constraint ${\displaystyle 10.z_{5}\geqslant 1}$ so ${\displaystyle z_{5}}$ shall equal to 1. As ${\displaystyle z_{5}=1}$, constraint {3,6,12,14} are satisfied no matter what other ${\displaystyle z}$ values are taken. If we also take a look at constraint 7 and 4, if constraint 4 will be satisfied as long as constraint 7 is satisfied since ${\displaystyle z}$ values are nonnegative, so constraint 4 is no longer needed. The remaining constraints are:

${\displaystyle 1.z_{1}+z_{4}+z_{7}+z_{8}\geqslant 1}$

${\displaystyle 7.z_{1}+z_{2}\geqslant 1}$

${\displaystyle 8.z_{2}+z_{6}+z_{8}\geqslant 1}$

${\displaystyle 15.z_{4}+z_{6}\geqslant 1}$

The next step is to focus on constraint 7 and 15. We can have at least 4 combinations of ${\displaystyle z_{1},z_{2},z_{4},z_{6}}$values.

${\displaystyle A:z_{1}=1,z_{2}=0,z_{4}=1,z_{6}=0}$

${\displaystyle B:z_{1}=1,z_{2}=0,z_{4}=0,z_{6}=1}$

${\displaystyle C:z_{1}=0,z_{2}=1,z_{4}=1,z_{6}=0}$

${\displaystyle D:z_{1}=0,z_{2}=1,z_{4}=0,z_{6}=1}$

We can then discuss each combination and determine ${\displaystyle z_{7},z_{8}}$values for constraint 1 and 8 to be satisfied.

Combination ${\displaystyle A}$: constraint 1 already satisfied, we need ${\displaystyle z_{8}=1}$ to satisfy constraint 8.

Combination ${\displaystyle B}$: constraint 1 already satisfied, constraint 8 already satisfied.

Combination ${\displaystyle C}$: constraint 1 already satisfied, constraint 8 already satisfied.

Combination ${\displaystyle D}$: we need ${\displaystyle z_{7}=1}$ or ${\displaystyle z_{8}=1}$ to satisfy constraint 1, while constraint 8 already satisfied.

Our final step is to compare the four combinations. Since our objective is to minimize ${\displaystyle \sum _{j=1}^{8}z_{j}}$ and combinations ${\displaystyle B}$ and ${\displaystyle C}$ require the least amount of ${\displaystyle z_{j}}$ to be 1, they are the optimal solutions.

To conclude, our two solutions are:

${\displaystyle Solution1:z_{1}=1,z_{3}=1,z_{5}=1,z_{6}=1}$

${\displaystyle Solution2:z_{2}=1,z_{3}=1,z_{4}=1,z_{5}=1}$

The minimum number of cameras that we need to install is 4.

## Applications

The applications of the set covering problem span a wide range of applications, but its usefulness is evident in industrial and governmental planning. Variations of the set covering problem that are of practical significance include the following.

The optimal location problem

This set covering problems is concerned with maximizing the coverage of some public facilities placed at different locations. [7] Consider the problem of placing fire stations to serve the towns of some city. [8] If each fire station can serve its town and all adjacent towns, we can formulate a set covering problem where each subset consists of a set of adjacent towns. The problem is then solved to minimize the required number of fire stations to serve the whole city.

Let ${\displaystyle y_{i}}$ be the decision variable corresponding to choosing to build a fire station at town ${\displaystyle i}$. Let ${\displaystyle S_{i}}$ be a subset of towns including town ${\displaystyle i}$ and all its neighbors. The problem is then formulated as follows.

minimize ${\displaystyle \sum _{i=1}^{n}y_{i}}$

such that ${\displaystyle \sum _{i\in S_{i}}y_{i}\geq 1,\forall i}$

A real-world case study involving optimizing fire station locations in Istanbul is analyzed in this reference. [8] The Istanbul municipality serves 790 subdistricts, which should all be covered by a fire station. Each subdistrict is considered covered if it has a neighboring district (a district at most 5 minutes away) that has a fire station. For detailed computational analysis, we refer the reader to the mentioned academic paper.

The optimal route selection problem

Consider the problem of selecting the optimal bus routes to place pothole detectors. Due to the scarcity of the physical sensors, the problem does not allow for placing a detector on every road. The task of finding the maximum coverage using a limited number of detectors could be formulated as a set covering problem. [9] [10] Specifically, giving a collection of bus routes R, where each route itself is divided into segments. Route ${\displaystyle i}$ is denoted by ${\displaystyle R_{i}}$, and segment ${\displaystyle j}$ is denoted by ${\displaystyle S_{j}}$. The segments of two different routes can overlap, and each segment is associated with a length ${\displaystyle a_{j}}$. The goal is then to select the routes that maximize the total covered distance.

This is quite different from other applications because it results in a maximization formulation, rather than a minimization formulation. Suppose we want to use at most ${\displaystyle k}$ different routes. We want to find ${\displaystyle k}$ routes that maximize the length of of covered segments. Let ${\displaystyle x_{i}}$ be the binary decision variable corresponding to selecting route ${\displaystyle R_{i}}$, and let ${\displaystyle y_{j}}$ be the decision variable associated with covering segment ${\displaystyle S_{j}}$. Let us also denote the set of routes that cover segment ${\displaystyle j}$ by ${\displaystyle C_{j}}$. The problem is then formulated as follows.

{\displaystyle {\begin{aligned}{\text{max}}&~~\sum _{j}a_{j}y_{j}\\{\text{s.t}}&~~\sum _{i\in C_{j}}x_{i}\geq y_{j}\quad \forall j\\&~~\sum _{i}x_{i}=k\\&~~x_{i},y_{j}\in \{0,1\}\\\end{aligned}}}

The work by Ali and Dyo explores a greedy approximation algorithm to solve an optimal selection problem including 713 bus routes in Greater London. [9] Using 14% of the routes only (100 routes), the greedy algorithm returns a solution that covers 25% of the segments in Greater London. For a details of the approximation algorithm and the world case study, we refer the reader to this reference. [9] For a significantly larger case study involving 5747 buses covering 5060km, we refer the reader to this academic article. [10]

The airline crew scheduling problem

An important application of large-scale set covering is the airline crew scheduling problem, which pertains to assigning airline staff to work shifts. [4] [11] Thinking of the collection of flights as a universal set to be covered, we can formulate a set covering problem to search for the optimal assignment of employees to flights. Due to the complexity of airline schedules, this problem is usually divided into two subproblems: crew pairing and crew assignment. We refer the interested reader to this survey, which contains several problem instances with the number of flights ranging from 1013 to 7765 flights, for a detailed analysis of the formulation and algorithms that pertain to this significant application. [4] [12]

## Conclusion

The set covering problem, which aims to find the least number of subsets that cover some universal set, is a widely known NP-hard combinatorial problem. Due to its applicability to route planning and airline crew scheduling, several methods have been proposed to solve it. Its straightforward formulation allows for the use of off-the-shelf optimizers to solve it. Moreover, heuristic techniques and greedy algorithms can be used to solve large-scale set covering problems for industrial applications.

## References

1. T. Grossman and A. Wool, "Computational experience with approximation algorithms for the set covering problem," European Journal of Operational Research, vol. 101, pp. 81-92, 1997.
2. P. Slavı́k, "A Tight Analysis of the Greedy Algorithm for Set Cover," Journal of Algorithms,, vol. 25, pp. 237-245, 1997.
3. T. Grossman and A. Wool, "What Is the Best Greedy-like Heuristic for the Weighted Set Covering Problem?," Operations Research Letters, vol. 44, pp. 366-369, 2016.
4. J. Rubin, "A Technique for the Solution of Massive Set Covering Problems, with Application to Airline Crew Scheduling," Transportation Science, vol. 7, pp. 34-48, 1973.
5. Williamson, David P., and David B. Shmoys. “The Design of Approximation Algorithms” [1]. “Cambridge University Press”, 2011.
6. V. Chvatal, "Greedy Heuristic for the Set-Covering Problem," Mathematics of Operations Research, vol. 4, pp. 233-235, 1979.
7. R. Church and C. ReVelle, "The maximal covering location problem," Papers of the Regional Science Association, vol. 32, pp. 101-118, 1974.
8. E. Aktaş, Ö. Özaydın, B. Bozkaya, F. Ülengin, and Ş. Önsel, "Optimizing Fire Station Locations for the Istanbul Metropolitan Municipality," Interfaces, vol. 43, pp. 240-255, 2013.
9. J. Ali and V. Dyo, "Coverage and Mobile Sensor Placement for Vehicles on Predetermined Routes: A Greedy Heuristic Approach," Proceedings of the 14th International Joint Conference on E-Business and Telecommunications, pp. 83-88, 2017.
10. P.H. Cruz Caminha , R. De Souza Couto , L.H. Maciel Kosmalski Costa , A. Fladenmuller , and M. Dias de Amorim, "On the Coverage of Bus-Based Mobile Sensing," Sensors, 2018.
11. E. Marchiori and A. Steenbeek, "An Evolutionary Algorithm for Large Scale Set Covering Problems with Application to Airline Crew Scheduling," Real-World Applications of Evolutionary Computing. EvoWorkshops 2000. Lecture Notes in Computer Science, 2000.
12. A. Kasirzadeh, M. Saddoune, and F. Soumis "Airline crew scheduling: models, algorithms, and data sets," EURO Journal on Transportation and Logistics, vol. 6, pp. 111-137, 2017.