# Reallocating Multiple Facilities on the Line

We study the multistage K-facility reallocation problem on the real line, where we maintain K facility locations over T stages, based on the stage-dependent locations of n agents. Each agent is connected to the nearest facility at each stage, and the facilities may move from one stage to another, to accommodate different agent locations. The objective is to minimize the connection cost of the agents plus the total moving cost of the facilities, over all stages. K-facility reallocation was introduced by de Keijzer and Wojtczak, where they mostly focused on the special case of a single facility. Using an LP-based approach, we present a polynomial time algorithm that computes the optimal solution for any number of facilities. We also consider online K-facility reallocation, where the algorithm becomes aware of agent locations in a stage-by-stage fashion. By exploiting an interesting connection to the classical K-server problem, we present a constant-competitive algorithm for K = 2 facilities.

• 25 publications
• 3 publications
• 2 publications
• 18 publications
• 14 publications
• 1 publication
03/23/2021

### Facility Reallocation on the Line

We consider a multi-stage facility reallocation problems on the real lin...
05/23/2019

### Maximin-Aware Allocations of Indivisible Goods

We study envy-free allocations of indivisible goods to agents in setting...
10/29/2020

### Performance Indicators Contributing To Success At The Group And Play-Off Stages Of The 2019 Rugby World Cup

Performance indicators that contributed to success at the group stage an...
07/26/2021

### Strategyproof Facility Location in Perturbation Stable Instances

We consider k-Facility Location games, where n strategic agents report t...
06/23/2020

### The Bike Sharing Problem

Assume that m ≥ 1 autonomous mobile agents and 0 ≤ b ≤ m single-agent tr...
08/16/2019

### Parallel Computation of Alpha Complex for Biomolecules

Alpha complex, a subset of the Delaunay triangulation, has been extensiv...
11/26/2018

### Maintaining Perfect Matchings at Low Cost

The min-cost matching problem suffers from being very sensitive to small...

## 1 Introduction

Facility Location is a classical problem that has been widely studied in both combinatorial optimization and operations research, due to its many practical applications. It provides a simple and natural model for industrial planning, network design, machine learning, data clustering and computer vision

Drezner and Hamacher [12], Lazic [19], Caragiannis et al. [7], Betzler et al. [5]. In its basic form, -Facility Location instances are defined by the locations of agents in a metric space. The goal is to find facility locations so as to minimize the sum of distances of the agents to their nearest facility.

In many natural location and network design settings, agent locations are not known in advance. Motivated by this fact, Meyerson [21] introduced online facility location problems, where agents arrive one-by-one and must be irrevocably assigned to a facility upon arrival. Moreover, the fast increasing volume of available data and the requirement for responsive services has led to new, online clustering algorithms Liberty et al. [20], balancing the quality of the clusters with their rate of change over time. In practical settings related to online data clustering, new data points arrive, and the decision of clustering some data points together should not be regarded as irrevocable (see e.g., Fotakis [15] and the references therein).

More recently, understanding the dynamics of temporally evolving social or infrastructure networks has been the central question in many applied areas such as viral marketing, urban planning etc. Dynamic facility location proposed by Eisenstat et al. [13] has been a new tool to analyze temporal aspects of such networks. In this time dependent variant of facility location, agents may change their location over time and we look for the best tradeoff between the optimal connections of agents to facilities and the stability of solutions between consecutive timesteps. The stability of the solutions is modeled by introducing an additional moving cost (or switching cost), which has a different definition depending on the particular setting.

Model and Motivation. In this work, we study the multistage -facility reallocation problem on the real line, introduced by de Keijzer and Wojtczak [10]. In -facility reallocation, facilities are initially located at on the real line. Facilities are meant to serve agents for the next days. At each day, each agent connects to the facility closest to its location and incurs a connection cost equal to this distance. The locations of the agents may change every day, thus we have to move facilities accordingly in order to reduce the connection cost. Naturally, moving a facility is not for free, but comes with the price of the distance that the facility was moved. Our goal is to specify the exact positions of the facilities at each day so that the total connection cost plus the total moving cost is minimized over all days. In the online version of the problem, the positions of the agents at each stage are revealed only after determining the locations of the facilities at stage .

For a motivating example, consider a company willing to advertise its products. To this end, it organizes advertising campaigns at different locations of a large city for the next

days. Based on planned events, weather forecasts, etc., the company estimates a population distribution over the locations of the city for each day. Then, the company decides to compute the best possible campaign reallocation with

de Keijzer and Wojtczak [10] fully characterized the optimal offline and online algorithms for the special case of a single facility and presented a dynamic programming algorithm for facilities with running time exponential in . Despite the practical significance and the interesting theoretical properties of -facility reallocation, its computational complexity and its competitive ratio (for the online variant) are hardly understood.

Contribution. In this work, we resolve the computational complexity of -facility reallocation on the real line and take a first step towards a full understanding of the competitive ratio for the online variant. More specifically, in Section 3, we present an optimal algorithm with running time polynomial in the combinatorial parameters of -facility reallocation (i.e., , and ). This substantially improves on the complexity of the algorithm, presented in [10], that is exponential in

. Our algorithm solves a Linear Programming relaxation and then

rounds the fractional solution to determine the positions of the facilities. The main technical contribution is showing that a simple rounding scheme yields an integral solution that has the exact same cost as the fractional one.

Our second main result concerns the online version of the problem with facilities. We start with the observation that online -facility reallocation problem with facilities is a natural and interesting generalization of the classical -server problem, which has been a driving force in the development of online algorithms for decades. The key difference is that, in the -server problem, there is a single agent that changes her location at each stage and a single facility has to be relocated to this new location at each stage. Therefore, the total connection cost is by definition , and we seek to minimize the total moving cost.

From a technical viewpoint, the -facility reallocation problem poses a new challenge, since it is much harder to track the movements of the optimal algorithm as the agents keep coming. It is not evident at all whether techniques and ideas from the -server problem can be applied to the -facility reallocation problem, especially for more general metric spaces. As a first step towards this direction, we design a constant-competitive algorithm, when . Our algorithm appears in Section 4 and is inspired by the double coverage algorithm proposed for the -server problem Koutsoupias [18].

Related Work. We can cast the -facility reallocation problem as a clustering problem on a temporally evolving metric. From this point of view, -facility reallocation problem is a dynamic -median problem. A closely related problem is the dynamic facility location problem, Eisenstat et al. [13], An et al. [1]. Other examples in this setting are the dynamic sum radii clustering Blanchard and Schabanel [6] and multi-stage optimization problems on matroids and graphs Gupta et al. [17].

In Friggstad and Salavatipour [16], a mobile facility location problem was introduced, which can be seen as a one stage version of our problem. They showed that even this version of the problem is -hard in general metric spaces using an approximation preserving reduction to -median problem.

Online facility location problems and variants have been extensively studied in the literature, see Fotakis [15] for a survey. Divéki and Imreh [11] studied an online model, where facilities can be moved with zero cost. As we have mentioned before, the online variant of the -facility reallocation problem is a generalization of the -server problem, which is one of the most natural online problems. Koutsoupias [18] showed a -competitive algorithm for the -server problem for every metric space, which is also -competitive, in case the metric is the real line Bartal and Koutsoupias [4]. Other variants of the -server problem include the -server problem Bansal et al. [3, 2], the infinite server problem Coester et al. [8] and the -taxi problemFiat et al. [14], Coester and Koutsoupias [9].

## 2 Problem Definition and Preliminaries

###### Definition 1 (K-Facility Reallocation Problem)

We are given a tuple as input. The

dimensional vector

describes the initial positions of the facilities. The positions of the agents over time are described by . The position of agent at stage is and describes the positions of the agents at stage .

###### Definition 2

A solution of K-Facility Reallocation Problem is a sequence . Each is a dimensional vector that gives the positions of the facilities at stage and is the position of facility at stage . The cost of the solution is

 Cost(x)=T∑t=1[K∑k=1|xtk−xt−1k|+n∑i=1min1≤k≤K|αti−xtk|]

Given an instance of the problem, the goal is to find a solution that minimizes the . The term describes the cost for moving the facilities from place to place and we refer to it as moving cost, while the term describes the connection cost of the agents and we refer to it as connection cost.

In the online setting, we study the special case of -facility reallocation problem. We evaluate the performance of our algorithm using competitive analysis; an algorithm is -competitive if for every request sequence, its online performance is at most times worse (up to a small additive constant) than the optimal offline algorithm, which knows the entire sequence in advance.

## 3 Polynomial Time Algorithm

Our approach is a typical LP based algorithm that consists of two basic steps.

• Step 1: Expressing the -Facility Reallocation Problem as an Integer Linear Program.

• Step 2: Solving fractionally the Integer Linear Program and rounding the fractional solution to an integral one.

### 3.1 Formulating the Integer Linear Program

A first difficulty in expressing the -Facility Reallocation Problem as an Integer Linear Program is that the positions on the real line are infinite. We remove this obstacle with help of the following lemma proved in [10].

###### Lemma 3.1

Let an instance of the -facility reallocation problem. There exists an optimal solution such that for all stages and ,

 x∗tk∈C1∪…∪CT∪x0

According to Lemma 3.1, there exists an optimal solution that locates the facilities only at positions where either an agent has appeared or a facility was initially lying. Lemma 3.1 provides an exhaustive search algorithm for the problem and is also the basis for the Dynamic Programming approach in [10]. We use Lemma 3.1 to formulate our Integer Linear Program.

The set of positions can be represented equivalently by a path . In this path, the -th node corresponds to the -th leftmost position of and the distance between two consecutive nodes on the path equals the distance of the respective positions on the real line. Now, the facility reallocation problem takes the following discretized form: We have a path that is constructed by the specific instance . Each facility is initially located at a node and at each stage , each agent is also located at a node of . The goal is to move the facilities from node to node such that the connection cost of the agents plus the moving cost of the facilities is minimized.

To formulate this discretized version as an Integer Linear Program, we introduce some additional notation. Let be the distance of the nodes in , be the set of facilities and be the set of agents. For each , is the node where agent is located at stage . We also define the following -indicator variables for all : if, at stage , agent connects to a facility located at node , if, at stage , facility is located at node , if facility was at node at stage and moved to node at stage . Now, the problem can be formulated as the Integer Linear Program depicted in Figure1.

The first three constraints correspond to the fact that at every stage , each agent must be connected to a node where at least one facility is located. The constraint enforces each facility to be located at exactly one node . The constraint describes the cost for moving facility from node to node . The final two constraints ensure that facility moved from node to node at stage if and only if facility was at node at stage and was at node at stage ( iff and ).

We remark that the values of are determined by the initial positions of the facilities, which are given by the instance of the problem. The notation should not be confused with , which is the position of facility at stage on the real line .

### 3.2 Rounding the Fractional Solution

Our algorithm, described in Algorithm 1, is a simple rounding scheme of the optimal fractional solution of the Integer Linear Program of Figure 1. This simple scheme produces an integral solution that has the exact same cost with an optimal fractional solution.

###### Theorem 3.1

Let denote the solution produced by Algorithm 1. Then

 Cost(x)=T∑t=1[∑i∈C∑j∈Vd(Loc(i,t),j)xtij+∑k∈FStk]

where denote the values of these variables in the optimal fractional solution of the Integer Linear Program (1).

Theorem 3.1 is the main result of this section and it implies the optimality of our algorithm. We remind that by Lemma 3.1, there is an optimal solution that locates facilities only in positions . This solution corresponds to an integral solution of our Integer Linear Program, meaning that is greater than or equal to the cost of the optimal fractional solution, which by Lemma 3.1 equals . We dedicate the rest of the section to prove Theorem 3.1. The proof is conducted in two steps and each step is exhibited in sections 3.3 and 3.4 respectively.

In section 3.3, we present a very simple rounding scheme in the case, where the values of the variables of the optimal fractional solution satisfy the following assumption.

###### Assumption 1

Let and be either or , for some positive integer .

Although Assumption 1 is very restrictive and its not generally satisfied, it is the key step for proving the optimality guarantee of the rounding scheme presented in Algorithm 1. Then, in section 3.4 we use the rounding scheme of section 3.3 to prove Theorem 3.1. In the upcoming sections, will denote the values of these variables in the optimal fractional solution of the ILP (1).

### 3.3 Rounding Semi-Integral solutions

Throughout this section, we suppose that Assumption 1 is satisfied; and are either or , for some positive integer . If the optimal fractional solution meets these requirements, then the integral solution presented in Lemma 3.2 has the same overall cost. The goal of the section is to prove Lemma 3.2.

###### Definition 3

denotes the set of nodes of with a positive amount of facility () at stage ,

 j∈V+t if and only if ctj>0

We remind that since or , . We also consider the nodes in to be ordered from left to right.

###### Lemma 3.2

Let be the integral solution that at each stage places the -th facility at the node of i.e. . Then, has the same cost as the optimal fractional solution.

The term m-th facility refers to the ordering of the facilities on the real line according to their initial positions . The proof of Lemma 3.2 is quite technically complicated, however it is based on two intuitive observations about the optimal fractional solution.

###### Observation 1

The set of nodes at each agent connects at stage are consecutive nodes of . More precisely, there exists a set such that

 ∑j∈Vd(Loc(i,t),j)xtij=1Nℓ+N−1∑h=ℓd(Loc(i,t),Yth)

#### Proof:

Let an agent that at some stage has and for some . Assume that and to simplify notation consider . Now, increase by and decrease by , where . Then, the cost of the solution is decreased by , thus contradicting the optimality of the solution. The same argument holds if . The proof follows since .

###### Observation 2

Under Assumption 1, the -th facility places amount of facility from the to the node of i.e. to nodes .

Observation 2 serves in understanding the structure of the optimal fractional solution under Assumption 1. However, it will be not used in this form in the rest of the section. We use Lemma 3.3 instead, which is roughly a different wording of Observation 2 and its proof can be found in subsection A.1 of the Appendix.

###### Lemma 3.3

Let the fractional moving cost of facility at stage . Then

 T∑t=1∑k∈FStk=1NT∑t=1K⋅N∑j=1d(Yt−1j,Ytj)

Observations 1, and Lemma 3.3 (Observation 2) are the key points in proving Lemma 3.2.

###### Definition 4

Let the integral solution that places at stage the -th facility at the node of i.e. .

Notice that the integral solution referred in Lemma 3.2 corresponds to . The proof of Lemma 3.2 follows directly by Lemma 3.4 and Lemma 3.5 that conclude this section.

###### Lemma 3.4

Let be the moving cost of facility at stage in the optimal fractional solution and MovingCost the total moving cost of the facilities in the integral solution . Then,

 1NN∑p=1MovingCost(Solp)=T∑t=1∑k∈FStk

#### Proof:

By the definition of the solutions we have that:

 1NN∑p=1MovingCost(Solp) = 1NN∑p=1T∑t=1K∑m=1d(Yt−1(m−1)N+p,Yt(m−1)N+p) = 1NT∑t=1K∑m=1N∑p=1d(Yt−1(m−1)N+p,Yt(m−1)N+p) = 1NT∑t=1K⋅N∑j=1d(Yt−1j,Ytj) = T∑t=1∑k∈FStk

The last equality comes from Lemma 3.3.

Lemma 3.4 states that if we pick uniformly at random one of the integral solutions , then the expected moving cost that we will pay is equal to the moving cost paid by the optimal fractional solution. Interestingly, the same holds for the expected connection cost. This is formally stated in Lemma 3.5 and it is where Observation 1 comes into play.

###### Lemma 3.5

Let denote the connection cost of agent at stage in . Then,

 1NN∑p=1ConCostti(Solp)=∑j∈Vd(Loc(i,t),j)xtij

As already mentioned, the proof of Lemma 3.5 crucially makes use of Observation 1 and is presented in the subsection A.1 of the Appendix. Combining Lemma 3.4 and 3.5 we get that if we pick an integral solution uniformly at random, the average total cost that we pay is , where is the optimal fractional cost. More precisely,

 1NN∑p=1Cost(Solp) = 1NN∑p=1[MovingCost(Solp)+T∑t=1∑i∈CConCostti(Solp)] = T∑t=1[K∑k=1Stk+∑i∈C∑j∈Vd(Loc(i,t),j)xtij] = Z∗LP

Since , we have that and this proves Lemma 3.2.

### 3.4 Rounding the General Case

In this section, we use Lemma 3.2 to prove Theorem 3.1. As already discussed, Assumption 1 is not satisfied in general by the fractional solution of the linear program (1). Each will be either or , for positive some integers . However, each positive will have the form , where . This is due to the constraint .

Consider the path constructed from path as follows: Each node is split into copies with zero distance between them. Consider also the LP (1), when the underlying path is and at each stage , each agent is located to a node of that is a copy of ’s original location, , where . Although these are two different LP’s, they are closely related since a solution for the one can be converted to a solution for the other with the exact same cost. This is due to the fact that for all , , where and .

The reason that we defined and the second LP is the following: Given an optimal fractional solution of the LP defined for , we will construct a fractional solution for the LP defined for with the exact same cost, which additionally satisfies Assumption 1. Then, using Lemma 3.2 we can obtain an integral solution for with the same cost. This integral solution for can be easily converted to an integral solution for . We finally show that these steps are done all at once by the rounding scheme of Algorithm 1 and this concludes the proof of Theorem 3.1.

Given the fractional positions of the optimal solution of the LP formulated for , we construct the fractional positions of the facilities in as follows: If , then facility puts a amount of facility in nodes of the set that have a amount of facility. The latter is possible since there are exactly copies of each and (that is the reason we required copies of each node). The values of the rest of the variables are defined in the proof of Lemma 3.7 that is presented in the end of the section. The key point is that the produced solution will satisfy the following properties (see Lemma 3.7):

• its cost equals

• or , for each

• or for each

• , for each

Clearly, this solution satisfies Assumption 1 and thus Lemma 3.2 can be applied. This implies that the integral solution for that places the -th facility to the node of () has cost . So the integral solution for that places the -th facility to the node , such that , has again cost .

A naive way to determine the nodes is to calculate , construct and its fractional solution, find the nodes and determine the nodes of . Obviously, this rounding scheme requires exponential time. Fortunately, Lemma 3.6 provides a linear time rounding scheme to determine the node given the optimal fractional solution of . This concludes the proof of Theorem 3.1.

###### Lemma 3.6

The node of is a copy of the node if and only if

 jtm−1∑ℓ=1ctℓ≤m−1

.

#### Proof:

Let node of be a copy of the node . Then

 jtm−1∑ℓ=1ctℓ=jtm−1∑ℓ=1∑ℓ′∈Copies(ℓ)c′ tℓ′≤(m−1)N1N=m−1
 jtm∑ℓ=1ctℓ=jtm∑ℓ=1∑ℓ′∈Copies(ℓ)c′ tℓ′=((m−1)N+1)1N>m−1

The above equations hold because of the property and that is either or .

Now, let and assume that -th node of is a copy of . If , then and if , then . As a result, .

###### Remark 1

We remark that the nodes can be determined with an even simpler way than that presented in Algorithm 1. That is is the most left node such that . However, this rounding strategy requires some additional analysis.

###### Lemma 3.7

Let the optimal fractional solution for the LP  with underlying path . Then, there exists a solution of the LP  with underlying path such that

1. Its cost is .

2. or , for each

3. or , for each

4. , for each

#### Proof:

First, we set values to the variables . Initially, all . We know that if , then it equals , for some positive integer . For each such , we find with . Then, we set for . Since there are copies of each node and , we can always find sufficient copies of with . When this step is terminated, we are sure that conditions are satisfied.

We continue with the variables . Initially, all . Then, each positive has the form . Let to simplify notation. We now find copies of of and of so that

• for all

We then set . Again, since and we can always find pairs of copies of and that satisfy the above requirements. We can now prove that the movement cost of each facility is the same in both solutions.

 ∑j∈V∑ℓ∈Vd(j,ℓ)Stkjℓ = ∑j∈V∑ℓ∈Vd(j,ℓ)Btkjℓ/N = ∑j∈V∑ℓ∈V∑h∈Copies(j)∑h′∈Copies(ℓ)S′tkhh′d(h,h′) = ∑j′∈V′∑ℓ′∈V′S′tkj′ℓ′d(j′,ℓ′)

The second equality follows from the fact that are copies of respectively and thus .

Finally, set values to the variables for each . Again, each positive equals , for some positive integer. We take copies of , and set . The connection cost of each agent remains the same since

 ∑j∈Vd(Loc(i,t),j)xtij = ∑j∈Vd(Loc(i,t),j)Btij/N = ∑j∈Vd(Loc(i,t),j)∑j′∈Copies(j)x′tij′ = ∑j∈V∑j′∈Copies(j)d(Loc′(i,t),j′)x′tij′ = ∑h∈V′d(Loc′(i,t),h)x′tih

The third equality holds since .

## 4 A Constant-Competitive Algorithm for the Online 2-Facility Reallocation Problem

In this section, we present an algorithm for the online 2-facility reallocation problem and we discuss the core ideas that prove its performance guarantee. The online algorithm, denoted as Algorithm 2, consists of two major steps.

In Step , facilities are initially moved towards the positions of the agents. We remark that in Step , the final positions of the facilities at stage are not yet determined. The purpose of this step is to bring at least one facility close to the agents. This initial moving consists of three cases (see Figure 2), depending only on the relative positions of the facilities at stage and the agents at stage .

In Step , our algorithm determines the final positions of the facilities . Notice that after Step , at least one of the facilities is inside the interval , meaning that at least one of the facilities is close to the agents. As a result, our algorithm may need to decide between moving the second facility close to the agents or just letting the agents connect to the facility that is already close to them. Obviously, the first choice may lead to small connection cost, but large moving cost, while the second has the exact opposite effect. Roughly speaking, Algorithm 2 does the following: If the connection cost of the agents, when placing just one facility optimally, is not much greater than the cost for moving the second facility inside , then Algorithm 2 puts the first facility to the position that minimizes the connection cost, if one facility is used. Otherwise, it puts the facilities to the positions that minimize the connection cost, if two facilities are used. The above cases are depicted in Figure 3. We formalize how this choice is performed, introducing some additional notation.

###### Definition 5

• denotes the positions of the agents at stage ordered from left to right.

• If is a set of positions with , then denotes the median interval of the set, which is the interval . If , then is a single point.

• denotes the optimal connection cost for the set when all agents of connect to just one facility. That is We also define .

• (resp. ) denotes the positions of the agents that connect to facility (resp. ) at stage in the optimal solution . (resp. ) denotes the positions of the agents that connect to facility (resp. ) at stage in the solution produced by Algorithm 2.