This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

The Power of Recourse: Better Algorithms for Facility Location in Online and Dynamic Models

Xiangyu Guo Department of Computer Science and Engineering, University at Buffalo, xiangyug@buffalo.edu    Janardhan Kulkarni The Algorithms Group, Microsoft Research, Redmond, jakul@microsoft.com    Shi Li Department of Computer Science and Engineering, University at Buffalo, shil@buffalo.edu    Jiayi Xian Department of Computer Science and Engineering, University at Buffalo, jxian@buffalo.edu
Abstract

In this paper we study the facility location problem in the online with recourse and dynamic algorithm models. In the online with recourse model, clients arrive one by one and our algorithm needs to maintain good solutions at all time steps with only a few changes to the previously made decisions (called recourse). We show that the classic local search technique can lead to a (1+2+ϵ)(1+\sqrt{2}+\epsilon)-competitive online algorithm for facility location with only O(lognϵlog1ϵ)O\left(\frac{\log n}{\epsilon}\log\frac{1}{\epsilon}\right) amortized facility and client recourse.

We then turn to the dynamic algorithm model for the problem, where the main goal is to design fast algorithms that maintain good solutions at all time steps. We show that the result for online facility location, combined with the randomized local search technique of Charikar and Guha [10], leads to an O(1+2+ϵ)O(1+\sqrt{2}+\epsilon) approximation dynamic algorithm with amortized update time of O~(n)\tilde{O}(n) in the incremental setting against adaptive adversaries. Notice that the running time is almost optimal, since in general metric space, it takes Ω(n)\Omega(n) time to specify a new client’s position. The approximation factor of our algorithm also matches the best offline analysis of the classic local search algorithm.

Finally, we study the fully dynamic model for facility location, where clients can both arrive and depart. Let FF denote the set of available facility locations. Our main result is an O(1)O(1)-approximation algorithm in this model with O(|F|)O(|F|) preprocessing time and O(log3D)O(\log^{3}D) amortized update time for the HST metric spaces. Using the seminal results of Bartal [4] and Fakcharoenphol, Rao and Talwar [17], which show that any arbitrary NN-point metric space can be embedded into a distribution over HSTs such that the expected distortion is at most O(logN)O(\log N), we obtain a O(log|F|)O(\log|F|) approximation with preprocessing time of O(|F|2log|F|)O(|F|^{2}\log|F|) and O(log3D)O(\log^{3}D) amortized update time. The approximation guarantee holds in expectation for every time step of the algorithm, and the result holds in the oblivious adversary model.

1 Introduction

In the (uncapacitated) facility location problem, we are given a metric space (FC,d)(F\cup C,d), where FF is the set of facility locations, CC is the set of clients, and d:(FC)×(FC)0d:(F\cup C)\times(F\cup C)\rightarrow{\mathbb{R}}_{\geq 0} is a distance function, which is non-negative, symmetric and satisfies triangle inequalities. For each location iFi\in F, there is a facility opening cost fi0f_{i}\geq 0. The goal is open a subset SFS\subseteq F of facilities so as to minimize cost of opening the facilities and the connection cost. The cost of connecting a client jj to an open facility ii is equal to d(j,i)d(j,i). Hence, the objective function can be expressed concisely as minSF(f(S)+jCd(j,S))\min_{S\subseteq F}\left(f(S)+\sum_{j\in C}d(j,S)\right), where for a set SFS\subseteq F, f(S):=iSfif(S):=\sum_{i\in S}f_{i} is the total facility cost of SS and d(j,S):=miniSd(j,i)d(j,S):=\min_{i\in S}d(j,i) denotes the distance of jj to the nearest location in SS. The facility location problem arises in countless applications: in the placement of servers in data centers, network design, wireless networking, data clustering, location analysis for placement of fire stations, medical centers, and so on. Hence, the problem has been studied extensively in many different communities: approximation algorithms, operations research, and computational geometry. In the approximation algorithms literature in particular, the problem occupies a prominent position as the development of every major technique in the field is tied to its application on the facility location problem. See the text book by Williamson and Shmoys [40] for more details. The problem is hard to approximate to a factor better than 1.463 [28]. The current best-known polynomial-time algorithm is given by the third author, and achieves 1.488-approximation [34].

In many real-world applications the set of clients arrive online, the metric space can change over time, and there can be memory constraints: This has motivated the problem to be studied in various models: online [35, 21, 2, 20], dynamic [11, 27, 12, 39, 18, 15, 1], incremental [19, 9, 23], streaming [32, 22, 33, 13, 9], game theoretic [38, 24, 25], to name a few. This paper is concerned with online and dynamic models. Thus to keep the flow of presentation linear, we restrict ourselves to the results in these two models here.

Motivated by its applications in network design and data clustering, Meyerson [35] initiated the study of facility location problem in the online setting. Here, clients arrive online one-by-one, the algorithm has to assign the newly arriving client to an already opened facility or needs to open a new facility to serve the request. The decisions made by the algorithm are irrevocable, in the sense that a facility that is opened cannot be closed and the clients cannot be reassigned. In the online setting, Meyerson [35] designed a very elegant randomized algorithm that achieves an O(logn)O(\log n) competitive ratio, and also showed that no online algorithm can obtain O(1)O(1) competitive ratio. This result was later extended by Fotakis [21] to obtain an asymptotically optimal O(logn/loglogn)O(\log n/\log\log n)-competitive algorithm. Both the algorithms and analysis techniques in [21, 35] were influential, and found many applications in other models such as streaming [23]. The lowerbound in Fotakis [21] holds even in very special metric spaces such as HSTs or the real line. Since then, several online algorithms have been designed achieving the same competitive ratio with more desirable properties such as deterministic [2], primal-dual [20], or having a small memory footprint [22]. We refer to a beautifully written survey by Fotakis [23] for more details.

The main reason to assume that decisions made by an algorithm are irrevocable is because the cost of changing the solution is expensive in some applications. However, if one examines these above applications closely, say for example connecting clients to servers in data centers, it is more natural to assume that decisions need not be irrevocable but the algorithm should not change the solution too much. This is even more true in modern data centers where topologies can be reconfigured; see [26] for more details. A standard way of quantifying the restriction that an online algorithm does not make too many changes is using the notion of recourse. The recourse per step of an online algorithm is the number of changes it makes to the solution. Recourse captures the minimal amount of changes an online algorithm has to make to maintain a desired competitive ratio due to the information theoretic limits. For the facility location problem, depending on the application, the recourse can correspond to: 1) the number of changes made to the opened facilities (called facility recourse) 2) the number of reconnections made to the clients (called client recourse). Notice that we can assume for every facility we open/close, we have to connect/disconnect at least one client. Thus the client recourse is at least the facility recourse. In the clustering applications arising in massive data sets, the opened facilities represent cluster centers, which represent summaries of data. Here one is interested in making sure that summaries do not change too frequently as more documents are added online. Therefore, facility recourse is a good approximation to the actual cost of changing the solution [9, 19]. On the other hand, in network design problems, client recourse is the true indicator of the cost to implement the changes in the solution. As a concrete example, consider the problem of connecting clients to servers in datacenters, which was one of the main motivation for Meyerson [35] to initiate the study of online facility location problem. Here, it is important that one does not reconnect clients to servers too many times, as such changes can incur significant costs both in terms of disruption of service and the labor cost. Consider another scenario where a retailing company tries to maintain stores to serve the dynamically changing set of clients. As the clients are changing so frequently, it would be infeasible to build/shutdown even one store for every new client. In this application, small client recourse per step is desirable, as that will automatically forbid frequent changes of store locations.

In this light, a natural question that arises is:

Is it possible to maintain a constant approximation for the facility location problem if we require that the facility and client recourse is small?

Our first main result shows that indeed this is possible. In the following theorems, we use nn to denote the total number of facility locations and all clients that ever arrived, and DD to denote the diameter of the metric dd (assuming all distances are integers).

Theorem 1.

There is a deterministic online algorithm for the facility location problem that achieves a competitive ratio of (1+2+ϵ)(1+\sqrt{2}+\epsilon) with O(lognϵlog1ϵ)O\left(\frac{\log n}{\epsilon}\log\frac{1}{\epsilon}\right) amortized facility and client recourse against an adaptive adversary.

Our algorithm to show the above theorem differs from the previous approaches used in the context of online variants of facility location problem, and is based on local search. The local search algorithm is one of the most widely used algorithms for the facility location problem in practice and is known to achieve an approximation factor of (1+2)(1+\sqrt{2}) in the offline setting. See the influential paper by Arya et al [3] and a survey by Munagala [36]. Thus our result matches the best known approximation ratio for offline facility location using local search. Further, our result shows that the local search algorithm augmented with some small modifications is inherently stable as it does not make too many changes to the solutions even if clients are added in an online fashion. This gives further justification for its popularity among practitioners.

Prior to Theorem 1, the known results [19, 14, 22] needed one or more of these assumptions: 1) the facility costs are the same 2) we are interested in knowing only the cost of solution 3) we are interested only in bounding the facility recourse. In particular, there was no known algorithm that bounds the client recourse, which is an important consideration in many applications mentioned above. Moreover, our algorithm also achieves a better approximation factor; previously best known algorithm for the facility location problem achieved a competitive ratio of 48 [23].

Our result in the recourse setting for the facility location problem should be contrasted with the similar results shown recently for online Steiner tree [30], set cover [29], scheduling [31], and matchings and flows [6, 31]. Moreover, these results also raise an intriguing questions: is polylog amount of recourse enough to beat information theoretic lowerbounds in the online algorithms? Is recourse as or more powerful than randomization?

While having a small client recourse is enough in data center applications, it is not enough in some others. Take wireless networks as a concrete example. Here, the set of clients (mobile devices) keeps changing over time, and it is necessary to update the assignment of clients to facilities as quickly as possible so to minimize the service disruption. These applications motivated Cygan et al [12], Goranci et al [27] and Cohen-Addad et al [11] to study the facility location problem in the framework of dynamic algorithms. The dynamic model of [12] and [11] is different from what we study here, so we discuss it at end of this section.

The dynamic facility location problem is similar to the one in online setting except that at each time step either a new client arrives or an existing client departs. The goal is to always maintain a solution that is a constant factor approximation to the optimal solution, while minimizing the total time spent in updating the solution. We emphasize that we require our dynamic algorithms to maintain an actual assignment of clients to facilities, not just the set of open facilities and an estimate of connection cost. This is important for applications mentioned above. This setting was considered in [27], who showed that for metric spaces with doubling dimension κ\kappa, there is a deterministic fully dynamic algorithm with O~(2κ2)\tilde{O}(2^{\kappa^{2}}) update time, which maintains a constant approximation. However, for more general metric spaces no results were known in the dynamic setting, and we give the first results. First we consider the incremental setting, where clients only arrive and never depart.

Theorem 2.

In the incremental setting against an adaptive adversary, there is a randomized dynamic algorithm for the facility location problem that, with probability at least 11/n21-1/n^{2}, maintains an approximation factor of (1+2+ϵ)(1+\sqrt{2}+\epsilon) and has total update time of O(n2ϵ2log3nlog1ϵ)O(\frac{n^{2}}{\epsilon^{2}}\log^{3}n\log\frac{1}{\epsilon}).

Note that it takes Θ(n|F|)\Theta(n|F|) space to specify the input in our model (see Section 2.2). Hence the running time of our algorithms is almost optimal up to polylog factors when |F|=Ω(n)|F|=\Omega(n). The proof of above theorem uses randomized local search and builds on our result in the recourse setting. We use randomization to convert the recourse bound into an update time bound. Further, our analysis of above theorem also implies one can obtain O(n|F|ϵ2log3nlog1ϵ)O(\frac{n|F|}{\epsilon^{2}}\log^{3}n\log\frac{1}{\epsilon}) running time by losing O(1)O(1) factors in the approximation ratio; see the remark at the end of Section 5.

Next we study the fully dynamic setting. Here, we first consider an important class of metric spaces called hierarchically well separated tree (HST) metrics [4]; see Definition 5 for the formal definition, and Section 2.2 for more details about how the input sequence is given. For HST metric spaces, we show the following result.

Theorem 3.

In the fully dynamic setting against adaptive adversaries, there is a deterministic algorithm for the facility location problem that achieves an O(1)O(1) approximation factor with O(|F|)O(|F|) preprocessing time and O(nlog3D)O(n\log^{3}D) total update time for the HST metric spaces.

A seminal result by Bartal [4], which was later tightened by Fakcharoenphol, Rao and Talwar [17], shows that any arbitrary NN-point metric space can be embedded into a distribution over HSTs such that the expected distortion is at most O(logN)O(\log N), which is also tight. Moreover, such a probabilistic embedding can also be computed in O(N2logN)O(N^{2}\log N) time; see recent results by Blelloch, Gu and Sun for details [7]. These results immediately imply the following theorem, provided the input is specified as in Section 2.2.

Theorem 4.

In the fully dynamic setting against oblivious adversary, there is a randomized algorithm for the facility location problem that maintains an approximation factor of O(log|F|)O(\log|F|) with preprocessing time of O(|F|2log|F|)O(|F|^{2}\log|F|) and O(nlog3D)O(n\log^{3}D) total update time. The approximation guarantee holds only in expectation for every time step of the algorithm.

Observe that unlike the incremental setting, the above theorem holds only in the oblivious adversary model, as probabilistic embedding techniques preserve distances only in expectation as can be seen by taking a cycle on nn points. Our result also shows that probabilistic tree embeddings using HSTs can be a very useful technique in the design of dynamic algorithms, similar to its role in online algorithms [4, 5, 37, 8].

Our algorithms in Theorems 3 and 4 in the fully dynamic setting also have the nice property that amortized client and facility recourse is O(log3D)O(\log^{3}D) (in fact, we can achieve a slight better bound of O(log2D)O(\log^{2}D) as can be seen from the analysis). This holds as our dynamic algorithms maintain the entire assignment of clients to facilities explicitly in memory at every time step. Thus, the amortized client reconnections is at most the amortized update time. This is useful when one considers an online setting where clients arrive and depart, and is interested in small client recourse. A fully dynamic online model of facility location problem, where clients arrive and depart was recently studied by Cygan et al [12] and Cohen-Addad et al [11], but with different assumption on recourse. In this model, when a client arrives, the algorithm has to assign it to an open facility immediately; While upon departure of a client, if a facility was opened at the same location, then the clients that were assigned to that location should be reassigned immediately and irrevocably. Cygan et al [12] studied the case when recourse is not allowed: they showed that a delicate extension of Meyerson’s [35] algorithm obtains asymptotically tight competitive ratio of O(logn/loglogn)O(\log n/\log\log n). Cohen-Addad et al [11] later showed that this can be improved to O(1)O(1) if recourse is allowed. However, both results holds only for the uniform facility costs and Cygan et al[12] even showed an unbounded lower bound for the non-uniform facility cost case in their model. Moreover, in their model reconnections of clients are assumed to be “automatic” and do not count towards the client recourse; it is not clear how many client reconnections their algorithm will make.

1.1 Our Techniques

Our main algorithmic technique for proving Theorems 1 and 2 is local search, which is one of the powerful algorithm design paradigms. Indeed, for both results, the competitive (approximation) ratio we achieve is 1+2+ϵ1+\sqrt{2}+\epsilon, which matches the best approximation ratio for offline facility location obtained using local search [3]. Both of our results are based on the following key lemma. Suppose we maintain local optimum solutions at every time step in our algorithm. When a new client jtj_{t} comes at time tt, we add it to our solution using a simple operation, and let Δt\Delta_{t} be the increase of our cost due to the arrival of jtj_{t}. The key lemma states that the sum of Δt\Delta_{t} values in the first TT^{\prime} time steps can be bounded in terms the optimum cost at time TT^{\prime}. With a simple modification to the local search algorithm, in which we require each local operation decreases enough cost for every client it reconnects, one can bound the total client recourse.

The straightforward way to implement the local search algorithm takes time Ω(n3)\Omega(n^{3}). To derive a better running time, we leverage the randomized local search idea of Charikar and Guha [10]. At every iteration, we randomly choose a facility ii or a closing operation, and then perform the best operation that opens or swaps in ii, or closes a facility if that is what we choose. By restricting the facility ii and with the help of the heap data structure, an iteration of the algorithm can be implemented in time O(|C|log|F|)O(|C|\log|F|). As in [10] we can also show that each iteration can make a reasonable progress in expectation, leading to a bound of O~(|F|)\tilde{O}(|F|) on the number of iterations for the success of the algorithm with high probability. We remark that the algorithm in [10] used a different local search framework. Therefore, our result shows that the classic algorithm of [3] can also be made fast.

However, directly replacing the randomized local search procedure with a deterministic one does not work: The solution at the end of each time might not be a local optimum as we did not enumerate all possible local operations. Thus the key lemma does not hold any more. Nevertheless we show that applying a few local operations around jtj_{t} upon its arrival can address the issue. With the key lemma, one can bound the number of times we perform the iterative randomized local search procedure, and thus the overall running time.

Our proof for Theorem 3 is based on a generalization of the greedy algorithm for facility location on HST metrics, which was developed in [16] in the context of differential privacy but only for the case of uniform facility cost. The intuition of the algorithm is as follows: If for some vertex vv of the HST TT, the number of clients in the tree TvT_{v} (the sub-tree of TT rooted at vv) times the length of parent edge of vv is big compared to the cost of the cheapest facility in TvT_{v}, then we should open that facility. Otherwise, we should not open it and let the clients in TvT_{v} be connected to outside TvT_{v} through the parent edge. This intuition can be made formal: We mark vv in the former case; then simply opening the cheapest facility in TvT_{v} for all lowest marked vertices vv leads to a constant approximation for facility location.

The above offline algorithm leads to a dynamic data structure that maintains O(1)O(1)-approximate solutions, supports insertion and deletion of clients, and reports the connecting facility of a client in O(logD)O(\log D) time. This is the case since each time a client arrives or departs, only its ancestors will be affected. However, in a dynamic algorithm setting, we need to maintain the assignment vector in memory, so that when the connecting facility of a client changes, it needs to be notified. This requires that the number of reconnections made by our algorithm to be small. To achieve the goal, we impose two constants for each vv when deciding whether vv should be marked and the cheapest facility in TvT_{v} should be open. When a vertex vv changes its marking/opening status, we update the constants in such a way that it becomes hard for the status to be changed back.

2 Preliminaries

Throughout the paper, we use FF to denote the set of potential facilities for all the problems and models; we assume FF is given upfront. CC is the dynamic set of clients we need to connect by our algorithm. This is not necessarily the set of clients that are present: In the algorithms for online facility location with recourse and dynamic facility location in the incremental setting, we fix the connections of some clients as the algorithms proceed. These clients are said to be “frozen” and excluded from CC. We shall always use dd to denote the hosting metric containing FF and all potential clients. For any point jj and subset VV of points in the metric, we define d(j,V)=minvVd(j,v)d(j,V)=\min_{v\in V}d(j,v) to be the minimum distance from jj to a point in VV. We assume all distances are integers, the minimum non-zero distance between two points is 1. We define DD, the diameter or the aspect ratio of a metric space, as the largest distance between two points in it. Let nn be |F||F| plus the total number of clients arrived during the whole process. The algorithms do not need to know the exact value of nn in advance, except that in the dynamic algorithm for facility location in the incremental setting (the problem in Theorem 2), to achieve the 11/n21-1/n^{2} success probability, a sufficiently large Γ=poly(n,logD,1ϵ)\Gamma=\mathrm{poly}(n,\log D,\frac{1}{\epsilon}) needs to be given.111For an algorithm that might fail, we need to have some information about nn to obtain a failure probability that depends on nn.

In all the algorithms, we maintain a set SS of open facilities, and a connection σSC\sigma\in S^{C} of clients in CC to facilities in SS. We do not require that σ\sigma connects clients to their respective nearest open facilities. For any solution (SF,σSC)(S^{\prime}\subseteq F,\sigma^{\prime}\in S^{\prime C}), we use 𝖼𝖼(σ)=jCd(j,σj)\mathsf{cc}(\sigma^{\prime})=\sum_{j\in C}d(j,\sigma_{j}) to denote the connection cost of the solution. For facility location, we use 𝖼𝗈𝗌𝗍(S,σ)=f(S)+𝖼𝖼(σ)\mathsf{cost}(S^{\prime},\sigma^{\prime})=f(S^{\prime})+\mathsf{cc}(\sigma^{\prime}) to denote the total cost of the solution (S,σ)(S^{\prime},\sigma^{\prime}), where f(S):=iSfif(S^{\prime}):=\sum_{i\in S^{\prime}}f_{i}. Notice that σ\sigma and the definitions of 𝖼𝖼\mathsf{cc} and 𝖼𝗈𝗌𝗍\mathsf{cost} functions depend on the dynamic set CC.

Throughout the paper, we distinguish between a “moment”, a “time” and a “step”. A moment refers to a specific time point during the execution of our algorithm. A time corresponds to an arrival or a departure event: At each time, exactly one client arrives or departs, and time tt refers to the period from the moment the tt-th event happens until the moment the (t+1)(t+1)-th event happens (or the end of the algorithm). One step refers to one statement in our pseudo-codes indexed by a number.

2.1 Hierarchically Well Separated Trees

Definition 5.

A hierarchically-well-separated tree (or HST for short) is an edge-weighted rooted tree with the following properties:

  • all the root-to-leaf paths have the same number of edges,

  • if we define the level of vertex vv, 𝗅𝖾𝗏𝖾𝗅(v){\mathsf{level}}(v), to be the number of edges in a path from vv to any of its leaf descendant, then for an non-root vertex vv, the weight of the edge between vv and its parent is exactly 2𝗅𝖾𝗏𝖾𝗅(v)2^{{\mathsf{level}}(v)}.

Given a HST TT with the set of leaves being XX, we use dTd_{T} to denote the shortest path metric of the tree TT (with respect to the edge weights) restricted to XX.

The classic results by Bartal [4] and Fakcharoenphol, Rao and Talwar [17] state that we can embed any NN-point metric (X,d)(X,d) (with minimum non-zero distance being 11) to a distribution π\pi of expanding222A metric (X,dT)(X,d_{T}) is expanding w.r.t (X,d)(X,d) if for every u,vXu,v\in X, we have dT(u,v)d(u,v)d_{T}(u,v)\geq d(u,v). HST metrics (X,dT)(X,d_{T}) with distortion O(logN)O(\log N): For every u,vXu,v\in X, we have dT(u,v)d(u,v)d_{T}(u,v)\geq d(u,v) and 𝔼u,v[dT(u,v)]O(logN)d(u,v)\operatorname*{\mathbb{E}}_{u,v}[d_{T}(u,v)]\leq O(\log N)d(u,v). Moreover, there is an efficient randomized algorithm [7] that outputs a sample of the tree TT from π\pi. Thus applying standard arguments, Theorem 3 implies Theorem 4.

2.2 Specifying Input Sequence

In this section we specify how the input sequence is given. For the online and dynamic facility location problem, we assume the facility locations FF, their costs (fi)iF(f_{i})_{i\in F}, and the metric dd restricted to FF are given upfront, and they take O(|F|2)O(|F|^{2}) space. Whenever a client jCj\in C arrives, it specifies its distance to every facility iFi\in F (notice that the connection cost of an assignment σSC\sigma\in S^{C} does not depend on distances between two clients and thus they do not need to be given). Thus the whole input contains O(n|F|)O(n|F|) words.

For Theorems 3 and 4, as we do not try to optimize the constants, we do not need that a client specifies its distance to every facility. By losing a multiplicative factor of 22 and an additive factor of 11 in the approximation ratio, we can assume that every client jj is collocated with its nearest facility in FF (See Appendix C). Thus, we only require that when a client jj comes, it reports the position of its nearest facility. For Theorem 3, the HST TT over FF is given at the beginning using O(|F|)O(|F|) words. For Theorem 4, the metric dd over FF is given at the beginning using O(|F|2)O(|F|^{2}) words. Then, we use an efficient algorithm [7] to sample a HST TT.

2.3 Local Search for facility location

The local-search technique has been used to obtain the classic (1+2)(1+\sqrt{2})-approximation offline algorithm for facility location [3]. We now give an overview of the algorithm, which will be the baseline of our online and dynamic algorithms for facility location. One can obtain a (tight) 33-approximation for facility location without scaling facility costs. Scaling the facility costs by a factor of λ:=2\lambda:=\sqrt{2} when deciding whether an operation can decrease the cost, we can achieve a better approximation ratio of α𝖥𝖫:=1+2\alpha_{\mathsf{FL}}:=1+\sqrt{2}. Throughout, we fix the constants λ=2\lambda=\sqrt{2} and α𝖥𝖫=1+2\alpha_{\mathsf{FL}}=1+\sqrt{2}. For a solution (S,σ)(S^{\prime},\sigma^{\prime}) to a facility location instance, we use 𝖼𝗈𝗌𝗍λ(S,σ)=λf(S)+𝖼𝖼(σ)\mathsf{cost}_{\lambda}(S^{\prime},\sigma^{\prime})=\lambda f(S^{\prime})+\mathsf{cc}(\sigma^{\prime}) to denote the cost of the solution (S,σ)(S^{\prime},\sigma^{\prime}) with facility costs scaled by λ=2\lambda=\sqrt{2}. We call 𝖼𝗈𝗌𝗍λ(S,σ)\mathsf{cost}_{\lambda}(S^{\prime},\sigma^{\prime}) the scaled cost of (S,σ)(S^{\prime},\sigma^{\prime}).

Given the current solution (S,σ)(S,\sigma) for a facility location instance defined by F,C,dF,C,d and (fi)iF(f_{i})_{i\in F}, we can apply a local operation that changes the solution (S,σ)(S,\sigma). A valid local operation is one of the following.

  • An 𝗈𝗉𝖾𝗇\mathsf{open} operation, in which we open some facility iFi\in F and reconnect a subset CCC^{\prime}\subseteq C of clients to ii. We allow ii to be already in SS, in which case we simply reconnect CC^{\prime} to ii. This needs to be allowed since our σ\sigma does not connect clients to their nearest open facilities.

  • A 𝖼𝗅𝗈𝗌𝖾\mathsf{close} operation, we close some facility iSi^{\prime}\in S and reconnect the clients in σ1(i)\sigma^{-1}(i^{\prime}) to facilities in S{i}S\setminus\{i^{\prime}\}.

  • In a 𝗌𝗐𝖺𝗉\mathsf{swap} operation, we open some facility iSi\notin S and close some facility iSi^{\prime}\in S, reconnect the clients in σ1(i)\sigma^{-1}(i^{\prime}) to facilities in S{i}{i}S\setminus\{i^{\prime}\}\cup\{i\}, and possibly some other clients to ii. We say ii is swapped in and ii^{\prime} is swapped out by the operation.

Thus, in any valid operation, we can open and/or close at most one facility. A client can be reconnected if it is currently connected to the facility that will be closed, or it will be connected to the new open facility. After we apply a local operation, SS and σ\sigma will be updated accordingly so that (S,σ)(S,\sigma) is always the current solution.

For the online algorithm with recourse model, since we need to bound the number of reconnections, we apply a local operation only if the scaled cost it decreases is large compared to the number of reconnections it makes. This motivates the following definition:

Definition 6 (Efficient operations for facility location).

Given a ϕ0\phi\geq 0, we say a local operation on a solution (S,σ)(S,\sigma) for a facility location instance is ϕ\phi-efficient, if it decreases 𝖼𝗈𝗌𝗍λ(S,σ)\mathsf{cost}_{\lambda}(S,\sigma) by more than ϕ\phi times the number of clients it reconnects.

The following two theorems can be derived from the analysis for the local search algorithms for facility location. We include their proofs in Appendix A for completeness.

Theorem 7.

Consider a facility location instance with cost of the optimum solution being 𝗈𝗉𝗍\mathsf{opt} (using the original cost function). Let (S,σ)(S,\sigma) be the current solution in our algorithm and ϕ0\phi\geq 0 be a real number. If there are no ϕ\phi-efficient local operations on (S,σ)(S,\sigma), then we have

𝖼𝗈𝗌𝗍(S,σ)α𝖥𝖫(𝗈𝗉𝗍+|C|ϕ).\displaystyle\mathsf{cost}(S,\sigma)\leq\alpha_{\mathsf{FL}}\big{(}\mathsf{opt}+|C|\phi\big{)}.

In particular, if we apply the theorem with ϕ=0\phi=0, then we obtain that (S,σ)(S,\sigma) is a (α𝖥𝖫=1+2)(\alpha_{\mathsf{FL}}=1+\sqrt{2})-approximation for the instance.

The following theorem will be used to analyze our randomized local search procedure.

Theorem 8.

Let (S,σ)(S,\sigma) be a solution to a facility location instance and 𝗈𝗉𝗍\mathsf{opt} be the optimum cost. Then there are two sets 𝒫C{\mathcal{P}}_{\mathrm{C}} and 𝒫F{\mathcal{P}}_{\mathrm{F}} of valid local operations on (S,σ)(S,\sigma), where each operation op\mathrm{op} decreases the scaled cost 𝖼𝗈𝗌𝗍λ(S,σ)\mathsf{cost}_{\lambda}(S,\sigma) by op>0\nabla_{\mathrm{op}}>0, such that the following holds:

  • op𝒫Cop𝖼𝖼(σ)(λf(S)+𝖼𝖼(σ))\sum_{\mathrm{op}\in{\mathcal{P}}_{\mathrm{C}}}\nabla_{\mathrm{op}}\geq\mathsf{cc}(\sigma)-(\lambda f(S^{*})+\mathsf{cc}(\sigma^{*})).

  • op𝒫Fopλf(S)(λf(S)+2𝖼𝖼(σ))\sum_{\mathrm{op}\in{\mathcal{P}}_{\mathrm{F}}}\nabla_{\mathrm{op}}\geq\lambda f(S)-(\lambda f(S^{*})+2\mathsf{cc}(\sigma^{*})).

  • There are at most |F||F| 𝖼𝗅𝗈𝗌𝖾\mathsf{close} operations in 𝒫C𝒫F{\mathcal{P}}_{\mathrm{C}}\biguplus{\mathcal{P}}_{\mathrm{F}}.

  • For every iFi\in F, there is at most 1 operation in each of 𝒫C{\mathcal{P}}_{\mathrm{C}} and 𝒫F{\mathcal{P}}_{\mathrm{F}} that opens or swaps in ii.

2.4 Useful Lemmas

The following lemmas will be used repeatedly in our analysis and thus we prove them separately in Appendix B.

Lemma 9.

Let b0Tb\in{\mathbb{R}}_{\geq 0}^{T} for some integer T1T\geq 1. Let BT=t=1TbtB_{T^{\prime}}=\sum_{t=1}^{T^{\prime}}b_{t} for every T=0,1,,TT^{\prime}=0,1,\cdots,T. Let 0<a1a2aT0<a_{1}\leq a_{2}\leq\cdots\leq a_{T} be a sequence of real numbers and α>0\alpha>0 such that BtαatB_{t}\leq\alpha a_{t} for every t[T]t\in[T]. Then we have

t=1Tbtatα(lnaTa1+1).\displaystyle\sum_{t=1}^{T}\frac{b_{t}}{a_{t}}\leq\alpha\left(\ln\frac{a_{T}}{a_{1}}+1\right).
Lemma 10.

Assume at some moment of an algorithm for facility location, CC is the set of clients, (S,σ)(S,\sigma) is the solution for CC. Let iFi\in F and C~C\tilde{C}\subseteq C be any non-empty set of clients. Also at the moment there are no ϕ\phi-efficient operation that opens ii for some ϕ0\phi\geq 0. Then we have

d(i,S)fi+2j~C~d(i,j~)|C~|+ϕ.\displaystyle d(i,S)\leq\frac{f_{i}+2\sum_{\tilde{j}\in\tilde{C}}d(i,\tilde{j})}{|\tilde{C}|}+\phi.

Organization

The rest of the paper is organized as follows. In Section 3, we prove Theorem 1 by giving our online algorithm for facility location with recourse. Section 4 gives the randomized local search procedure, that will be used in the proof of Theorem 2 in Section 5. Section 6 is dedicated to the proof of Theorem 4, by giving the fully dynamic algorithm for facility location in HST metrics. We give some open problems and future directions in Section 7. Some proofs are deferred to the appendix for a better flow of the paper.

3 (1+2+ϵ)(1+\sqrt{2}+\epsilon)-Competitive Online Algorithm with Recourse

In this section, we prove Theorem 1 by giving the algorithm for online facility location with recourse.

3.1 The Algorithm

For any ϵ>0\epsilon>0, let ϵ=Θ(ϵ)\epsilon^{\prime}=\Theta(\epsilon) be a parameter that is sufficiently small so that the approximation ratio α𝖥𝖫+O(ϵ)=1+2+O(ϵ)\alpha_{\mathsf{FL}}+O(\epsilon^{\prime})=1+\sqrt{2}+O(\epsilon^{\prime}) achieved by our algorithm is at most α𝖥𝖫+ϵ\alpha_{\mathsf{FL}}+\epsilon. Our algorithm for online facility location is easy to describe. Whenever the client jtj_{t} comes at time tt, we use a simple rule to connect jtj_{t}, as defined in the procedure 𝗂𝗇𝗂𝗍𝗂𝖺𝗅𝖼𝗈𝗇𝗇𝖾𝖼𝗍\mathsf{initial\mathchar 45\relax connect} in Algorithm 1: either connecting jtj_{t} to the nearest facility in SS, or opening and connecting jtj_{t} to its nearest facility in FSF\setminus S, whichever incurs the smaller cost. Then we repeatedly perform ϕ\phi-efficient operations (Definition 6), until no such operations can be found, for ϕ=ϵ𝖼𝗈𝗌𝗍(S,σ)α𝖥𝖫|C|\phi=\frac{\epsilon^{\prime}\cdot\mathsf{cost}(S,\sigma)}{\alpha_{\mathsf{FL}}|C|}. 333There are exponential number of possible operations, but we can check if there is a ϕ\phi-efficient one efficiently. 𝖼𝗅𝗈𝗌𝖾\mathsf{close} operations can be handled easily. To check if we can open a facility ii, it suffices to check if jC:d(j,i)+ϕ<d(j,σj)(d(j,σj)d(j,i)ϕ)>λfi1iS\sum_{j\in C:d(j,i)+\phi<d(j,\sigma_{j})}(d(j,\sigma_{j})-d(j,i)-\phi)>\lambda f_{i}\cdot 1_{i\notin S}. 𝗌𝗐𝖺𝗉\mathsf{swap} operations are more complicated but can be handled similarly.

Algorithm 1 𝗂𝗇𝗂𝗍𝗂𝖺𝗅𝖼𝗈𝗇𝗇𝖾𝖼𝗍(j)\mathsf{initial\mathchar 45\relax connect}(j)
1:if miniFS(fi+d(i,j))<d(j,S)\min_{i\in F\setminus S}(f_{i}+d(i,j))<d(j,S) then
2:     let i=argminiFS(fi+d(i,j))i^{*}=\arg\min_{i\in F\setminus S}(f_{i}+d(i,j)), SS{i},σjiS\leftarrow S\cup\{i^{*}\},\sigma_{j}\leftarrow i^{*}
3:else σjargminiSd(j,i)\sigma_{j}\leftarrow\arg\min_{i\in S}d(j,i)

We can show that the algorithm gives an (α𝖥𝖫+ϵ)(\alpha_{\mathsf{FL}}+\epsilon)-approximation with amortized recourse O(logDlogn)O(\log D\log n); recall that DD is the aspect ratio of the metric. To remove the dependence on DD, we divide the algorithm into stages, and freeze the connections of clients that arrived in early stages. The final algorithm is described in Algorithm 3, and Algorithm 2 gives one stage of the algorithm.

Algorithm 2 One Stage of Online Algorithm for Facility Location
1:
  • CC: initial set of clients

  • (S,σ)(S,\sigma): a solution for CC which is O(1)O(1)-approximate

  • Clients j1,j2,j_{1},j_{2},\cdots arrive from time to time

2: Guaranteeing that (S,σ)(S,\sigma) at the end of each time tt is α𝖥𝖫1ϵ\frac{\alpha_{\mathsf{FL}}}{1-\epsilon^{\prime}}-approximate
3:𝗂𝗇𝗂𝗍𝖼𝗈𝗌𝗍(S,σ)\mathsf{init}\leftarrow\mathsf{cost}(S,\sigma)
4:for t1,2,t\leftarrow 1,2,\cdots, terminating if no more clients will arrive do
5:     CC{jt}C\leftarrow C\cup\{j_{t}\}, and call 𝗂𝗇𝗂𝗍𝗂𝖺𝗅𝖼𝗈𝗇𝗇𝖾𝖼𝗍(jt)\mathsf{initial\mathchar 45\relax connect}(j_{t})
6:     while there exists an ϵ𝖼𝗈𝗌𝗍(S,σ)α𝖥𝖫|C|\frac{\epsilon^{\prime}\cdot\mathsf{cost}(S,\sigma)}{\alpha_{\mathsf{FL}}|C|}-efficient local operation do perform the operation      
7:     if 𝖼𝗈𝗌𝗍(S,σ)>𝗂𝗇𝗂𝗍/ϵ\mathsf{cost}(S,\sigma)>\mathsf{init}/\epsilon^{\prime} then terminate the stage      
Algorithm 3 Online Algorithm for Facility Location
1:C,S,σ=()C\leftarrow\emptyset,S\leftarrow\emptyset,\sigma=()
2:repeat
3:     CC,(S,σ)(S,σ)C^{\circ}\leftarrow C,(S^{\circ},\sigma^{\circ})\leftarrow(S,\sigma)
4:     redefine the next time to be time 1 and run one stage as defined in Algorithm 2
5:     permanently open one copy of each facility in SS^{\circ}, and permanently connect clients in CC^{\circ} according to σ\sigma^{\circ} (we call the operation freezing SS^{\circ} and CC^{\circ})
6:     CCCC\leftarrow C\setminus C^{\circ}, restrict the domain of σ\sigma to be the new CC
7:until no clients come

In Algorithm 2, we do as described above, with two modifications. First, we are given an initial set CC of clients and a solution (S,σ)(S,\sigma) for CC which is O(1)O(1)-approximate. Second, the stage will terminate if the cost of our solution increases by a factor of more than 1/ϵ1/\epsilon^{\prime}. The main algorithm (Algorithm 3) is broken into many stages. Since we shall focus on one stage of the algorithm for most part of our analysis, we simply redefine the time so that every stage starts with time 1. The improved recourse comes from the freezing operation: at the end of each stage, we permanently open one copy of each facility in SS^{\circ}, and permanently connect clients in CC^{\circ} to copies of SS^{\circ} according to σ\sigma^{\circ}, where CC^{\circ} and (S,σ)(S^{\circ},\sigma^{\circ}) are the client set and solution at the beginning of the stage. Notice that we assume the original facilities in SS^{\circ} will still participate in the algorithm in the future; that is, they are subject to opening and closing. Thus each facility may be opened multiple times during the algorithm and we take the facility costs of all copies into consideration. This assumption is only for the sake of analysis; the actual algorithm only needs to open one copy and the costs can only be smaller compared to the described algorithm.

From now on, we focus on one stage of the algorithm and assume that the solution given at the beginning of each stage is O(1)O(1)-approximate. In the end we shall account for the loss due to the freezing of clients and facilities. Within a stage, the approximation ratio follows directly from Theorem 7: Focus on the moment after the while loop at time step tt in Algorithm 2. Since there are no ϵ𝖼𝗈𝗌𝗍(S,σ)α𝖥𝖫|C|\frac{\epsilon^{\prime}\cdot\mathsf{cost}(S,\sigma)}{\alpha_{\mathsf{FL}}|C|}-efficient local operations on (S,σ)(S,\sigma), we have by the theorem that 𝖼𝗈𝗌𝗍(S,σ)α𝖥𝖫(𝗈𝗉𝗍+|C|ϵ𝖼𝗈𝗌𝗍(S,σ)α𝖥𝖫|C|)=α𝖥𝖫𝗈𝗉𝗍+ϵ𝖼𝗈𝗌𝗍(S,σ)\mathsf{cost}(S,\sigma)\leq\alpha_{\mathsf{FL}}\left(\mathsf{opt}+|C|\cdot\frac{\epsilon^{\prime}\cdot\mathsf{cost}(S,\sigma)}{\alpha_{\mathsf{FL}}|C|}\right)=\alpha_{\mathsf{FL}}\mathsf{opt}+\epsilon^{\prime}\cdot\mathsf{cost}(S,\sigma), where 𝗈𝗉𝗍\mathsf{opt} is the cost of the optimum solution for CC. Thus, at the end of each time, we have 𝖼𝗈𝗌𝗍(S,σ)α𝖥𝖫1ϵ𝗈𝗉𝗍\mathsf{cost}(S,\sigma)\leq\frac{\alpha_{\mathsf{FL}}}{1-\epsilon^{\prime}}\cdot\mathsf{opt}.

3.2 Bounding Amortized Recourse in One Stage

We then bound the amortized recourse in a stage; we assume that 𝖼𝗈𝗌𝗍(S,σ)>0\mathsf{cost}(S,\sigma)>0 at the beginning of the stage since otherwise there will be no recourse involved in the stage (since we terminate the stage when the cost becomes non-zero). We use TT to denote the last time of the stage. For every time tt, let CtC_{t} be the set CC at the end of time tt, and 𝗈𝗉𝗍t\mathsf{opt}_{t} to be the cost of the optimum solution for the set CtC_{t}. For every t[T]t\in[T], we define Δt\Delta_{t} to be the value of 𝖼𝗈𝗌𝗍(S,σ)\mathsf{cost}(S,\sigma) after Step 5 at time step tt in Algorithm 2, minus that before Step 5. We can think of this as the cost increase due to the arrival of jtj_{t}.

The key lemma we can prove is the following:

Lemma 11.

For every T[T]T^{\prime}\in[T], we have

t=1TΔtO(logT)𝗈𝗉𝗍T.\sum_{t=1}^{T^{\prime}}\Delta_{t}\leq O(\log T^{\prime})\mathsf{opt}_{T^{\prime}}.
Proof.

Consider the optimum solution for CTC_{T^{\prime}} and focus on any star (i,C)(i,C^{\prime}) in the solution; that is, ii is an open facility and CC^{\prime} is the set of clients connected to ii. Assume CC0={jt1,jt2,,jts}C^{\prime}\setminus C_{0}=\{j_{t_{1}},j_{t_{2}},\cdots,j_{t_{s}}\}, where 1t1<t2<<tsT1\leq t_{1}<t_{2}<\cdots<t_{s}\leq T^{\prime}; recall that C0C_{0} is the initial set of clients given at the beginning of the stage. We shall bound s=1sΔts\sum_{s^{\prime}=1}^{s}\Delta_{t_{s^{\prime}}} in terms of the cost of the star (i,CC0)(i,C^{\prime}\setminus C_{0}).

By the rule specified in 𝗂𝗇𝗂𝗍𝗂𝖺𝗅𝖼𝗈𝗇𝗇𝖾𝖼𝗍\mathsf{initial\mathchar 45\relax connect}, we have Δt1fi+d(i,jt1)\Delta_{t_{1}}\leq f_{i}+d(i,j_{t_{1}}). Now focus on any integer k[2,s]k\in[2,s]. Before Step 5 at time tkt_{k}, no (ϕ:=ϵ𝖼𝗈𝗌𝗍(S,σ)α𝖥𝖫|Ctk1|O(ϵ)𝗈𝗉𝗍tk1tk1O(ϵ)𝗈𝗉𝗍Ttk1)\Big{(}\phi:=\frac{\epsilon^{\prime}\cdot\mathsf{cost}(S,\sigma)}{\alpha_{\mathsf{FL}}|C_{t_{k}-1}|}\leq\frac{O(\epsilon^{\prime})\cdot\mathsf{opt}_{t_{k}-1}}{t_{k}-1}\leq\frac{O(\epsilon^{\prime})\cdot\mathsf{opt}_{T^{\prime}}}{t_{k}-1}\Big{)}-efficient operation that opens ii is available. Thus, we can apply Lemma 10 on ii, C~={jt1,jt2,,jtk1}\tilde{C}=\{j_{t_{1}},j_{t_{2}},\cdots,j_{t_{k-1}}\} and ϕ\phi to conclude that before Step 5, we have

d(i,S)fi+2k=1k1d(i,jtk)k1+O(ϵ)𝗈𝗉𝗍Ttk1.\displaystyle d(i,S)\leq\frac{f_{i}+2\cdot\sum_{k^{\prime}=1}^{k-1}d(i,j_{t_{k^{\prime}}})}{k-1}+\frac{O(\epsilon^{\prime})\cdot\mathsf{opt}_{T^{\prime}}}{t_{k}-1}.

In 𝗂𝗇𝗂𝗍𝗂𝖺𝗅𝖼𝗈𝗇𝗇𝖾𝖼𝗍(jtk)\mathsf{initial\mathchar 45\relax connect}(j_{t_{k}}), we have the option of connecting jtkj_{t_{k}} to its nearest open facility. Thus, we have

Δtkd(i,S)+d(i,jtk)\displaystyle\Delta_{t_{k}}\leq d(i,S)+d(i,j_{t_{k}}) fi+2k=1k1d(i,jtk)k1+O(ϵ)𝗈𝗉𝗍Ttk1+d(i,jtk).\displaystyle\leq\frac{f_{i}+2\cdot\sum_{k^{\prime}=1}^{k-1}d(i,j_{t_{k^{\prime}}})}{k-1}+\frac{O(\epsilon^{\prime})\cdot\mathsf{opt}_{T^{\prime}}}{t_{k}-1}+d(i,j_{t_{k}}).

We now sum up the above inequality for all k[2,s]k\in[2,s] and that Δt1fi+d(j,jt1)\Delta_{t_{1}}\leq f_{i}+d(j,j_{t_{1}}). We get

k=1sΔtkO(logs)(fi+k=1sd(i,jtk))+O(ϵ)k=2s𝗈𝗉𝗍Ttk1.\displaystyle\sum_{k=1}^{s}\Delta_{t_{k}}\leq O(\log s)\left(f_{i}+\sum_{k^{\prime}=1}^{s}d(i,j_{t_{k^{\prime}}})\right)+O(\epsilon^{\prime})\sum_{k=2}^{s}\frac{\mathsf{opt}_{T^{\prime}}}{t_{k}-1}. (1)

To see the above inequality, it suffices to consider the coefficients for fif_{i} and d(i,jtk)d(i,j_{t_{k^{\prime}}})’s on the right-hand side. The coefficient for fif_{i} is at most 1+11+12++1s1=O(logs)1+\frac{1}{1}+\frac{1}{2}+\cdots+\frac{1}{s-1}=O(\log s); the coefficient for each d(i,jtk)d(i,j_{t_{k^{\prime}}}) is 1+2k+2k+1++2s1=O(logs)1+\frac{2}{k^{\prime}}+\frac{2}{k^{\prime}+1}+\cdots+\frac{2}{s-1}=O(\log s).

We now take the sum of (1) over all stars (i,C)(i,C^{\prime}) in the optimum solution for CTC_{T^{\prime}}. The sum for the first term on the right side of (1) will be O(logT)𝗈𝗉𝗍TO(\log T^{\prime})\mathsf{opt}_{T^{\prime}} since fi+k=1sd(i,jtk)f_{i}+\sum_{k^{\prime}=1}^{s}d(i,j_{t_{k^{\prime}}}) is exactly the cost of the star (i,CC0C)(i,C^{\prime}\setminus C_{0}\subseteq C^{\prime}). The sum for the second term will be O(ϵlogT)𝗈𝗉𝗍TO(\epsilon^{\prime}\log T^{\prime})\cdot\mathsf{opt}_{T^{\prime}} since the set of integers tk1t_{k}-1 overall stars (i,C)(i,C^{\prime}) and all k2k\geq 2 are all positive and distinct. Thus overall, we have t=1TΔtO(logT)𝗈𝗉𝗍T\sum_{t=1}^{T^{\prime}}\Delta_{t}\leq O(\log T^{\prime})\mathsf{opt}_{T^{\prime}}. ∎

With Lemma 11, we can now bound the amortized recourse of one stage. In time tt, 𝖼𝗈𝗌𝗍(S,δ)\mathsf{cost}(S,\delta) first increases by Δt\Delta_{t} in Step 5. Then after that, it decreases by at least ϵ𝖼𝗈𝗌𝗍(S,σ)α𝖥𝖫|C|ϵ𝗈𝗉𝗍tα𝖥𝖫|C|ϵ𝗈𝗉𝗍tα𝖥𝖫|CT|\frac{\epsilon^{\prime}\mathsf{cost}(S,\sigma)}{\alpha_{\mathsf{FL}}|C|}\geq\frac{\epsilon^{\prime}\mathsf{opt}_{t}}{\alpha_{\mathsf{FL}}|C|}\geq\frac{\epsilon^{\prime}\mathsf{opt}_{t}}{\alpha_{\mathsf{FL}}|C_{T}|} for every reconnection we made. Let ΦT=t=1TΔt\Phi_{T^{\prime}}=\sum_{t=1}^{T^{\prime}}\Delta_{t}; Lemma 11 says Φtα𝗈𝗉𝗍t\Phi_{t}\leq\alpha\mathsf{opt}_{t} for some α=O(logT)\alpha=O(\log T) and every t[T]t\in[T]. Noticing that (𝗈𝗉𝗍t)tT(\mathsf{opt}_{t})_{t\in T} is a non-decreasing sequence, the total number of reconnections is at most

initϵ𝗈𝗉𝗍1/(α𝖥𝖫|CT|)+t=1TΔtϵ𝗈𝗉𝗍t/(α𝖥𝖫|CT|)=α𝖥𝖫|CT|ϵ(init𝗈𝗉𝗍1+t=1T1Δt𝗈𝗉𝗍t+ΔT𝗈𝗉𝗍T).\displaystyle\frac{\textsf{init}}{\epsilon^{\prime}\cdot\mathsf{opt}_{1}/(\alpha_{\mathsf{FL}}|C_{T}|)}+\sum_{t=1}^{T}\frac{\Delta_{t}}{\epsilon^{\prime}\cdot\mathsf{opt}_{t}/(\alpha_{\mathsf{FL}}|C_{T}|)}=\frac{\alpha_{\mathsf{FL}}|C_{T}|}{\epsilon^{\prime}}\left(\frac{\textsf{init}}{\mathsf{opt}_{1}}+\sum_{t=1}^{T-1}\frac{\Delta_{t}}{\mathsf{opt}_{t}}+\frac{\Delta_{T}}{\mathsf{opt}_{T}}\right).

Notice that 𝗂𝗇𝗂𝗍O(1)𝗈𝗉𝗍0O(1)𝗈𝗉𝗍1\mathsf{init}\leq O(1)\mathsf{opt}_{0}\leq O(1)\mathsf{opt}_{1}. Applying Lemma 9 with TT replaced by T1T-1, bt=Δt,Bt=Φtb_{t}=\Delta_{t},B_{t}=\Phi_{t} and at=𝗈𝗉𝗍ta_{t}=\mathsf{opt}_{t} for every tt, we have that t=1T1Δt𝗈𝗉𝗍tα(ln𝗈𝗉𝗍T1𝗈𝗉𝗍1+1)=O(logTlog1ϵ)\sum_{t=1}^{T-1}\frac{\Delta_{t}}{\mathsf{opt}_{t}}\leq\alpha\left(\ln\frac{\mathsf{opt}_{T-1}}{\mathsf{opt}_{1}}+1\right)=O\left(\log T\log\frac{1}{\epsilon^{\prime}}\right), since we have 𝗈𝗉𝗍T1O(1/ϵ)𝗈𝗉𝗍1\mathsf{opt}_{T-1}\leq O(1/\epsilon^{\prime})\cdot\mathsf{opt}_{1}. Notice that ΔT𝗈𝗉𝗍T\Delta_{T}\leq\mathsf{opt}_{T} since 𝗈𝗉𝗍TminiF(fi+d(i,jT))ΔT\mathsf{opt}_{T}\geq\min_{i\in F}(f_{i}+d(i,j_{T}))\geq\Delta_{T}. So, the total number of reconnections is at most O(logTϵlog1ϵ)|CT|O\left(\frac{\log T}{\epsilon^{\prime}}\log\frac{1}{\epsilon^{\prime}}\right)\cdot|C_{T}|. The amortized recourse per client is O(logTϵlog1ϵ)O(lognϵlog1ϵ)O\left(\frac{\log T}{\epsilon^{\prime}}\log\frac{1}{\epsilon^{\prime}}\right)\leq O\left(\frac{\log n}{\epsilon^{\prime}}\log\frac{1}{\epsilon^{\prime}}\right), where in the amortization, we only considered clients involved in the stage. Recall that nn is the total number of clients arrived.

As each client appears in at most 2 stages, the overall amortized recourse is O(lognϵlog1ϵ)O\left(\frac{\log n}{\epsilon^{\prime}}\log\frac{1}{\epsilon^{\prime}}\right). Finally we consider the loss in the approximation ratio due to freezing of clients. Suppose we are in the pp-th stage. Then the clients arrived at and before (p2)(p-2)-th stage has been frozen and removed. Let 𝗈𝗉𝗍¯\overline{\mathsf{opt}} be the cost of the optimum solution for all clients arrived at or before (p1)(p-1)-th stage. Then the frozen facilities and clients have cost at most 𝗈𝗉𝗍¯O(ϵ+ϵ2+ϵ2+)=O(ϵ)𝗈𝗉𝗍¯\overline{\mathsf{opt}}\cdot O\left(\epsilon^{\prime}+\epsilon^{\prime 2}+\epsilon^{\prime 2}+\cdots\right)=O(\epsilon^{\prime})\overline{\mathsf{opt}}. In any time in the pp-th stage, the optimum solution taking all arrived clients into consideration has cost 𝗈𝗉𝗍¯𝗈𝗉𝗍¯\overline{\mathsf{opt}}^{\prime}\geq\overline{\mathsf{opt}}, and our solution has cost at most (α𝖥𝖫+O(ϵ))𝗈𝗉𝗍¯(\alpha_{\mathsf{FL}}+O(\epsilon^{\prime}))\overline{\mathsf{opt}}^{\prime} without considering the frozen clients and facilities. Thus, our solution still has approximation ratio (α𝖥𝖫+O(ϵ))𝗈𝗉𝗍¯+O(ϵ)𝗈𝗉𝗍¯𝗈𝗉𝗍¯=α𝖥𝖫+O(ϵ)\frac{(\alpha_{\mathsf{FL}}+O(\epsilon^{\prime}))\overline{\mathsf{opt}}^{\prime}+O(\epsilon^{\prime})\overline{\mathsf{opt}}}{\overline{\mathsf{opt}}^{\prime}}=\alpha_{\mathsf{FL}}+O(\epsilon^{\prime}) when taking the frozen clients into consideration.

4 Fast Local Search via Randomized Sampling

From now on, we will be concerned with dynamic algorithms. Towards proving Theorem 2 for the incremental setting, we first develop a randomized procedure that allows us to perform local search operations fast. In the next section, we use this procedure and ideas from the previous section to develop the dynamic algorithm with the fast update time.

The high level idea is as follows: We partition the set of local operations into many “categories” depending on which facility it tries to open or swap in. In each iteration of the procedure, we sample the category according to some distribution and find the best local operation in this category. By only focusing on one category, one iteration of the procedure can run in time O(|C|log|F|)O(|C|\log|F|). On the other hand, the categories and the distribution over them are designed in such a way that in each iteration, the cost of our solution will be decreased by a multiplicative factor of 1Ω(1|F|)1-\Omega\big{(}\frac{1}{|F|}\big{)}. This idea has been used in [10] to obtain their O~(n2)\tilde{O}(n^{2}) algorithm for approximating facility location. However, their algorithm was based on a different local search algorithm and analysis; for consistency and convenience of description, we stick to original local search algorithm of [3] that leads to (1+2)(1+\sqrt{2})-approximation for the problem. Our algorithm needs to use the heap data structure.

4.1 Maintaining Heaps for Clients

Unlike the online algorithm for facility location in Section 3, in the dynamic algorithm, we guarantee that the clients are connected to their nearest open facilities. That is, we always have σj=argminiSd(j,i)\sigma_{j}=\arg\min_{i\in S}d(j,i); we still keep σ\sigma for convenience of description. We maintain |C||C| min-heaps, one for each client jCj\in C: The min-heap for jj will contain the facilities in S{σj}S\setminus\{\sigma_{j}\}, with priority value of ii being d(j,i)d(j,i). This allows us to efficiently retrieve the second nearest open facility to each jj: This is the facility at the top of the heap for jj and we use the procedure 𝗁𝖾𝖺𝗉𝗍𝗈𝗉(j)\mathsf{heap\mathchar 45\relax top}(j) to return it.

Algorithm 4 Δ𝗈𝗉𝖾𝗇(i)\mathsf{\Delta\mathchar 45\relax open}(i): return λfijCmax{0,d(j,σj)d(j,i)}\lambda f_{i}-\sum_{j\in C}\max\{0,d(j,\sigma_{j})-d(j,i)\}
Algorithm 5 𝗍𝗋𝗒𝗈𝗉𝖾𝗇(i)\mathsf{try\mathchar 45\relax open}(i)
1:if Δ𝗈𝗉𝖾𝗇(i)<0\mathsf{\Delta\mathchar 45\relax open}(i)<0 then open ii by updating S,σS,\sigma and heaps accordingly
Algorithm 6 Δ𝗌𝗐𝖺𝗉𝗂𝗇(i)\mathsf{\Delta\mathchar 45\relax swap\mathchar 45\relax in}(i)
1:C{jC:d(j,i)<d(j,σj)}C^{\prime}\leftarrow\{j\in C:d(j,i)<d(j,\sigma_{j})\} and ΨλfijC(d(j,σj)d(j,i))\Psi\leftarrow\lambda f_{i}-\sum_{j\in C^{\prime}}\big{(}d(j,\sigma_{j})-d(j,i)\big{)}
2:ΔminiS{jσ1(i)C[min{d(j,i),d(j,𝗁𝖾𝖺𝗉𝗍𝗈𝗉(j))}d(j,i)]λfi}+Ψ\Delta\leftarrow\min_{i^{\prime}\in S}\left\{\sum_{j\in\sigma^{-1}(i^{\prime})\setminus C^{\prime}}\big{[}\min\{d(j,i),d(j,\mathsf{heap\mathchar 45\relax top}(j))\}-d(j,i^{\prime})\big{]}-\lambda f_{i^{\prime}}\right\}+\Psi
3:return (Δ,the i above achieving the value of Δ)(\Delta,\text{the $i^{\prime}$ above achieving the value of $\Delta$})
Algorithm 7 Δ𝖼𝗅𝗈𝗌𝖾\mathsf{\Delta\mathchar 45\relax close}
1:ΔminiS{jσ1(i)[d(j,𝗁𝖾𝖺𝗉𝗍𝗈𝗉(j))d(j,i)]λfi}\Delta\leftarrow\min_{i^{\prime}\in S}\left\{\sum_{j\in\sigma^{-1}(i^{\prime})}\big{[}d(j,\mathsf{heap\mathchar 45\relax top}(j))-d(j,i^{\prime})\big{]}-\lambda f_{i^{\prime}}\right\}
2:return (Δ,the i above achieving the value of Δ)(\Delta,\text{the $i^{\prime}$ above achieving the value of $\Delta$})

We define four simple procedures Δ𝗈𝗉𝖾𝗇,𝗍𝗋𝗒𝗈𝗉𝖾𝗇,Δ𝗌𝗐𝖺𝗉𝗂𝗇\mathsf{\Delta\mathchar 45\relax open},\mathsf{try\mathchar 45\relax open},\mathsf{\Delta\mathchar 45\relax swap\mathchar 45\relax in} and Δ𝖼𝗅𝗈𝗌𝖾\mathsf{\Delta\mathchar 45\relax close} that are described in Algorithms 4, 5, 6 and 7 respectively. Recall that we use the scaled cost for the local search algorithm; so we are working on the scaled cost function in all these procedures. Δ𝗈𝗉𝖾𝗇(i)\mathsf{\Delta\mathchar 45\relax open}(i) for any iSi\notin S returns Δ\Delta, the increment of the scaled cost that will be incurred by opening ii. (For it to be useful, Δ\Delta should be negative, in which case |Δ||\Delta| indicates the cost decrement of opening ii). This is just one line procedure as in Algorithm 4; 𝗍𝗋𝗒𝗈𝗉𝖾𝗇\mathsf{try\mathchar 45\relax open} will open ii if it can reduce the scaled cost. Δ𝗌𝗐𝖺𝗉𝗂𝗇(i)\mathsf{\Delta\mathchar 45\relax swap\mathchar 45\relax in}(i) for some iSi\notin S returns a pair (Δ,i)(\Delta,i^{\prime}), where Δ\Delta is the smallest scaled cost increment we can achieve by opening ii and closing some facility iSi^{\prime}\in S, and ii^{\prime} gives the facility achieving the smallest value. (Again, for Δ\Delta to be useful, it should be negative, in which case ii^{\prime} is the facility that gives the maximum scaled cost decrement |Δ||\Delta|.) Similarly, Δ𝖼𝗅𝗈𝗌𝖾\mathsf{\Delta\mathchar 45\relax close} returns a pair (Δ,i)(\Delta,i^{\prime}), which tells us the maximum scaled cost decrement we can achieve by closing one facility and which facility can achieve the decrement. Notice that in all the procedures, the facility we shall open or swap in is given as a parameter, while the facility we shall close is chosen and returned by the procedures.

With the heaps, the procedures Δ𝗈𝗉𝖾𝗇,Δ𝗌𝗐𝖺𝗉𝗂𝗇\mathsf{\Delta\mathchar 45\relax open},\mathsf{\Delta\mathchar 45\relax swap\mathchar 45\relax in} and Δ𝖼𝗅𝗈𝗌𝖾\mathsf{\Delta\mathchar 45\relax close} can run in O(|C|)O(|C|) time. We only analyze Δ𝗌𝗐𝖺𝗉𝗂𝗇(i)\mathsf{\Delta\mathchar 45\relax swap\mathchar 45\relax in}(i) as the other two are easier. First, we define CC^{\prime} to be the set of clients jj with d(j,i)<d(j,σj)d(j,i)<d(j,\sigma_{j}); these are the clients that will surely be reconnected to ii once ii is swapped in. Let Ψ=λfijC(d(j,σj)d(j,i))\Psi=\lambda f_{i}-\sum_{j\in C^{\prime}}(d(j,\sigma_{j})-d(j,i)) be the net scaled cost increase by opening ii and connecting CC^{\prime} to ii. The computation of CC^{\prime} and Ψ\Psi in Step 1 takes O(|C|)O(|C|) time. If additionally we close some iSi^{\prime}\in S, we need to reconnect each client in σ1(i)C\sigma^{-1}(i^{\prime})\setminus C^{\prime} to either ii, or the top element in the heap for jj, whichever is closer to jj. Steps 2 and 3 compute and return the best scaled cost increment and the best ii^{\prime}. Since iS|σ1(i)|=|C|\sum_{i^{\prime}\in S}|\sigma^{-1}(i^{\prime})|=|C|, the running time of the step can be bounded by O(|C|)O(|C|).

The running time for 𝗍𝗋𝗒𝗈𝗉𝖾𝗇\mathsf{try\mathchar 45\relax open}, swapping two facilities and closing a facility (which are not defined explicitly as procedures, but used in Algorithms 8) can be bounded by O(|C|log|F|)O(|C|\log|F|). The running times come from updating the heap structures: For each of the |C||C| heaps, we need to delete and/or add at most 22 elements; each operation takes time O(log|F|)O(\log|F|).

4.2 Random Sampling of Local Operations

Algorithm 8 𝗌𝖺𝗆𝗉𝗅𝖾𝖽𝗅𝗈𝖼𝖺𝗅𝗌𝖾𝖺𝗋𝖼𝗁\mathsf{sampled\mathchar 45\relax local\mathchar 45\relax search}
1:if 𝗋𝖺𝗇𝖽(0,1)<1/3\mathsf{rand}(0,1)<1/3 then \triangleright 𝗋𝖺𝗇𝖽(0,1)\mathsf{rand}(0,1) returns a uniformly random number in [0,1][0,1]
2:     (Δ,i)Δ𝖼𝗅𝗈𝗌𝖾(\Delta,i^{\prime})\leftarrow\mathsf{\Delta\mathchar 45\relax close}
3:     if Δ<0\Delta<0 then close ii^{\prime} by updating S,δS,\delta and heaps accordingly
4:else
5:     ii\leftarrow random facility in FSF\setminus S
6:     ΔΔ𝗈𝗉𝖾𝗇(i),(Δ,i)Δ𝗌𝗐𝖺𝗉𝗂𝗇(i)\Delta\leftarrow\mathsf{\Delta\mathchar 45\relax open}(i),(\Delta^{\prime},i^{\prime})\leftarrow\mathsf{\Delta\mathchar 45\relax swap\mathchar 45\relax in}(i)
7:     if ΔΔ\Delta\leq\Delta^{\prime} and Δ<0\Delta<0 then open ii by updating S,δS,\delta and heaps accordingly
8:     else if Δ<0\Delta^{\prime}<0 then open ii and close ii^{\prime} by updating S,δS,\delta and heaps accordingly
Algorithm 9 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)\mathsf{FL\mathchar 45\relax iterate}(M)
1:(Sbest,σbest)(S,σ)(S^{\mathrm{best}},\sigma^{\mathrm{best}})\leftarrow(S,\sigma)
2:for 1\ell\leftarrow 1 to MM do
3:     call 𝗌𝖺𝗆𝗉𝗅𝖾𝖽𝗅𝗈𝖼𝖺𝗅𝗌𝖾𝖺𝗋𝖼𝗁\mathsf{sampled\mathchar 45\relax local\mathchar 45\relax search}
4:     if 𝖼𝗈𝗌𝗍(S,σ)<𝖼𝗈𝗌𝗍(Sbest,σbest)\mathsf{cost}(S,\sigma)<\mathsf{cost}(S^{\mathrm{best}},\sigma^{\mathrm{best}}) then (Sbest,σbest)(S,σ)(S^{\mathrm{best}},\sigma^{\mathrm{best}})\leftarrow(S,\sigma)      
5:return (Sbest,σbest)(S^{\mathrm{best}},\sigma^{\mathrm{best}})

With the support of the heaps, we can design a fast algorithm to implement randomized local search. 𝗌𝖺𝗆𝗉𝗅𝖾𝖽𝗅𝗈𝖼𝖺𝗅𝗌𝖾𝖺𝗋𝖼𝗁\mathsf{sampled\mathchar 45\relax local\mathchar 45\relax search} in Algorithm 8 gives one iteration of the local search. We first decide which operation we shall perform randomly. With probability 1/31/3, we perform the 𝖼𝗅𝗈𝗌𝖾\mathsf{close} operation that will reduce the scaled cost the most (if it exists). With the remaining probability 2/32/3, we perform either an 𝗈𝗉𝖾𝗇\mathsf{open} or a 𝗌𝗐𝖺𝗉\mathsf{swap} operation. To reduce the running time, we randomly choose a facility iFSi\in F\setminus S and find the best operation that opens or swaps in ii, and perform the operation if it reduces the cost. One iteration of 𝗌𝖺𝗆𝗉𝗅𝖾𝖽𝗅𝗈𝖼𝖺𝗅𝗌𝖾𝖺𝗋𝖼𝗁\mathsf{sampled\mathchar 45\relax local\mathchar 45\relax search} calls the procedures in Algorithms 4 to 7 at most once and performs at most one operation, and thus has running time O(|C|log|F|)O(|C|\log|F|).

In the procedure 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)\mathsf{FL\mathchar 45\relax iterate}(M) described in Algorithm 9, we run the 𝗌𝖺𝗆𝗉𝗅𝖾𝖽𝗅𝗈𝖼𝖺𝗅𝗌𝖾𝖺𝗋𝖼𝗁\mathsf{sampled\mathchar 45\relax local\mathchar 45\relax search} MM times. It returns the best solution obtained in these iterations, according to the original (non-scaled) cost, which is not necessarily the solution given in the last iteration. So we have

Observation 12.

The running time of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)\mathsf{FL\mathchar 45\relax iterate}(M) is O(M|C|log|F|)O(M|C|\log|F|), where CC is the set of clients when we run the procedure.

Throughout this section, we fix a facility location instance. Let (S,σ)(S^{*},\sigma^{*}) be the optimum solution (w.r.t the original cost) and 𝗈𝗉𝗍=𝖼𝗈𝗌𝗍(S,σ)\mathsf{opt}=\mathsf{cost}(S^{*},\sigma^{*}) be the optimum cost. Fixing one execution of 𝗌𝖺𝗆𝗉𝗅𝖾𝖽𝗅𝗈𝖼𝖺𝗅𝗌𝖾𝖺𝗋𝖼𝗁\mathsf{sampled\mathchar 45\relax local\mathchar 45\relax search}, we use (S0,σ0)(S^{0},\sigma^{0}) and (S1,σ1)(S^{1},\sigma^{1}) to denote the solutions before and after the execution respectively. Then, we have

Lemma 13.

Consider an execution of 𝗌𝖺𝗆𝗉𝗅𝖾𝖽𝗅𝗈𝖼𝖺𝗅𝗌𝖾𝖺𝗋𝖼𝗁\mathsf{sampled\mathchar 45\relax local\mathchar 45\relax search} and fix (S0,σ0)(S^{0},\sigma^{0}). We have

𝖼𝗈𝗌𝗍λ(S0,σ0)𝔼[𝖼𝗈𝗌𝗍λ(S1,σ1)]13|F|max{𝖼𝖼(σ0)(λf(S)+𝖼𝖼(σ))λf(S)(λf(S)+2𝖼𝖼(σ))𝖼𝗈𝗌𝗍λ(S0,σ0)(2λf(S)+3𝖼𝖼(σ))}.\displaystyle\mathsf{cost}_{\lambda}(S^{0},\sigma^{0})-\operatorname*{\mathbb{E}}[\mathsf{cost}_{\lambda}(S^{1},\sigma^{1})]\geq\frac{1}{3|F|}\max\left\{\begin{array}[]{c}\mathsf{cc}(\sigma^{0})-(\lambda f(S^{*})+\mathsf{cc}(\sigma^{*}))\\ \lambda f(S)-(\lambda f(S^{*})+2\mathsf{cc}(\sigma^{*}))\\ \mathsf{cost}_{\lambda}(S^{0},\sigma^{0})-(2\lambda f(S^{*})+3\mathsf{cc}(\sigma^{*}))\end{array}\right\}.
Lemma 14.

Let (S,σ)(S^{\circ},\sigma^{\circ}) be the (S,σ)(S,\sigma) at the beginning of an execution of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)\mathsf{FL\mathchar 45\relax iterate}(M), and assume it is an O(1)O(1)-approximation to the instance. Let Γ2\Gamma\geq 2 and M=O(|F|ϵlogΓ)M=O\left(\frac{|F|}{\epsilon^{\prime}}\log\Gamma\right) is big enough. Then with probability at least 11Γ1-\frac{1}{\Gamma}, the solution returned by the procedure is (α𝖥𝖫+ϵ)(\alpha_{\mathsf{FL}}+\epsilon^{\prime})-approximate.

5 (1+2+ϵ)(1+\sqrt{2}+\epsilon)-Approximate Dynamic Algorithm for Facility Location in Incremental Setting

In this section, we prove Theorem 2 by combining the ideas from Sections 3 and 4 to derive a dynamic algorithm for facility location in the incremental setting. As for the online algorithm in Section 3, we divide our algorithm into stages. Whenever a client comes, we use a simple rule to accommodate it. Now we can not afford to consider all possible local operations as in Section 3. Instead we use the randomized local search idea from the algorithm in Section 4 by calling the procedure 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate}. We call the procedure only if the cost of our solution has increased by a factor of 1+ϵ1+\epsilon^{\prime} (where ϵ=Θ(ϵ)\epsilon^{\prime}=\Theta(\epsilon) is small enough). In our analysis, we show a lemma similar to Lemma 11: The total increase of costs due to arrival of clients is small, compared to the optimum cost for these clients. Then, we can bound the number of times we call 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate}. Recall that we are given an integer Γ=poly(n,logD,1ϵ)\Gamma=\mathrm{poly}\big{(}n,\log D,\frac{1}{\epsilon}\big{)} that is big enough: We are aiming at a success probability of 11/Γ1-1/\Gamma for each call of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate}. Our final running time will only depend on O(logΓ)O(\log\Gamma).

The main algorithm will be the same as Algorithm 3, except that we use Algorithm 10 as the algorithm for one stage. As before, we only need to design one stage of the algorithm. Recall that in a stage we are given an initial set CC of clients, an O(1)O(1)-approximate solution (S,σ)(S,\sigma) for CC. Clients come one by one and our goal is to maintain an (α𝖥𝖫+O(ϵ))(\alpha_{\mathsf{FL}}+O(\epsilon^{\prime}))-approximate solution at any time. The stage terminates if no client comes or our solution has cost more than 1/ϵ1/\epsilon^{\prime} times the cost of the initial solution.

Algorithm 10 One Stage of Dynamic Algorithm for Facility Location
1:
  • CC: the initial set of clients

  • (S,σ)(S,\sigma): initial solution for CC, which is O(1)O(1)-approximate

2:let M=O(|F|ϵlogΓ)M=O\left(\frac{|F|}{\epsilon^{\prime}}\log\Gamma\right) be large enough
3:(S,σ)𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)(S,\sigma)\leftarrow\mathsf{FL\mathchar 45\relax iterate}\left(M\right), init𝖼𝗈𝗌𝗍(S,σ),𝗅𝖺𝗌𝗍init\textsf{init}\leftarrow\mathsf{cost}(S,\sigma),{\mathsf{last}}\leftarrow\textsf{init}
4:for t1,2,3,t\leftarrow 1,2,3,\cdots, terminating if no more clients arrive do
5:     for q=log𝗅𝖺𝗌𝗍|F|q={\left\lceil\log\frac{{\mathsf{last}}}{|F|}\right\rceil} to log𝗅𝖺𝗌𝗍ϵ{\left\lceil\log\frac{{\mathsf{last}}}{\epsilon^{\prime}}\right\rceil} do
6:         if iargminiFS,fi2qd(jt,i)i\leftarrow\arg\min_{i\in F\setminus S,f_{i}\leq 2^{q}}d(j_{t},i) exists, then call 𝗍𝗋𝗒𝗈𝗉𝖾𝗇(i)\mathsf{try\mathchar 45\relax open^{\prime}}(i) \triangleright 𝗍𝗋𝗒𝗈𝗉𝖾𝗇\mathsf{try\mathchar 45\relax open^{\prime}} is the same as 𝗍𝗋𝗒𝗈𝗉𝖾𝗇\mathsf{try\mathchar 45\relax open} except we consider the cost instead of scaled cost.      
7:     CC{jt}C\leftarrow C\cup\{j_{t}\} and call 𝗍𝗋𝗒𝗈𝗉𝖾𝗇(argminiFS(d(jt,i)+fi))\mathsf{try\mathchar 45\relax open^{\prime}}\big{(}\arg\min_{i\in F\setminus S}(d(j_{t},i)+f_{i})\big{)}
8:     if 𝖼𝗈𝗌𝗍(S,σ)>(1+ϵ)𝗅𝖺𝗌𝗍\mathsf{cost}(S,\sigma)>(1+\epsilon^{\prime})\cdot{\mathsf{last}} then
9:         (S,σ)𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)(S,\sigma)\leftarrow\mathsf{FL\mathchar 45\relax iterate}\left(M\right)
10:         if 𝖼𝗈𝗌𝗍(S,σ)>𝗅𝖺𝗌𝗍\mathsf{cost}(S,\sigma)>{\mathsf{last}} then 𝗅𝖺𝗌𝗍𝖼𝗈𝗌𝗍(S,σ){\mathsf{last}}\leftarrow\mathsf{cost}(S,\sigma)          
11:         if 𝗅𝖺𝗌𝗍>init/ϵ{\mathsf{last}}>\textsf{init}/\epsilon^{\prime} then terminate the stage                

Notice that in a stage, we are considering the original costs of solutions (instead of scaled costs as inside 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate}). During a stage we maintain a value 𝗅𝖺𝗌𝗍{\mathsf{last}} which gives an estimation on the cost of the current solution (S,σ)(S,\sigma). Whenever a client jtj_{t} comes, we apply some rules to open some facilities and connect jtj_{t} (Steps 5 to 7). These operations are needed to make the cost increase due to the arrival of jtj_{t} (defined as Δt\Delta_{t} later) small. In the algorithm 𝗍𝗋𝗒𝗈𝗉𝖾𝗇\mathsf{try\mathchar 45\relax open^{\prime}} is the same as 𝗍𝗋𝗒𝗈𝗉𝖾𝗇\mathsf{try\mathchar 45\relax open}, except that we use the original cost instead of the scaled cost (this is not important but only for the sake of convenience). If 𝖼𝗈𝗌𝗍(S,σ)\mathsf{cost}(S,\sigma) becomes too large, i.e, 𝖼𝗈𝗌𝗍(S,σ)>(1+ϵ)𝗅𝖺𝗌𝗍\mathsf{cost}(S,\sigma)>(1+\epsilon^{\prime}){\mathsf{last}}, then we call (S,σ)𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)(S,\sigma)\leftarrow\mathsf{FL\mathchar 45\relax iterate}(M) for the MM defined in Step 2 (Step 9), and update 𝗅𝖺𝗌𝗍{\mathsf{last}} to 𝖼𝗈𝗌𝗍(S,σ)\mathsf{cost}(S,\sigma) if we have 𝖼𝗈𝗌𝗍(S,σ)>𝗅𝖺𝗌𝗍\mathsf{cost}(S,\sigma)>{\mathsf{last}} (Step 10). We terminate the algorithm when 𝗅𝖺𝗌𝗍𝗂𝗇𝗂𝗍/ϵ{\mathsf{last}}\geq\mathsf{init}/\epsilon, where 𝗂𝗇𝗂𝗍\mathsf{init} is 𝖼𝗈𝗌𝗍(S,σ)\mathsf{cost}(S,\sigma) at the beginning of the stage (Step 11).

We say an execution of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)\mathsf{FL\mathchar 45\relax iterate}(M) is successful if the event in Lemma 14 happens. Then we have

Lemma 15.

If all executions of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate} are successful, the solution (S,σ)(S,\sigma) at the end of each time is (1+ϵ)(α𝖥𝖫+ϵ)(1+\epsilon^{\prime})(\alpha_{\mathsf{FL}}+\epsilon^{\prime})-approximate.

Proof.

This holds since we always have 𝖼𝗈𝗌𝗍(S,σ)(1+ϵ)𝗅𝖺𝗌𝗍\mathsf{cost}(S,\sigma)\leq(1+\epsilon^{\prime}){\mathsf{last}} at the end of each time, where 𝗅𝖺𝗌𝗍{\mathsf{last}} is the cost of some (α𝖥𝖫+ϵ)(\alpha_{\mathsf{FL}}+\epsilon^{\prime})-approximate solution at some moment before. As we only add clients to CC, the cost of the optimum solution can only increase and thus the claim holds. ∎

Now we argue each execution of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)\mathsf{FL\mathchar 45\relax iterate}(M) is successful with probability at least 11/Γ1-1/\Gamma. This will happen if (S,σ)(S,\sigma) is O(1)O(1)-approximate before the call. By Lemma 14, we only need to make sure that the (S,σ)(S,\sigma) before the execution is O(1)O(1)-approximate. This is easy to see: Before Step 7 in time tt, we have 𝖼𝗈𝗌𝗍(S,σ)O(1)𝗈𝗉𝗍\mathsf{cost}(S,\sigma)\leq O(1)\mathsf{opt}; the increase of 𝖼𝗈𝗌𝗍(S,σ)\mathsf{cost}(S,\sigma) in the step is at most the value of 𝗈𝗉𝗍\mathsf{opt} after the step (i.e, we consider the client jtj_{t} when defining 𝗈𝗉𝗍\mathsf{opt}). Thus, we have 𝖼𝗈𝗌𝗍(S,σ)O(1)𝗈𝗉𝗍\mathsf{cost}(S,\sigma)\leq O(1)\mathsf{opt} after the step.

5.1 Bounding Number of Times of Calling 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate}

It remains to bound the number of times we call 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate}. Again, we use TT to denote the last time step of Algorithm 10 (i.e, one stage of the dynamic algorithm) and Δt\Delta_{t} to denote the cost increase due to the arrival of jtj_{t}: it is the value of 𝖼𝗈𝗌𝗍(S,σ)\mathsf{cost}(S,\sigma) before Step 7 minus that after Step 7 in time tt. For every time t[T]t\in[T], let CtC_{t} be the set CC at the end of time tt, and let 𝗈𝗉𝗍t\mathsf{opt}_{t} be the cost of the optimum solution for CtC_{t}. Let 𝗅𝖺𝗌𝗍t{\mathsf{last}}_{t} be the value of 𝗅𝖺𝗌𝗍{\mathsf{last}} at the beginning of time tt.

Due to Step 7, we have the following observation:

Observation 16.

For every t[T]t\in[T], we have ΔtminiF(fi+d(i,jt))\Delta_{t}\leq\min_{i\in F}(f_{i}+d(i,j_{t})).

Proof.

Let i=argminiF(fi+d(i,jt))i=\arg\min_{i\in F}(f_{i}+d(i,j_{t})) and consider Step 7 at time tt. If d(jt,S)fi+d(i,jt)d(j_{t},S)\leq f_{i}+d(i,j_{t}) before the step, then we have Δtd(i,jt)\Delta_{t}\leq d(i,j_{t}). Otherwise, iSi\notin S and d(jt,S)>fi+d(i,jt)d(j_{t},S)>f_{i}+d(i,j_{t}). Then 𝗍𝗋𝗒𝗈𝗉𝖾𝗇(i)\mathsf{try\mathchar 45\relax open^{\prime}}(i) in the step will open ii and we have Δtfi+d(i,jt)\Delta_{t}\leq f_{i}+d(i,j_{t}). ∎

We can also prove the following lemma that bounds Δt\Delta_{t}:

Lemma 17.

Let t[T],iFt\in[T],i^{*}\in F such that fi𝗅𝖺𝗌𝗍t/ϵf_{i^{*}}\leq{\mathsf{last}}_{t}/\epsilon^{\prime} and CCt1C^{\prime}\subseteq C_{t-1} be any non-empty subset. Then we have

Δt2|C|(max{fi,𝗅𝖺𝗌𝗍t/|F|}+jCd(i,j))+5d(i,jt).\displaystyle\Delta_{t}\leq\frac{2}{|C^{\prime}|}\left(\max{\left\{f_{i^{*}},{\mathsf{last}}_{t}/|F|\right\}}+\sum_{j\in C^{\prime}}d(i^{*},j)\right)+5d(i^{*},j_{t}).
Proof.

In this proof, we focus on the time tt of the algorithm. If iSi^{*}\in S before Step 7, then we have Δtd(i,jt)\Delta_{t}\leq d(i^{*},j_{t}) and thus we can assume iSi^{*}\notin S before Step 7. Since Loop 5 only adds facilities to SS, we have that iSi^{*}\notin S at any moment in Loop 5.

Let q=logmax{fi,𝗅𝖺𝗌𝗍t/|F|}q={\left\lceil\log\max{\left\{f_{i^{*}},{\mathsf{last}}_{t}/|F|\right\}}\right\rceil}; notice this qq is considered in Loop 5. Let iFSi\in F\setminus S be the facility with fi2qf_{i}\leq 2^{q} nearest to jtj_{t} at the beginning of the iteration qq; this is the facility we try to open in Step 6 in the iteration for qq. Notice that d(jt,i)d(jt,i)d(j_{t},i)\leq d(j_{t},i^{*}) since ii^{*} is a candidate facility.

Since we called 𝗍𝗋𝗒𝗈𝗉𝖾𝗇(i)\mathsf{try\mathchar 45\relax open}(i) in Step 6, there is no 0-efficient opening operation that opens ii after the step. Then, we can apply Lemma 10 on this facility ii, the set CC^{\prime} and ϕ=0\phi=0. So, after Step 6 of the iteration for qq, we have

d(jt,S)1|C|(fi+2jCd(i,j))+d(i,jt).\displaystyle d(j_{t},S)\leq\frac{1}{|C^{\prime}|}\left(f_{i}+2\sum_{j\in C^{\prime}}d(i,j)\right)+d(i,j_{t}).

Notice that d(i,i)d(i,jt)+d(jt,i)2d(jt,i)d(i,i^{*})\leq d(i,j_{t})+d(j_{t},i^{*})\leq 2d(j_{t},i^{*}), fi2max{fi,ϵ𝗅𝖺𝗌𝗍t/|F|}f_{i}\leq 2\max{\left\{f_{i^{*}},\epsilon^{\prime}{\mathsf{last}}_{t}/|F|\right\}} and SS can only grow before the end of Step 7. We have

Δt\displaystyle\Delta_{t} 1|C|(2max{fi,𝗅𝖺𝗌𝗍t/|F|}+2jC(d(i,j)+d(i,i)))+d(i,jt)\displaystyle\leq\frac{1}{|C^{\prime}|}\left(2\max{\left\{f_{i^{*}},{\mathsf{last}}_{t}/|F|\right\}}+2\sum_{j\in C^{\prime}}(d(i^{*},j)+d(i^{*},i))\right)+d(i^{*},j_{t})
2|C|(max{fi,𝗅𝖺𝗌𝗍t/|F|}+jCd(i,j))+5d(i,jt).\displaystyle\leq\frac{2}{|C^{\prime}|}\left(\max{\left\{f_{i^{*}},{\mathsf{last}}_{t}/|F|\right\}}+\sum_{j\in C^{\prime}}d(i^{*},j)\right)+5d(i^{*},j_{t}).\qed

With the lemma, we can then prove the following lemma:

Lemma 18.

For every T[T1]T^{\prime}\in[T-1], we have

t=1TΔtO(logT)𝗈𝗉𝗍T\displaystyle\sum_{t=1}^{T^{\prime}}\Delta_{t}\leq O(\log T^{\prime})\cdot\mathsf{opt}_{T^{\prime}}
Proof.

The proof is similar to that of Lemma 11. Let (S,σ)(S^{*},\sigma^{*}) be the optimum solution for clients CTC_{T^{\prime}}. Focus on some iSi^{*}\in S^{*} and assume (CTC0)σ1(i)={jt1,jt2,,jts}(C_{T^{\prime}}\setminus C_{0})\cap\sigma^{*-1}(i^{*})=\{j_{t_{1}},j_{t_{2}},\cdots,j_{t_{s}}\} with 1t1<t2<<tsT1\leq t_{1}<t_{2}<\cdots<t_{s}\leq T^{\prime}.

We have Δt1fi+d(i,jt1)\Delta_{t_{1}}\leq f_{i^{*}}+d(i^{*},j_{t_{1}}) by Observation 16. Then focus on any k[2,s]k\in[2,s]. If fi>𝗅𝖺𝗌𝗍tk/ϵf_{i^{*}}>{\mathsf{last}}_{t_{k}}/\epsilon, then we must have 𝗈𝗉𝗍tk𝗅𝖺𝗌𝗍tk/ϵ\mathsf{opt}_{t_{k}}\geq{\mathsf{last}}_{t_{k}}/\epsilon and the stage will terminate at time tk{t_{k}}. Thus tk=T{t_{k}}=T, contradicting the assumption that tkTT1{t_{k}}\leq T^{\prime}\leq T-1. So we assume fi𝗅𝖺𝗌𝗍tk/ϵf_{i^{*}}\leq{\mathsf{last}}_{t_{k}}/\epsilon. We can apply Lemma 17 with ii^{*} and C={jt1,jt2,,jtk1}C^{\prime}=\{j_{t_{1}},j_{t_{2}},\cdots,j_{t_{k-1}}\} to obtain that Δtk2k1(max{fi,𝗅𝖺𝗌𝗍tk/|F|}+k=1k1d(i,jtk))+5d(i,jtk)\Delta_{t_{k}}\leq\frac{2}{k-1}\left(\max{\left\{f_{i^{*}},{\mathsf{last}}_{t_{k}}/|F|\right\}}+\sum_{k^{\prime}=1}^{k-1}d(i^{*},j_{t_{k^{\prime}}})\right)+5d(i^{*},j_{t_{k}}). We can replace 𝗅𝖺𝗌𝗍tk{\mathsf{last}}_{t_{k}} with 𝗅𝖺𝗌𝗍T{\mathsf{last}}_{T^{\prime}} since 𝗅𝖺𝗌𝗍tk𝗅𝖺𝗌𝗍T{\mathsf{last}}_{t_{k}}\leq{\mathsf{last}}_{T^{\prime}}.

The sum of upper bounds over all k[s]k\in[s] is a linear combinations of max{fi,𝗅𝖺𝗌𝗍T/|F|}\max{\left\{f_{i^{*}},{\mathsf{last}}_{T^{\prime}}/|F|\right\}} and d(i,jtk)d(i^{*},j_{t_{k^{\prime}}})’s. In the linear combination, the coefficient for max{fi,𝗅𝖺𝗌𝗍T/|F|}\max{\left\{f_{i^{*}},{\mathsf{last}}_{T^{\prime}}/|F|\right\}} is at most 1+21+22+23++2s1=O(logs)=O(logT)1+\frac{2}{1}+\frac{2}{2}+\frac{2}{3}+\cdots+\frac{2}{s-1}=O(\log s)=O(\log T^{\prime}). The coefficient for d(i,jtk)d(i^{*},j_{t_{k^{\prime}}}) is at most 5+2k+2k+1+2s1=O(logs)=O(logT)5+\frac{2}{k^{\prime}}+\frac{2}{k^{\prime}+1}+\cdots\frac{2}{s-1}=O(\log s)=O(\log T^{\prime}). Thus, overall, we have k=1sΔtkO(logT)(max{fi,𝗅𝖺𝗌𝗍T/|F|}+k=1sd(i,jtk))\sum_{k=1}^{s}\Delta_{t_{k}}\leq O(\log T^{\prime})\big{(}\max{\left\{f_{i^{*}},{\mathsf{last}}_{T^{\prime}}/|F|\right\}}+\sum_{k^{\prime}=1}^{s}d(i^{*},j_{t_{k^{\prime}}})\big{)}.

Therefore t=1TΔtO(logT)(𝖼𝗈𝗌𝗍(S,σ)+|S|𝗅𝖺𝗌𝗍T/|F|)\sum_{t=1}^{T^{\prime}}\Delta_{t}\leq O(\log T^{\prime})\left(\mathsf{cost}(S^{*},\sigma^{*})+|S^{*}|{\mathsf{last}}_{T^{\prime}}/|F|\right), by taking the sum of the above inequality over all iSi^{*}\in S^{*}. The bound is at most O(logT)(𝗈𝗉𝗍T+𝗅𝖺𝗌𝗍T)=O(logT)𝗈𝗉𝗍TO(\log T^{\prime})(\mathsf{opt}_{T^{\prime}}+{\mathsf{last}}_{T^{\prime}})=O(\log T^{\prime})\cdot\mathsf{opt}_{T^{\prime}}, since |S||F||S^{*}|\leq|F| and 𝗅𝖺𝗌𝗍TO(1)𝗈𝗉𝗍T1O(1)𝗈𝗉𝗍T{\mathsf{last}}_{T^{\prime}}\leq O(1)\mathsf{opt}_{T^{\prime}-1}\leq O(1)\mathsf{opt}_{T^{\prime}}. ∎

Between two consecutive calls of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate} in Step 9 at time t1t_{1} and t2>t1t_{2}>t_{1}, 𝖼𝗈𝗌𝗍(S,σ)\mathsf{cost}(S,\sigma) should have increased by at least ϵ𝗅𝖺𝗌𝗍t2\epsilon^{\prime}{\mathsf{last}}_{t_{2}}: At the end of time t1t_{1}, we have 𝖼𝗈𝗌𝗍(S,σ)𝗅𝖺𝗌𝗍t1+1=𝗅𝖺𝗌𝗍t2\mathsf{cost}(S,\sigma)\leq{\mathsf{last}}_{t_{1}+1}={\mathsf{last}}_{t_{2}} since otherwise 𝗅𝖺𝗌𝗍{\mathsf{last}} should have been updated in time t1t_{1}. We need to have 𝖼𝗈𝗌𝗍(S,σ)>(1+ϵ)𝗅𝖺𝗌𝗍t2\mathsf{cost}(S,\sigma)>(1+\epsilon^{\prime}){\mathsf{last}}_{t_{2}} after Step 7 at time t2t_{2} in order to call 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate}. Thus, the increase of the cost during this period is at least ϵ𝗅𝖺𝗌𝗍t2\epsilon^{\prime}{\mathsf{last}}_{t_{2}}. Thus, we have t=t1+1t2Δtϵ𝗅𝖺𝗌𝗍t1\sum_{t=t_{1}+1}^{t_{2}}\frac{\Delta_{t}}{\epsilon^{\prime}\cdot{\mathsf{last}}_{t}}\geq 1 since 𝗅𝖺𝗌𝗍t=𝗅𝖺𝗌𝗍t2{\mathsf{last}}_{t}={\mathsf{last}}_{t_{2}} for every t(t1,t2]t\in(t_{1},t_{2}]. The argument also holds when t1=0t_{1}=0 and t2>t1t_{2}>t_{1} is the first time in which we call 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate}. Counting the call of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate} in Step 3, we can bound the total number of times we call the procedure by 1+1ϵt=1TΔt𝗅𝖺𝗌𝗍t1+\frac{1}{\epsilon^{\prime}}\sum_{t=1}^{T}\frac{\Delta_{t}}{{\mathsf{last}}_{t}}.

Again let ΦT=t=1TΔt\Phi_{T^{\prime}}=\sum_{t=1}^{T^{\prime}}\Delta_{t} for every T[0,T]T^{\prime}\in[0,T]. Lemma 18 says ΦtO(logt)𝗈𝗉𝗍t\Phi_{t}\leq O(\log t)\mathsf{opt}_{t} for every t[0,T1]t\in[0,T-1]. For every t[T]t\in[T], since Δt𝗈𝗉𝗍t\Delta_{t}\leq\mathsf{opt}_{t}, thus we have Φt=Φt1+ΔtO(logt)𝗈𝗉𝗍t1O(logT)𝗅𝖺𝗌𝗍t\Phi_{t}=\Phi_{t-1}+\Delta_{t}\leq O(\log t)\mathsf{opt}_{t-1}\leq O(\log T){\mathsf{last}}_{t} since 𝗅𝖺𝗌𝗍t{\mathsf{last}}_{t} will be at least the cost of some solution for Ct1C_{t-1}. Applying Lemma 9 with at=𝗅𝖺𝗌𝗍t,bt=Δta_{t}={\mathsf{last}}_{t},b_{t}=\Delta_{t} and Bt=ΦtB_{t}=\Phi_{t} for every tt, the number of times we call 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate} can be bounded by

1+1ϵt=1TΔt𝗅𝖺𝗌𝗍t1ϵO(logT)(ln𝗅𝖺𝗌𝗍T𝗅𝖺𝗌𝗍1+1)=O(logTϵlog1ϵ).\displaystyle 1+\frac{1}{\epsilon^{\prime}}\sum_{t=1}^{T}\frac{\Delta_{t}}{{\mathsf{last}}_{t}}\leq\frac{1}{\epsilon^{\prime}}O(\log T)\left(\ln\frac{{\mathsf{last}}_{T}}{{\mathsf{last}}_{1}}+1\right)=O\left(\frac{\log T}{\epsilon}\log\frac{1}{\epsilon}\right).

We can then analyze the running time and the success probability of our algorithm. Focus on each stage of the algorithm. By Observation 12, each call to 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)\mathsf{FL\mathchar 45\relax iterate}(M) takes time O(M|C|log|F|)=O(|F|ϵ(logΓ)|C|logn)=O(n|CT|ϵlog2n)O(M|C|\log|F|)=O\left(\frac{|F|}{\epsilon^{\prime}}(\log\Gamma)|C|\log n\right)=O\left(\frac{n\cdot|C_{T}|}{\epsilon}\log^{2}n\right), where CC is the set of clients in the algorithm at the time we call the procedure, CTCC_{T}\supseteq C is the number set of clients at the end of time TT, and M=O(|F|ϵlogΓ)M=O\left(\frac{|F|}{\epsilon^{\prime}}\log\Gamma\right) is as defined in Step 2. The total number of times we call the procedure is at most O(logTϵlog1ϵ)O(lognϵlog1ϵ)O\left(\frac{\log T}{\epsilon}\log\frac{1}{\epsilon}\right)\leq O\left(\frac{\log n}{\epsilon}\log\frac{1}{\epsilon}\right). Thus, the running time we spent on 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate} is O(n|CT|ϵ2log3nlog1ϵ)O\left(\frac{n\cdot|C_{T}|}{\epsilon^{2}}\log^{3}n\log\frac{1}{\epsilon}\right). The running time for Steps 5 to 7 is at most TO(log|F|ϵ)O(|CT|log|F|)=O(|CT|Tlog2|F|ϵ)O(n|CT|log2nϵ)T\cdot O\big{(}\log\frac{|F|}{\epsilon^{\prime}}\big{)}\cdot O\big{(}|C_{T}|\log|F|\big{)}=O(|C_{T}|T\log^{2}\frac{|F|}{\epsilon})\leq O(n|C_{T}|\log^{2}\frac{n}{\epsilon}). Thus, the total running time of a stage is at most O(n|CT|ϵ2log3nlog1ϵ)O\left(\frac{n\cdot|C_{T}|}{\epsilon^{2}}\log^{3}n\log\frac{1}{\epsilon}\right). Now consider all the stages together. The sum of |CT||C_{T}| values over all stages is at most 2n2n since every client appears in at most 2 stages. So, the total running time of our algorithm is O(n2ϵ2log3nlog1ϵ)O\left(\frac{n^{2}}{\epsilon^{2}}\log^{3}n\log\frac{1}{\epsilon}\right).

For the success probability, the total number of times we call 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)\mathsf{FL\mathchar 45\relax iterate}(M) is at most O(log1/ϵ(nD)lognϵlog1ϵ)=poly(logn,logD,1ϵ)O\left(\log_{1/\epsilon}(nD)\frac{\log n}{\epsilon}\log\frac{1}{\epsilon}\right)=\mathrm{poly}(\log n,\log D,\frac{1}{\epsilon}). If we have Λ\Lambda is at least n2n^{2} times this number, which is still poly(n,logD,1ϵ)\mathrm{poly}(n,\log D,\frac{1}{\epsilon}), then the success probability of our algorithm is at least 11/n21-1/n^{2}.

Finally, we remark that the success of the algorithm only depends on the success of all executions of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate}. Each execution has success probability 11/Γ1-1/\Gamma even if the adversary is adaptive. This finishes the proof of Theorem 2.

Remark

We can indeed obtain an algorithm that has both O(logT)O(\log T) amortized client recourse and O~(n2)\tilde{O}(n^{2}) total running time, by defining ϕ=𝖼𝗈𝗌𝗍(S,σ)α𝖥𝖫ϵ\phi=\frac{\mathsf{cost}(S,\sigma)}{\alpha_{\mathsf{FL}}\epsilon^{\prime}} and only performing ϕ\phi-efficient local operations. However, this will require us to put ϕ\phi everywhere in our analysis and deteriorate the cleanness of the analysis. Thus, we choose to separate the two features in two algorithms: small recourse and O~(n2)\tilde{O}(n^{2}) total running time.

We also remark that the total running time for all calls of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate} is only O~(n|F|)\tilde{O}(n|F|), and the O~(n2)\tilde{O}(n^{2}) time comes from Steps 5 to 7. By losing a multiplicative factor of 22 and additive factor of 11 in the approximation ratio, we can assume every client is collocated with its nearest facility (See Appendix C). Then at any time we only have O(|F|)O(|F|) different positions for clients, and the running time of the algorithm can be improved to O(n|F|ϵ2log3nlog1ϵ)O(\frac{n|F|}{\epsilon^{2}}\log^{3}n\log\frac{1}{\epsilon}).

6 Fully Dynamic Algorithm for Facility Location on Hierarchically Well Separated Tree Metrics

In this section, we give our fully dynamic algorithm for facility location on hierarchically-well-separated-tree (HST) metrics. Our algorithm achieves O(1)O(1)-approximation and O(log2D)O(\log^{2}D) amortized update time. As we mentioned early, we assume each client is collocated with a facility. From now on, we fix the HST TT and assume the leaves of TT is X=FX=F; let VV be the set of all nodes in TT. Let dTd_{T} be the metric induced by TT over the set VV of vertices.

Notations. Recall that 𝗅𝖾𝗏𝖾𝗅(v){\mathsf{level}}(v) is the level of vv in TT. For every vertex vVv\in V, define Λv\Lambda_{v} to be the set of children of vv, XvX_{v} to be the set of leaf descendants of vv, and TvT_{v} be the maximal sub-tree of TT rooted at vv. We extend the facility cost from XX to all vertices in VV: for every vVXv\in V\setminus X, we define fv=miniXvfif_{v}=\min_{i\in X_{v}}f_{i}. We can assume that each internal vertex vv is a facility; by opening vv we mean opening a copy of the iXvi\in X_{v} with fi=fvf_{i}=f_{v}. This assumption only loses a factor of 22 in the competitive ratio: On one hand, having more facilities can only make our problem easier; on the other hand, the cost of connecting a client to any iXvi\in X_{v} is at most twice that of connecting it to vv. By the definition, the facility costs along a root-to-leaf path are non-decreasing.

6.1 Offline Algorithm for Facility Location on HST Metrics

In this section, we first give an offline O(1)O(1)-approximation algorithm for facility location on the HST metric dTd_{T} as a baseline. Notice that facility location on trees can be solved exactly using dynamic programming. However the algorithm is hard to analyze in the dynamic algorithm model since the solution is sensitive to client arrivals and departures. Our algorithm generalizes the algorithm in [16] for facility location with uniform facility cost, that was used to achieve the differential privacy requirement.

For every vertex vVv\in V, we let NvN_{v} be the number of clients at locations in XvX_{v}. Although according to the definition NvN_{v}’s are integers, in most part of the analysis we assume there are non-negative real numbers. This will be useful when we design the dynamic algorithm. Let α{1,2}V\alpha\in\{1,2\}^{V} and β{1,2}VX\beta\in\{1,2\}^{V\setminus X} be vectors given to our algorithm. They are introduced solely for the purpose of extending the algorithm to the dynamic setting; for the offline algorithm we can set α\alpha and β\beta to be all-1 vectors.

Marked and Open Facilities

For every vertex vVv\in V, we say vv is marked w.r.t the vectors NN and α\alpha if

Nv2𝗅𝖾𝗏𝖾𝗅(v)>fv/αvN_{v}\cdot 2^{{\mathsf{level}}(v)}>f_{v}/\alpha_{v}

and unmarked otherwise. The following observation can be made:

Observation 19.

Let uu be the parent of vv. If vv is marked w.r.t NN and α\alpha, so is uu.

Proof.

vv is marked w.r.t NN and α\alpha implies Nv2𝗅𝖾𝗏𝖾𝗅(v)>fv/αvN_{v}2^{{\mathsf{level}}(v)}>f_{v}/\alpha_{v}. Notice that NuNv,𝗅𝖾𝗏𝖾𝗅(u)=𝗅𝖾𝗏𝖾𝗅(v)+1,αv2αuN_{u}\geq N_{v},{\mathsf{level}}(u)={\mathsf{level}}(v)+1,\alpha_{v}\leq 2\alpha_{u} and fufvf_{u}\leq f_{v}. So, Nu2𝗅𝖾𝗏𝖾𝗅(u)2Nv2𝗅𝖾𝗏𝖾𝗅(v)>2fv/αvfu/αuN_{u}2^{{\mathsf{level}}(u)}\geq 2N_{v}2^{{\mathsf{level}}(v)}>2f_{v}/\alpha_{v}\geq f_{u}/\alpha_{u}. ∎

Thus there is a monotonicity property on the marking status of vertices in TT. We say a vertex vv is highest unmarked (w.r.t NN and α\alpha) if it is unmarked and its parent is marked; we say a vertex vv is lowest marked if it is marked but all its children are unmarked. However, sometimes we say a vertex uu is the lowest marked ancestor of a leaf vXv\in X if either u=vu=v is marked, or uvu\neq v is marked and the child of uu in the uu-vv path is unmarked; notice that in this case, uu might not be a lowest marked vertex since it may have some other marked children. If we need to distinguish between the two cases, we shall use that uu is lowest marked globally to mean uu is a lowest marked vertex.

If a leaf vertex vXv\in X is marked, then we open vv. For every marked vertex vVXv\in V\setminus X, we open vv if and only if

(uΛv:u unmarkedNu)2𝗅𝖾𝗏𝖾𝗅(v)>fv/(αvβv).\left(\sum_{u\in\Lambda_{v}:u\text{ unmarked}}N_{u}\right)2^{{\mathsf{level}}(v)}>f_{v}/(\alpha_{v}\beta_{v}).

Notice that all unmarked vertices are closed.

Observation 20.

If vv is lowest marked, then vv is open.

Proof.

We can assume vXv\notin X since otherwise vv is open. So, Nv2𝗅𝖾𝗏𝖾𝗅(v)>fv/αvN_{v}2^{{\mathsf{level}}(v)}>f_{v}/\alpha_{v} and all children of vv are unmarked. Thus, uΛv:u unmarkedNu=uΛvNu=Nv\sum_{u\in\Lambda_{v}:{u\text{ unmarked}}}N_{u}=\sum_{u\in\Lambda_{v}}N_{u}=N_{v}. Therefore, (uΛv:u unmarkedNu)2𝗅𝖾𝗏𝖾𝗅(v)=Nv2𝗅𝖾𝗏𝖾𝗅(v)>fv/αvfv/(αvβv)\left(\sum_{u\in\Lambda_{v}:{u\text{ unmarked}}}N_{u}\right)2^{{\mathsf{level}}(v)}=N_{v}2^{{\mathsf{level}}(v)}>f_{v}/\alpha_{v}\geq f_{v}/(\alpha_{v}\beta_{v}). Thus vv will be open. ∎

With the set of open facilities defined, every client is connected to its nearest open facility according to dTd_{T}, using a consistent tie-breaking rule (e.g, the nearest open facility with the smallest index). We assume the root rr of TT has fv2𝗅𝖾𝗏𝖾𝗅(v)1\frac{f_{v}}{2^{{\mathsf{level}}(v)}}\leq 1 by increasing the number of levels. So rr will be marked whenever Nr1N_{r}\geq 1. This finishes the description of the offline algorithm.

Analysis of O(1)O(1)-Approximation Ratio.

We show the algorithm achieves an O(1)O(1)-approximation. First we give a lower bound on the optimum cost. For every vVv\in V, let

𝖫𝖡(v)=min{Nv2𝗅𝖾𝗏𝖾𝗅(v),fv}.{\mathsf{LB}}(v)=\min{\left\{N_{v}2^{{\mathsf{level}}(v)},f_{v}\right\}}.

Then we have

Lemma 21.

Let UU be a set of vertices in TT without an ancestor-descendant pair; i.e, for every two distinct vertex uu and vv in UU, uu is not an ancestor of vv. Then the cost of the optimum solution is at least vU𝖫𝖡(v)\sum_{v\in U}{\mathsf{LB}}(v).

Proof.

Fix an optimum solution. Consider any vUv\in U. We consider the cost inside TvT_{v} in the optimum solution: the connection cost of clients, plus the cost of open facilities in TvT_{v}. Then this cost is at least 𝖫𝖡(v)=min{Nv2𝗅𝖾𝗏𝖾𝗅(v),fv}{\mathsf{LB}}(v)=\min{\left\{N_{v}2^{{\mathsf{level}}(v)},f_{v}\right\}}: If we open a facility in TvT_{v} then the facility cost is at least fvf_{v}; otherwise, all the NvN_{v} clients in TvT_{v} have to be connected to outside TvT_{v}, incurring a cost of at least Nv2𝗅𝖾𝗏𝖾𝗅(v)N_{v}2^{{\mathsf{level}}(v)}. The lemma follows from that the trees TvT_{v} over all vUv\in U are disjoint and thus we are not over-counting the costs in the optimum solution. ∎

Then let UU be the set of highest unmarked vertices and marked leaves; clearly UU does not have an ancestor-descendant pair. By Lemma 21, the optimum cost is at least vU𝖫𝖡(v)\sum_{v\in U}{\mathsf{LB}}(v). We prove the following lemma.

Lemma 22.

The solution produced by our algorithm has cost at most O(1)uU𝖫𝖡(u)O(1)\sum_{u\in U}{\mathsf{LB}}(u).

Proof.

First consider the facility cost of our solution. If a leaf vv is marked and open, we have Nv>fv/αvN_{v}>f_{v}/\alpha_{v} (as 𝗅𝖾𝗏𝖾𝗅(v)=0{\mathsf{level}}(v)=0) and thus 𝖫𝖡(v)=min{Nv,fv}fv/αv{\mathsf{LB}}(v)=\min{\left\{N_{v},f_{v}\right\}}\geq f_{v}/\alpha_{v}. Then fvf_{v} can be bounded by αv𝖫𝖡(v)2𝖫𝖡(v)\alpha_{v}{\mathsf{LB}}(v)\leq 2{\mathsf{LB}}(v). If vVXv\in V\setminus X is marked and open, then by our algorithm we have uΛv:u unmarkedNu2𝗅𝖾𝗏𝖾𝗅(v)fv/(αvβv)\sum_{u\in\Lambda_{v}:u\text{ unmarked}}N_{u}2^{{\mathsf{level}}(v)}\geq f_{v}/(\alpha_{v}\beta_{v}). Since each uu in the summation is unmarked, we have 𝖫𝖡(u)=Nu2𝗅𝖾𝗏𝖾𝗅(u){\mathsf{LB}}(u)=N_{u}2^{{\mathsf{level}}(u)}. Thus, we have uΛv:u unmarked𝖫𝖡(u)=12uNu2𝗅𝖾𝗏𝖾𝗅(v)12fv/(αvβv)18fv\sum_{u\in\Lambda_{v}:u\text{ unmarked}}{\mathsf{LB}}(u)=\frac{1}{2}\sum_{u}N_{u}2^{{\mathsf{level}}(v)}\geq\frac{1}{2}f_{v}/(\alpha_{v}\beta_{v})\geq\frac{1}{8}f_{v}. That is fvf_{v} can be bounded by 8uΛv:u unmarked𝖫𝖡(u)8\sum_{u\in\Lambda_{v}:u\text{ unmarked}}{\mathsf{LB}}(u). Notice that each uu in the summation has uUu\in U since it is highest unmarked. So, summing the bounds over all open facilities vv gives us that the facility cost of our solution is at most 8uU𝖫𝖡(u)8\sum_{u\in U}{\mathsf{LB}}(u).

Now consider the connection cost. For every vXv\in X, let uu be the highest unmarked ancestor of vv (if vv itself is open, then its connection cost is 0 and we do not need to consider this case). Let ww be the parent of uu; so ww is marked. Then there must be an open facility in the maximal tree rooted at ww: consider any lowest marked vertex in the sub-tree rooted at ww; it must be open by Lemma 20. Thus, any client at vv has connection cost at most 2×2𝗅𝖾𝗏𝖾𝗅(w)=4×2𝗅𝖾𝗏𝖾𝗅(u)2\times 2^{{\mathsf{level}}(w)}=4\times 2^{{\mathsf{level}}(u)}. Thus, the total connection cost in our solution is at most 4uUXNu2𝗅𝖾𝗏𝖾𝗅(u)=4uUX𝖫𝖡(u)4\sum_{u\in U\setminus X}N_{u}2^{{\mathsf{level}}(u)}=4\sum_{u\in U\setminus X}{\mathsf{LB}}(u). This finishes the proof of the lemma. ∎

Combining Lemmas 21 and 22 gives that our algorithm is an O(1)O(1)-approximation. One lemma that will be useful in the analysis of dynamic algorithm is the following:

Lemma 23.

For any open facility vv in our solution, the number of clients connected to vv that are outside TvT_{v} is at most O(logD)fv2𝗅𝖾𝗏𝖾𝗅(v)O(\log D)\frac{f_{v}}{2^{{\mathsf{level}}(v)}}.

Proof.

We consider each ancestor uu of vv and count the number clients connected to vv with lowest common ancestor with vv being uu. Focus on a child ww of uu that is not vv or an ancestor of vv. If ww is marked, then no clients in TwT_{w} will be connected to vv since some facility in TwT_{w} will be open. Thus, let UU^{\prime} be the unmarked children of uu that is not vv or an ancestor of vv. Then if we have wUNw2𝗅𝖾𝗏𝖾𝗅(u)fu/(αuβu)\sum_{w\in U^{\prime}}N_{w}2^{{\mathsf{level}}(u)}\geq f_{u}/(\alpha_{u}\beta_{u}), then uu will be marked and open and clients in Tw,wUT_{w},w\in U^{\prime} will not be connected to vv. Otherwise we have wUNw<fu/(αuβu2𝗅𝖾𝗏𝖾𝗅(u))fu/2𝗅𝖾𝗏𝖾𝗅(u)fv/2𝗅𝖾𝗏𝖾𝗅(v)\sum_{w\in U^{\prime}}N_{w}<f_{u}/(\alpha_{u}\beta_{u}\cdot 2^{{\mathsf{level}}(u)})\leq f_{u}/2^{{\mathsf{level}}(u)}\leq f_{v}/2^{{\mathsf{level}}(v)} as fufvf_{u}\leq f_{v} and 𝗅𝖾𝗏𝖾𝗅(u)𝗅𝖾𝗏𝖾𝗅(v){\mathsf{level}}(u)\geq{\mathsf{level}}(v). The lemma follows since we have at most O(logD)O(\log D) ancestors of vv. ∎

Remark

The algorithm so far gives a data structure that supports the following operations in O(logD)O(\log D) time: i) updating NvN_{v} for some vXv\in X and ii) returning the nearest open facility of a leaf vXv\in X. Indeed the algorithm can be made simpler: We set α\alpha to be the all-1 vector, and we open the set of lowest marked facilities (so both α\alpha and β\beta are not needed). For every vertex uVu\in V, we maintain the nearest open facility ψu\psi_{u} to uu in TuT_{u}. Whenever a client at vv arrives or departs, we only need change NuN_{u}, ψu\psi_{u}, marking and opening status of uu for ancestors uu of vv. To return the closest open facility to a leaf vXv\in X, we travel up the tree from vv until we find an ancestor uu with ψu\psi_{u} defined, and return ψu\psi_{u}. Both operations take O(logD)O(\log D) time. However, our goal is to maintain the solution (S,σ)(S,\sigma) explicitly in memory. Thus we also have to bound the the number of reconnections during the algorithm, since that will be a lower bound on the total running time.

6.2 Dynamic Algorithm for Facility Location on HST Metrics

In this section, we extend the offline algorithm to a dynamic algorithm with O(log3D)O(\log^{3}D)-amortized update time; recall that DD is the aspect ratio of the metric. We maintain α,β\alpha,\beta and NN-vectors, and at any moment of the algorithm, the marking and opening status of vertices are exactly the same as that obtained from the offline algorithm for α,β\alpha,\beta and NN.

Initially, let α\alpha and β\beta be all-11 vectors, and NN be the all-0 vector. So all the vertices are unmarked. Whenever a client at some vXv\in X arrives or departs, the α,β\alpha,\beta values, the marking and opening status of ancestors of vv may change and we show how to handle the changes. The vertices that are not ancestors of vv are not affected during the process.

When a client at vv arrives or departs, we increase or decrease the NuN_{u} values for all ancestors uu of vv by 1 continuously at the same rate (we can think of that the number of clients at vv increases or decreases by 1 continuously). During the process, the marking and opening status of these vertices may change. If such an event happens, we change α\alpha and/or β\beta values of the vertex so that it becomes harder for the status to change back in the future. Specifically, we use the following rules:

  • If a vertex uu changes to marked (from being unmarked), then we change αu\alpha_{u} to 22 (notice that uu remains marked w.r.t the new α\alpha), and βu\beta_{u} to 11. In this case, we do not consider the opening status change of uu as an event.

  • If a vertex uu changes to unmarked (from being marked), we change αu\alpha_{u} to 11 (notice that uu remains unmarked w.r.t the new α\alpha). The βu\beta_{u} value becomes useless. In this case, we also do not consider the opening status change of uu as an event.

  • If a marked vertex uu becomes open (from being closed), then we change βu\beta_{u} to 22 (notice that uu remains open w.r.t the new β\beta).

  • If a marked vertex uu becomes closed (from being open), then we change βu\beta_{u} to 11 (notice that uu remains closed w.r.t the new β\beta).

We call the 4 types of events above as marking, unmarking, opening and closing events.

Now we talk about the order the events happen. When we increase NuN_{u} values of ancestors of vv continuously, one of the following two events may happen:

  • The highest unmarked ancestor uu of vv may become globally lowest marked, and this may induce a closing event for the parent ww of uu.

  • The lowest marked ancestor uu of vv may become open.

Similarly, when we decrease NuN_{u} values of ancestors of vv continuously, one of the following two events may happen:

  • The lowest marked ancestor uu of vv may become unmarked (we must that uu was lowest marked globally), and this may induce an opening event for the parent ww of uu.

  • The lowest marked ancestor uu of vv may become closed.

Above, if two events happen at the same time, we handle an arbitrary event. Notice that after we handle the event, the conditions for the other event might not hold any more, in which case we do not handle it.

Once we have finished the process of increasing or decreasing NuN_{u} values by 1, the clients will be connected to their respective nearest open facilities, breaking ties using the consistent rule. A reconnection happens if a client is connected to a different facility.

Bounding Number of Reconnections

Now we analyze the reconnections made in the algorithm. When a client at vXv\in X arrives or departs, at most O(logD)O(\log D) vertices uu will have their NuN_{u} values changed by 11. We distribute 4 tokens to each ancestor uu of vv, that are of type-A, type-B, type-C and type-D respectively.444The types are only defined for convenience. We are going to use these tokens to charge the events happened.

First focus on the sequence of marking/unmarking events happened at a vertex uu. Right before uu becomes unmarked we have Nufu/(2×2𝗅𝖾𝗏𝖾𝗅(u))N_{u}\leq f_{u}/(2\times 2^{{\mathsf{level}}(u)}) since at the moment we have αu=2\alpha_{u}=2. Immediate after that αu\alpha_{u} is changed to 11. For uu to become marked again, we need Nufu/2𝗅𝖾𝗏𝖾𝗅(u)N_{u}\leq f_{u}/2^{{\mathsf{level}}(u)}. So during the period NuN_{u} must have been increased by at least fu/(2×2𝗅𝖾𝗏𝖾𝗅(u))f_{u}/(2\times 2^{{\mathsf{level}}(u)}). Similarly, right before uu becomes marked we have Nufu/2𝗅𝖾𝗏𝖾𝗅(u)N_{u}\geq f_{u}/2^{{\mathsf{level}}(u)} since at the moment we have αu=1\alpha_{u}=1. Then we change αu\alpha_{u} to 22 immediately. For uu to become unmarked again, NuN_{u} should be decreased by at least fu/(2×2𝗅𝖾𝗏𝖾𝗅(u))f_{u}/(2\times 2^{{\mathsf{level}}(u)}). So, when a marking/unmarking event happens at uu, we can spend Ω(fu/2𝗅𝖾𝗏𝖾𝗅(u))\Omega(f_{u}/2^{{\mathsf{level}}(u)}) type-A tokens owned by uu.

Then we focus on the sequence 𝒮\mathcal{S} of opening/closing events at uu between two adjacent marking/unmarking events at uu. At these moments, uu is marked and αu=2\alpha_{u}=2. For the first event in 𝒮\mathcal{S}, we can spend Ω(fu/2𝗅𝖾𝗏𝖾𝗅(u))\Omega(f_{u}/2^{{\mathsf{level}}(u)}) type-B tokens owned by uu. If some opening/closing event ee in 𝒮\mathcal{S} is induced by an unmarking/marking event of some child uu^{\prime} of uu, then we can spend Ω(fu/2𝗅𝖾𝗏𝖾𝗅(u))Ω(fu/2𝗅𝖾𝗏𝖾𝗅(u))\Omega(f_{u^{\prime}}/2^{{\mathsf{level}}(u^{\prime})})\geq\Omega(f_{u}/2^{{\mathsf{level}}(u)}) type-C tokens owned by uu^{\prime} for ee, and the event ee^{\prime} after ee in 𝒮\mathcal{S} if it exists. Notice that we already argued that uu^{\prime} has collected enough number of type-C tokens.

Then we focus on an event ee^{\prime} in 𝒮\mathcal{S} such that both ee and the event ee before ee^{\prime} in 𝒮\mathcal{S} are not induced. First, assume ee is an opening event and ee^{\prime} is a closing event. Then, after ee we have uΛu:u unmarkedNu=fu/(2×2𝗅𝖾𝗏𝖾𝗅(u))\sum_{u^{\prime}\in\Lambda_{u}:u^{\prime}\text{ unmarked}}N_{u^{\prime}}=f_{u}/(2\times 2^{{\mathsf{level}}(u)}) and before ee^{\prime} we have uΛu:u unmarkedNu=fu/(4×2𝗅𝖾𝗏𝖾𝗅(u))\sum_{u^{\prime}\in\Lambda_{u}:u^{\prime}\text{ unmarked}}N_{u^{\prime}}=f_{u}/(4\times 2^{{\mathsf{level}}(u)}). Notice that the set of unmarked children of uu may change, and let UU^{\prime} and U′′U^{\prime\prime} be the sets of unmarked children of uu at the moments after ee and before ee^{\prime} respectively. Again if there is some u(UU′′)(U′′U)u^{\prime}\in(U^{\prime}\setminus U^{\prime\prime})\cup(U^{\prime\prime}\setminus U^{\prime}), we spend Ω(fu2𝗅𝖾𝗏𝖾𝗅(u))Ω(fu2𝗅𝖾𝗏𝖾𝗅(u))\Omega(\frac{f_{u^{\prime}}}{2^{{\mathsf{level}}(u^{\prime})}})\geq\Omega(\frac{f_{u}}{2^{{\mathsf{level}}(u)}}) type-C tokens owned by uu^{\prime}. Otherwise, U=UU=U^{\prime} and fu/(4×2(𝗅𝖾𝗏𝖾𝗅(u)))f_{u}/(4\times 2^{({\mathsf{level}}(u))}) clients in TuT_{u} must have departed between ee and ee^{\prime} and we can then spend Ω(fu/2𝗅𝖾𝗏𝖾𝗅(u))\Omega(f_{u}/2^{{\mathsf{level}}(u)}) type-D tokens for ee^{\prime}. The case when ee is an closing event and ee^{\prime} is an opening event can be argued in the same way.

Thus, whenever an event happens at uu, we can spend Ω(fu/2𝗅𝖾𝗏𝖾𝗅(u))\Omega(f_{u}/2^{{\mathsf{level}}(u)}) tokens; moreover if an opening/closing event at uu was induced by an unmarking/marking event at some child uu^{\prime} of uu, then we can spend Ω(fu/2𝗅𝖾𝗏𝖾𝗅(u))\Omega(f_{u^{\prime}}/2^{{\mathsf{level}}(u^{\prime})}) tokens for the event at uu. A facility uu changes its opening status when an event happens at uu. Notice that, we reconnect a client only if it was connected to a ready-to-close facility, or it needs to be connected to newly open facility. By Lemma 23, at any moment the number of clients connected to uu from outside TuT_{u} is at most O(logD)fu2𝗅𝖾𝗏𝖾𝗅(u)O(\log D)\cdot\frac{f_{u}}{2^{{\mathsf{level}}(u)}}. At the moment uu changes its opening status because of an non-induced event, then before and after the event the number of clients connected to uu from TuT_{u} is of order O(fu2𝗅𝖾𝗏𝖾𝗅(u))O\left(\frac{f_{u}}{2^{{\mathsf{level}}(u)}}\right). uu changes its opening status due to a marking/unmarking event happened at some child uu^{\prime} of uu, then before and after the event the number of clients connected to uu from TuT_{u} is of order Θ(fu2𝗅𝖾𝗏𝖾𝗅(u))\Theta\left(\frac{f_{u^{\prime}}}{2^{{\mathsf{level}}(u^{\prime})}}\right). Thus, on average, for each token we spent we connect at most O(logD)O(\log D) clients. Since each client arrival or departure distributes at most O(logD)O(\log D) tokens, we have that the amortized number of reconnections (per client arrival/departure) is at most O(log2D)O(\log^{2}D).

Analyzing Update Time

Then with the bound on the number of reconnections (recourse), we can bound the update time easily. Indeed, we can maintain a ψu\psi_{u} for every uVu\in V, which indicates the nearest open facility to uu in TuuT_{u}\setminus u (ψu\psi_{u} could be undefined). We also maintain a value NuN^{\prime}_{u} for marked vertices uu where Nu=vΛv,v unmarkedNvN^{\prime}_{u}=\sum_{v\in\Lambda_{v},v\text{ unmarked}}N_{v}. Whenever a client at vv arrives or departs, we need to change αu,βu,Nu,Nu,ψu\alpha_{u},\beta_{u},N_{u},N^{\prime}_{u},\psi_{u}, marking and opening status of uu only for ancestors uu of vv. The update can be made in O(logD)O(\log D) time for every client arrival or departure using the information on the vertices. The bottleneck of the algorithm comes from reconnecting clients. We already argued that the amortized number of reconnections per client arrival/departure is O(log2D)O(\log^{2}D) and thus it suffices to give an algorithm that can find the clients to be connected efficiently.

For every vertex uu, we maintain a double-linked-list of unmarked children uu^{\prime} of uu with Nu1N_{u^{\prime}}\geq 1. With this structure it is easy to see that for every client that needs to be reconnected, we need O(logD)O(\log D) time to locate it. If uu becomes open, we need to consider each unmarked children uu^{\prime} of uu and reconnect clients in TuT_{u^{\prime}} to uu. The time needed to locate these clients can be made O(logD)O(\log D) times the number of clients. For every strict ancestor ww of uu for which there are no open facilities in between we can use the ψw\psi_{w} information to see if we need to reconnect clients in TwT_{w}. If yes, then for every unmarked child ww^{\prime} of ww with Nw1N_{w^{\prime}}\geq 1 that is not an ancestor of uu, we need to connect the clients in TwT_{w^{\prime}} to uu. Again enumerating these clients takes time O(logD)O(\log D) times the number of clients. Similarly, if uu becomes closed, we then need to connect all clients connected to uu to the nearest open facility to uu, which can be computed using ψ\psi values of uu and its ancestors. Enumerating the clients takes time O(logD)O(\log D) times the number of clients. Overall, the amortized running time per client arrival/departure is O(log3D)O(\log^{3}D).

7 Open Problems and Discussions

We initiated the study of facility location problem in general metric spaces in recourse and dynamic models. Several interesting problems remain open: The most obvious one is can we get O(1)O(1)-competitive online/dynamic algorithms with polylog amortized recourse or fast update times in the fully dynamic setting. Another interesting direction is can we extend our results to the capacitated facility location and capacitated kk-median, where there is an upper bound on the number of clients that can be assigned to a single open facility. From technical point of view, it would be interesting to find more applications of local search and probabilistic tree embedding techniques in the dynamic algorithms model. Finally, as alluded in the introduction, an exciting research direction is to understand the power of recourse in the online model.

References

  • [1] Hyung-Chan An, Ashkan Norouzi-Fard, and Ola Svensson. Dynamic facility location via exponential clocks. In Proceedings of the Twenty-Sixth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2015, San Diego, CA, USA, January 4-6, 2015, pages 708–721, 2015.
  • [2] Aris Anagnostopoulos, Russell Bent, Eli Upfal, and Pascal Van Hentenryck. A simple and deterministic competitive algorithm for online facility location. Inf. Comput., 194(2):175–202, November 2004.
  • [3] Vijay Arya, Naveen Garg, Rohit Khandekar, Adam Meyerson, Kamesh Munagala, and Vinayaka Pandit. Local search heuristic for k-median and facility location problems. In Proceedings on 33rd Annual ACM Symposium on Theory of Computing, July 6-8, 2001, Heraklion, Crete, Greece, pages 21–29, 2001.
  • [4] Y. Bartal. Probabilistic approximation of metric spaces and its algorithmic applications. In Proceedings of the 37th Annual Symposium on Foundations of Computer Science, FOCS ’96, pages 184–, Washington, DC, USA, 1996. IEEE Computer Society.
  • [5] Yair Bartal, Avrim Blum, Carl Burch, and Andrew Tomkins. A polylog(n)-competitive algorithm for metrical task systems. In Proceedings of the Twenty-Ninth Annual ACM Symposium on the Theory of Computing, El Paso, Texas, USA, May 4-6, 1997, pages 711–719, 1997.
  • [6] Aaron Bernstein, Jacob Holm, and Eva Rotenberg. Online bipartite matching with amortized O(log 2{}^{\mbox{2}} n) replacements. J. ACM, 66(5):37:1–37:23, 2019.
  • [7] Guy E. Blelloch, Yan Gu, and Yihan Sun. Efficient construction of probabilistic tree embeddings. In 44th International Colloquium on Automata, Languages, and Programming, ICALP 2017, July 10-14, 2017, Warsaw, Poland, pages 26:1–26:14, 2017.
  • [8] Sébastien Bubeck, Michael B. Cohen, Yin Tat Lee, James R. Lee, and Aleksander Madry. k-server via multiscale entropic regularization. In Proceedings of the 50th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2018, Los Angeles, CA, USA, June 25-29, 2018, pages 3–16, 2018.
  • [9] Moses Charikar, Chandra Chekuri, Tomás Feder, and Rajeev Motwani. Incremental clustering and dynamic information retrieval. In Proceedings of the Twenty-ninth Annual ACM Symposium on Theory of Computing, STOC ’97, pages 626–635, New York, NY, USA, 1997. ACM.
  • [10] Moses Charikar and Sudipto Guha. Improved combinatorial algorithms for facility location problems. SIAM J. Comput., 34(4):803–824, April 2005.
  • [11] Vincent Cohen-Addad, Niklas Hjuler, Nikos Parotsidis, David Saulpic, and Chris Schwiegelshohn. Fully dynamic consistent facility location. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alché-Buc, Emily B. Fox, and Roman Garnett, editors, Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, 8-14 December 2019, Vancouver, BC, Canada, pages 3250–3260, 2019.
  • [12] Marek Cygan, Artur Czumaj, Marcin Mucha, and Piotr Sankowski. Online facility location with deletions. In 26th Annual European Symposium on Algorithms, ESA 2018, August 20-22, 2018, Helsinki, Finland, pages 21:1–21:15, 2018.
  • [13] Artur Czumaj, Christiane Lammersen, Morteza Monemizadeh, and Christian Sohler. (1 + epsilon)-approximation for facility location in data streams. In Proceedings of the Twenty-fourth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA ’13, pages 1710–1728, Philadelphia, PA, USA, 2013. Society for Industrial and Applied Mathematics.
  • [14] Gabriella Divéki and Csanád Imreh. Online facility location with facility movements. Central European Journal of Operations Research, 19(2):191–200, Jun 2011.
  • [15] David Eisenstat, Claire Mathieu, and Nicolas Schabanel. Facility location in evolving metrics. In Javier Esparza, Pierre Fraigniaud, Thore Husfeldt, and Elias Koutsoupias, editors, Automata, Languages, and Programming, pages 459–470, Berlin, Heidelberg, 2014. Springer Berlin Heidelberg.
  • [16] Yunus Esencayi, Marco Gaboardi, Shi Li, and Di Wang. Facility location problem in differential privacy model revisited. CoRR, abs/1910.12050, 2019.
  • [17] Jittat Fakcharoenphol, Satish Rao, Satish Rao, and Kunal Talwar. A tight bound on approximating arbitrary metrics by tree metrics. In Proceedings of the Thirty-fifth Annual ACM Symposium on Theory of Computing, STOC ’03, pages 448–455, New York, NY, USA, 2003. ACM.
  • [18] Reza Zanjirani Farahani, Maryam Abedian, and Sara Sharahi. Dynamic Facility Location Problem, pages 347–372. Physica-Verlag HD, Heidelberg, 2009.
  • [19] Dimitris Fotakis. Incremental algorithms for facility location and k-median. Theor. Comput. Sci., 361(2-3):275–313, 2006.
  • [20] Dimitris Fotakis. A primal-dual algorithm for online non-uniform facility location. J. of Discrete Algorithms, 5(1):141–148, March 2007.
  • [21] Dimitris Fotakis. On the competitive ratio for online facility location. Algorithmica, 50(1):1–57, 2008.
  • [22] Dimitris Fotakis. Memoryless facility location in one pass. ACM Trans. Algorithms, 7(4):49:1–49:24, 2011.
  • [23] Dimitris Fotakis. Online and incremental algorithms for facility location. SIGACT News, 42(1):97–131, March 2011.
  • [24] Dimitris Fotakis and Christos Tzamos. On the power of deterministic mechanisms for facility location games. In Automata, Languages, and Programming - 40th International Colloquium, ICALP 2013, Riga, Latvia, July 8-12, 2013, Proceedings, Part I, pages 449–460, 2013.
  • [25] Dimitris Fotakis and Christos Tzamos. Winner-imposing strategyproof mechanisms for multiple facility location games. Theor. Comput. Sci., 472:90–103, 2013.
  • [26] Monia Ghobadi, Ratul Mahajan, Amar Phanishayee, Nikhil R. Devanur, Janardhan Kulkarni, Gireeja Ranade, Pierre-Alexandre Blanche, Houman Rastegarfar, Madeleine Glick, and Daniel C. Kilper. Projector: Agile reconfigurable data center interconnect. In Proceedings of the ACM SIGCOMM 2016 Conference, Florianopolis, Brazil, August 22-26, 2016, pages 216–229, 2016.
  • [27] Gramoz Goranci, Monika Henzinger, and Dariusz Leniowski. A tree structure for dynamic facility location. In 26th Annual European Symposium on Algorithms, ESA 2018, August 20-22, 2018, Helsinki, Finland, pages 39:1–39:13, 2018.
  • [28] Sudipto Guha and Samir Khuller. Greedy strikes back: Improved facility location algorithms. In Proceedings of the Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA ’98, pages 649–657, Philadelphia, PA, USA, 1998. Society for Industrial and Applied Mathematics.
  • [29] Anupam Gupta, Ravishankar Krishnaswamy, Amit Kumar, and Debmalya Panigrahi. Online and dynamic algorithms for set cover. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2017, Montreal, QC, Canada, June 19-23, 2017, pages 537–550, 2017.
  • [30] Anupam Gupta and Amit Kumar. Greedy algorithms for steiner forest. In Proceedings of the Forty-Seventh Annual ACM on Symposium on Theory of Computing, STOC 2015, Portland, OR, USA, June 14-17, 2015, pages 871–878, 2015.
  • [31] Anupam Gupta, Amit Kumar, and Cliff Stein. Maintaining assignments online: Matching, scheduling, and flows. In Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014, pages 468–479, 2014.
  • [32] Piotr Indyk. Algorithms for dynamic geometric problems over data streams. In Proceedings of the Thirty-sixth Annual ACM Symposium on Theory of Computing, STOC ’04, pages 373–380, New York, NY, USA, 2004. ACM.
  • [33] Christiane Lammersen and Christian Sohler. Facility location in dynamic geometric data streams. In Dan Halperin and Kurt Mehlhorn, editors, Algorithms - ESA 2008, pages 660–671, Berlin, Heidelberg, 2008. Springer Berlin Heidelberg.
  • [34] Shi Li. A 1.488 approximation algorithm for the uncapacitated facility location problem. Inf. Comput., 222:45–58, 2013.
  • [35] A. Meyerson. Online facility location. In Proceedings of the 42Nd IEEE Symposium on Foundations of Computer Science, FOCS ’01, pages 426–, Washington, DC, USA, 2001. IEEE Computer Society.
  • [36] Kamesh Munagala. Local search for k-medians and facility location. In Encyclopedia of Algorithms, pages 1139–1143. 2016.
  • [37] Seeun Umboh. Online network design algorithms via hierarchical decompositions. In Proceedings of the Twenty-Sixth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2015, San Diego, CA, USA, January 4-6, 2015, pages 1373–1387, 2015.
  • [38] Adrian Vetta. Nash equilibria in competitive societies, with applications to facility location, traffic routing and auctions. In Proceedings of the 43rd Symposium on Foundations of Computer Science, FOCS ’02, pages 416–, Washington, DC, USA, 2002. IEEE Computer Society.
  • [39] George O. Wesolowsky. Dynamic facility location. Manage. Sci., 19(11):1241–1248, July 1973.
  • [40] David P. Williamson and David B. Shmoys. The Design of Approximation Algorithms. Cambridge University Press, New York, NY, USA, 1st edition, 2011.

Appendix A Analysis of Offline Local Search Algorithms for Facility Location

In this section, we prove theorems related to the local search algorithms for facility location.

A.1 Local Search for facility location

See 7

Proof.

This proof is almost identical to the analysis of the αFL\alpha_{F}L-approximation local search algorithm for facility location, except we take ϕ\phi into consideration in all the inequalities. Eventually we shall have an αFL|C|ϕ\alpha_{F}L|C|\phi term on the right side of the inequality.

Formally, we let (S,σ)(S^{*},\sigma^{*}) be the optimum solution to facility location instance. Focus on an iSi^{*}\in S^{*}. Since there is no ϕ\phi-efficient operation that opens ii^{*} (recall that we can open ii^{*} even if we have iSi\in S^{*}), we have

jσ1(i)d(j,σj)λfi1iS+jσ1(i)(d(j,i)+ϕ).\displaystyle\sum_{j\in\sigma^{*-1}(i^{*})}d(j,\sigma_{j})\leq\lambda f_{i^{*}}\cdot 1_{i^{*}\notin S}+\sum_{j\in\sigma^{*-1}(i^{*})}(d(j,i^{*})+\phi).

This implies

jσ1(i)d(j,σj)λfi+jσ1(i)d(j,i)+|σ1(i)|ϕ.\displaystyle\sum_{j\in\sigma^{*-1}(i^{*})}d(j,\sigma_{j})\leq\lambda f_{i^{*}}+\sum_{j\in\sigma^{*-1}(i^{*})}d(j,i^{*})+|\sigma^{*-1}(i^{*})|\phi. (2)

Summing the inequalities over all iSi^{*}\in S^{*} gives us

𝖼𝖼(σ)λf(S)+𝖼𝖼(σ)+|C|ϕ.\displaystyle\mathsf{cc}(\sigma)\leq\lambda f(S^{*})+\mathsf{cc}(\sigma^{*})+|C|\phi. (3)

For every iSi\in S, let ψ(i)\psi(i) be the nearest facility in SS^{*} to ii. For every iSi^{*}\in S^{*} with ψ1(i)\psi^{-1}(i^{*})\neq\emptyset, let ψ(i)\psi^{*}(i^{*}) be the nearest facility in ψ1(i)\psi^{-1}(i^{*}) to ii^{*}.

Focus on some iS,i=ψ(i)i\in S,i^{*}=\psi(i) such that ψ(i)=i\psi^{*}(i^{*})=i. The operation that swaps in ii^{*}, swaps out ii and connects σ1(i)σ1(i)\sigma^{*-1}(i^{*})\cup\sigma^{-1}(i) to ii^{*} is not ϕ\phi-efficient. This implies

λfi+jσ1(i)σ1(i)d(j,σj)\displaystyle\quad\lambda f_{i}+\sum_{j\in\sigma^{*-1}(i^{*})\cup\sigma^{-1}(i)}d(j,\sigma_{j})
λfi+jσ1(i)d(j,i)+jσ1(i)σ1(i)d(j,i)+|σ1(i)σ1(i)|ϕ\displaystyle\leq\lambda f_{i^{*}}+\sum_{j\in\sigma^{*-1}(i^{*})}d(j,i^{*})+\sum_{j\in\sigma^{-1}(i)\setminus\sigma^{*-1}(i^{*})}d(j,i^{*})+\big{|}\sigma^{*-1}(i^{*})\cup\sigma^{-1}(i)\big{|}\phi
λfi+jσ1(i)d(j,i)+jσ1(i)σ1(i)[d(j,σ(j))+2d(j,i)]+|σ1(i)σ1(i)|ϕ.\displaystyle\leq\lambda f_{i^{*}}+\sum_{j\in\sigma^{*-1}(i^{*})}d(j,i^{*})+\sum_{j\in\sigma^{-1}(i)\setminus\sigma^{*-1}(i^{*})}[d(j,\sigma^{*}(j))+2d(j,i)]+\big{|}\sigma^{*-1}(i^{*})\cup\sigma^{-1}(i)\big{|}\phi.

To see the second inequality, notice that d(j,i)d(j,i)+d(i,i)d(j,i)+d(i,σ(j))2d(j,i)+d(j,σ(j))d(j,i^{*})\leq d(j,i)+d(i,i^{*})\leq d(j,i)+d(i,\sigma^{*}(j))\leq 2d(j,i)+d(j,\sigma^{*}(j)). Canceling jσ1(i)σ1(i)d(j,i)\sum_{j\in\sigma^{-1}(i)\setminus\sigma^{*-1}(i^{*})}d(j,i) on both sides and relaxing the right side a bit gives us

λfi+jσ1(i)d(j,σj)\displaystyle\quad\lambda f_{i}+\sum_{j\in\sigma^{*-1}(i^{*})}d(j,\sigma_{j}) λfi+jσ1(i)d(j,i)+|σ1(i)σ1(i)|ϕ\displaystyle\leq\lambda f_{i^{*}}+\sum_{j\in\sigma^{*-1}(i^{*})}d(j,i^{*})+\big{|}\sigma^{*-1}(i^{*})\cup\sigma^{-1}(i)\big{|}\phi
+jσ1(i)(d(j,i)+d(j,σ(j)))).\displaystyle+\sum_{j\in\sigma^{-1}(i)}\left(d(j,i)+d(j,\sigma^{*}(j)))\right). (4)

Notice that it could happen that i=ii=i^{*} in the above setting; the inequality was implied by the operation that opens i=ii=i^{*} and connects σ1(i=i)\sigma^{*-1}(i^{*}=i) to ii.

Now, focus on a iSi\in S with ψ(ψ(i))i\psi^{*}(\psi(i))\neq i. Then closing ii and connecting each client in jσ1(i)j\in\sigma^{-1}(i) to ψ(σ(j))i\psi^{*}(\sigma^{*}(j))\neq i is not ϕ\phi-efficient. So, we have

λfi+jσ1(i)d(j,i)\displaystyle\lambda f_{i}+\sum_{j\in\sigma^{-1}(i)}d(j,i) λfi+jσ1(i)d(j,ψ(σ(j)))+|σ1(i)|ϕ\displaystyle\leq\lambda f_{i}+\sum_{j\in\sigma^{-1}(i)}d(j,\psi^{*}(\sigma^{*}(j)))+\big{|}\sigma^{-1}(i)\big{|}\phi
jσ1(i)[2d(j,σ(j))+d(j,i)]+|σ1(i)|ϕ.\displaystyle\leq\sum_{j\in\sigma^{-1}(i)}[2d(j,\sigma^{*}(j))+d(j,i)]+\big{|}\sigma^{-1}(i)\big{|}\phi.

To see the inequality, we have d(j,ψ(σ(j)))d(j,σ(j))+d(σ(j),ψ(σ(j)))d(j,σ(j))+d(σ(j),i)2d(j,σ(j))+d(j,i)d(j,\psi^{*}(\sigma^{*}(j)))\leq d(j,\sigma^{*}(j))+d(\sigma^{*}(j),\psi(\sigma^{*}(j)))\leq d(j,\sigma^{*}(j))+d(\sigma^{*}(j),i)\leq 2d(j,\sigma^{*}(j))+d(j,i). This implies

λfi2jσ1(i)d(j,σ(j))+|σ1(i)|ϕ.\displaystyle\lambda f_{i}\leq 2\sum_{j\in\sigma^{-1}(i)}d(j,\sigma^{*}(j))+\big{|}\sigma^{-1}(i)\big{|}\phi. (5)

Now, consider the inequality obtained by summing up (4) for all pairs (i,i)(i,i^{*}) with i=ψ(i)i^{*}=\psi(i) and ψ(i)=i\psi^{*}(i^{*})=i, (5) for all ii with ψ(ψ(i))i\psi^{*}(\psi(i))\neq i, and (2) for all ii^{*} with ψ1(i)=\psi^{-1}(i^{*})=\emptyset. This inequality will be λf(S)+𝖼𝖼(σ)λf(S)+2𝖼𝖼(σ)+𝖼𝖼(σ)+2|C|ϕ\lambda f(S)+\mathsf{cc}(\sigma)\leq\lambda f(S^{*})+2\mathsf{cc}(\sigma^{*})+\mathsf{cc}(\sigma)+2|C|\phi, which is

λf(S)λf(S)+2𝖼𝖼(σ)+2|C|ϕ.\displaystyle\lambda f(S)\leq\lambda f(S^{*})+2\mathsf{cc}(\sigma^{*})+2|C|\phi. (6)

Summing up Inequalities (3) and 1/λ1/\lambda times (6) gives f(S)+𝖼𝖼(σ)(1+λ)f(S)+(1+2/λ)(𝖼𝖼(σ)+|C|ϕ)=αFL(𝗈𝗉𝗍+|C|ϕ)f(S)+\mathsf{cc}(\sigma)\leq(1+\lambda)f(S^{*})+(1+2/\lambda)\left(\mathsf{cc}(\sigma^{*})+|C|\phi\right)=\alpha_{F}L\left(\mathsf{opt}+|C|\phi\right), since 1+λ=1+2/λ=1+2=αFL1+\lambda=1+2/\lambda=1+\sqrt{2}=\alpha_{F}L. This finishes the proof of Theorem 7. ∎

See 8

The theorem follows from the proof of Theorem 7. Let ϕ=0\phi=0 in the theorem statement and the proof. (3) and (6) were obtained by adding many of the inequalities of the form (2), (4) and (5). Notice that each inequality corresponds to a local operation. In the setting for Theorem 8, the inequalities do not hold anymore since we do not have the condition that 0-efficient operations do not exist. However for an inequality correspondent to an operation op, we can add op\nabla_{\text{op}} to the right side so that the inequality becomes satisfied. Then adding all the inequalities that were used to obtain (3), we obtain

𝖼𝖼(σ)λf(S)+𝖼𝖼(σ)+op𝒫Cop\displaystyle\mathsf{cc}(\sigma)\leq\lambda f(S^{*})+\mathsf{cc}(\sigma^{*})+\sum_{\textrm{op}\in{\mathcal{P}}_{\mathrm{C}}}\nabla_{\textrm{op}}

where 𝒫C{\mathcal{P}}_{\mathrm{C}} is the set of operations correspondent to the inequalities. Similarly we can obtain a set 𝒫F{\mathcal{P}}_{\mathrm{F}} of operations, such that

λf(S)λf(S)+2𝖼𝖼(σ)+op𝒫Fop.\displaystyle\lambda f(S)\leq\lambda f(S^{*})+2\mathsf{cc}(\sigma^{*})+\sum_{\textrm{op}\in{\mathcal{P}}_{\mathrm{F}}}\nabla_{\textrm{op}}.

It is easy to check that each of 𝒫C{\mathcal{P}}_{\mathrm{C}} and 𝒫F{\mathcal{P}}_{\mathrm{F}} contains at most 1 operation opens or swaps in ii^{*}, for every iSfi^{*}\in S^{*}\subseteq f and does not contain operations that open or swap in facilities outside SS^{*}. 𝒫C𝒫F{\mathcal{P}}_{\mathrm{C}}\uplus{\mathcal{P}}_{\mathrm{F}} contains at most |S||F||S|\leq|F| close operations. Rewriting the two inequalities almost gives us Theorem 8, except for the requirement that each op𝒫C𝒫F\textrm{op}\in{\mathcal{P}}_{\mathrm{C}}\cup{\mathcal{P}}_{\mathrm{F}} has op>0\nabla_{\mathrm{op}}>0; this can be ensured by removing op’s with op0\nabla_{\textrm{op}}\leq 0 from 𝒫C{\mathcal{P}}_{\mathrm{C}} and 𝒫F{\mathcal{P}}_{\mathrm{F}}.

Appendix B Proofs of Useful Lemmas

See 9

Proof.

Define aT+1=+a_{T+1}=+\infty.

t=1Tbtat\displaystyle\sum_{t=1}^{T}\frac{b_{t}}{a_{t}} =t=1TBtBt1at=t=1TBt(1at1at+1)=t=1TBtat(1atat+1)αt=1T(1atat+1)\displaystyle=\sum_{t=1}^{T}\frac{B_{t}-B_{t-1}}{a_{t}}=\sum_{t=1}^{T}B_{t}\left(\frac{1}{a_{t}}-\frac{1}{a_{t+1}}\right)=\sum_{t=1}^{T}\frac{B_{t}}{a_{t}}\left(1-\frac{a_{t}}{a_{t+1}}\right)\leq\alpha\sum_{t=1}^{T}\left(1-\frac{a_{t}}{a_{t+1}}\right)
=αTαt=1T1atat+1αTα(T1)(a1aT)1/(T1)\displaystyle=\alpha T-\alpha\sum_{t=1}^{T-1}\frac{a_{t}}{a_{t+1}}\leq\alpha T-\alpha(T-1)\Big{(}\frac{a_{1}}{a_{T}}\Big{)}^{1/(T-1)}
=α(T1)(1elnaTa1/(T1))+αα(T1)lnaTa1/(T1)+α=α(lnaTa1+1).\displaystyle=\alpha(T-1)\left(1-e^{-\ln\frac{a_{T}}{a_{1}}/(T-1)}\right)+\alpha\leq\alpha(T-1)\ln\frac{a_{T}}{a_{1}}/(T-1)+\alpha=\alpha\left(\ln\frac{a_{T}}{a_{1}}+1\right).

The inequality in the second line used the following fact: if the product of T1T-1 positive numbers is a1aT\frac{a_{1}}{a_{T}}, then their sum is minimized when they are equal. The inequality in the third line used that 1exx1-e^{-x}\leq x for every xx. ∎

See 10

Proof.

By the conditions in the lemma, opening facility ii and reconnecting C~\tilde{C} to ii is not ϕ\phi-efficient. This gives that at the moment, we have

j~C~d(j~,S)j~C~d(j~,σj~)fi+j~C~d(i,j~)+|C~|ϕ\sum_{\tilde{j}\in\tilde{C}}d(\tilde{j},S)\leq\sum_{\tilde{j}\in\tilde{C}}d(\tilde{j},\sigma_{\tilde{j}})\leq f_{i}+\sum_{\tilde{j}\in\tilde{C}}d(i,\tilde{j})+|\tilde{C}|\cdot\phi

By triangle inequalities we have d(j~,S)d(i,S)d(i,j~)d(\tilde{j},S)\geq d(i,S)-d(i,\tilde{j}) for every j~C~\tilde{j}\in\tilde{C}. Combining with the previous inequality yields:

d(i,S)1|C~|j~C~(d(j~,S)+d(i,j~))fi+2j~C~d(i,j~)|C~|+ϕ.\displaystyle d(i,S)\leq\frac{1}{|\tilde{C}|}\sum_{\tilde{j}\in\tilde{C}}\left(d(\tilde{j},S)+d(i,\tilde{j})\right)\leq\frac{f_{i}+2\sum_{\tilde{j}\in\tilde{C}}d(i,\tilde{j})}{|\tilde{C}|}+\phi.\hskip 80.0pt\qed

Appendix C Moving Clients to Facility Locations

In this section we show that by moving clients to their nearest facilities, we lose a multiplicative factor of 22 and an additive factor of 11 in the approximation. That is, an α\alpha approximate solution for the new instance, is 2α+12\alpha+1 approximate for the original instance. Throughout this section, we simply use the set of open facilities to define a solution and all clients are connected to their respective nearest open facilities.

Let a facility location instance be given by F,(fj)jC,CF,(f_{j})_{j\in C},C and dd. Let ψj\psi_{j} be the nearest facility in FF to jj for every jCj\in C. By moving all clients jj to ψj\psi_{j}, we obtain a new instance. Let SS^{*} be the optimum solution to the original instance. Suppose we have an solution SS for the new instance that is α\alpha-approximate solution. Thus f(S)+jCd(ψj,S)α(f(S)+jCd(ψj,S))f(S)+\sum_{j\in C}d(\psi_{j},S)\leq\alpha\left(f(S^{*})+\sum_{j\in C}d(\psi_{j},S^{*})\right). We show that SS is 2α+12\alpha+1 approximate for the original instance.

Notice that for every jCj\in C, we have d(j,S)d(j,ψj)d(ψj,S)d(j,S)+d(j,ψj)d(j,S)-d(j,\psi_{j})\leq d(\psi_{j},S)\leq d(j,S)+d(j,\psi_{j}) by triangle inequalities.

f(S)+jCd(j,S)\displaystyle f(S)+\sum_{j\in C}d(j,S) f(S)+jC(d(ψj,S)+d(j,ψj))\displaystyle\leq f(S)+\sum_{j\in C}\left(d(\psi_{j},S)+d(j,\psi_{j})\right)
α(f(S)+jCd(ψj,S))+jCd(j,ψj)\displaystyle\leq\alpha\left(f(S^{*})+\sum_{j\in C}d(\psi_{j},S^{*})\right)+\sum_{j\in C}d(j,\psi_{j})

For every jCj\in C, since ψj\psi_{j} is the nearest facility in FF to jj, we have d(ψj,S)d(j,ψj)+d(j,S)2d(j,S)d(\psi_{j},S^{*})\leq d(j,\psi_{j})+d(j,S^{*})\leq 2d(j,S^{*}). Thus, we have

f(S)+jCd(j,S)\displaystyle f(S)+\sum_{j\in C}d(j,S) αf(S)+2αjCd(j,S)+jCd(j,ψj)\displaystyle\leq\alpha f(S^{*})+2\alpha\sum_{j\in C}d(j,S^{*})+\sum_{j\in C}d(j,\psi_{j})
αf(S)+(2α+1)jCd(j,S).\displaystyle\leq\alpha f(S^{*})+(2\alpha+1)\sum_{j\in C}d(j,S^{*}).

Thus, we have that SS is a (2α+1)(2\alpha+1)-approximate solution for the original instance.

Appendix D Missing Proofs from Section 4

See 13

Proof.

We are going to lower bound the expected value of 𝖼𝗈𝗌𝗍λ(S0,σ0)𝖼𝗈𝗌𝗍λ(S1,σ1)\mathsf{cost}_{\lambda}(S^{0},\sigma^{0})-\mathsf{cost}_{\lambda}(S^{1},\sigma^{1}). By Theorem 8, there are two sets 𝒫C{\mathcal{P}}_{\mathrm{C}} and 𝒫F{\mathcal{P}}_{\mathrm{F}} of local operations satisfying the properties. Below, we let 𝒬{\mathcal{Q}} be one of the following three sets: 𝒫C{\mathcal{P}}_{\mathrm{C}}, or 𝒫F{\mathcal{P}}_{\mathrm{F}}, or 𝒫C𝒫F{\mathcal{P}}_{\mathrm{C}}\biguplus{\mathcal{P}}_{\mathrm{F}}.

For every iFi\in F, let 𝒬i{\mathcal{Q}}_{i} be the set of operations in 𝒬{\mathcal{Q}} that open or swap in ii. Let 𝒬{\mathcal{Q}}_{\emptyset} be the set of 𝖼𝗅𝗈𝗌𝖾\mathsf{close} operations in 𝒬{\mathcal{Q}}. Let Φi\Phi_{i} be maximum of 𝗈𝗉\nabla_{\mathsf{op}} over all 𝗈𝗉𝒬i\mathsf{op}\in{\mathcal{Q}}_{i} (define Φi=0\Phi_{i}=0 if 𝒬i={\mathcal{Q}}_{i}=\emptyset); define Φ\Phi_{\emptyset} similarly. Notice that if iSi\in S then open ii will not decrease the cost since we maintain that all the clients are connected to their nearest open facilities. Thus, 𝒬i={\mathcal{Q}}_{i}=\emptyset for iSi\in S. Then, conditioned on that we consider 𝖼𝗅𝗈𝗌𝖾\mathsf{close} operations in 𝗌𝖺𝗆𝗉𝗅𝖾𝖽𝗅𝗈𝖼𝖺𝗅𝗌𝖾𝖺𝗋𝖼𝗁\mathsf{sampled\mathchar 45\relax local\mathchar 45\relax search}, the cost decrement of the iteration is at least Φ\Phi_{\emptyset}. Conditioned on that we consider opening or swapping in ii in the iteration, the decrement is at least Φi\Phi_{i}. Thus, 𝖼𝗈𝗌𝗍λ(S0,σ0)𝔼[𝖼𝗈𝗌𝗍λ(S1,σ1)]Φ3+iFS2Φi3|FS|\mathsf{cost}_{\lambda}(S^{0},\sigma^{0})-\operatorname*{\mathbb{E}}[\mathsf{cost}_{\lambda}(S^{1},\sigma^{1})]\geq\frac{\Phi_{\emptyset}}{3}+\sum_{i\in F\setminus S}\frac{2\Phi_{i}}{3|F\setminus S|}. Therefore,

𝗈𝗉𝒬𝗈𝗉\displaystyle\sum_{\mathsf{op}\in{\mathcal{Q}}}\nabla_{\mathsf{op}} |𝒬|Φ+iFS|𝒬i|Φi|F|Φ+2iFSΦi\displaystyle\leq|{\mathcal{Q}}_{\emptyset}|\Phi_{\emptyset}+\sum_{i\in F\setminus S}|{\mathcal{Q}}_{i}|\Phi_{i}\leq|F|\Phi_{\emptyset}+2\sum_{i\in F\setminus S}\Phi_{i}
3|F|(𝖼𝗈𝗌𝗍λ(S0,σ0)𝔼[𝖼𝗈𝗌𝗍λ(S1,σ1)]),\displaystyle\leq 3|F|(\mathsf{cost}_{\lambda}(S^{0},\sigma^{0})-\operatorname*{\mathbb{E}}[\mathsf{cost}_{\lambda}(S^{1},\sigma^{1})]),

since the third and fourth properties in the theorem imply |𝒬||F||{\mathcal{Q}}_{\emptyset}|\leq|F| and |𝒬i|2|{\mathcal{Q}}_{i}|\leq 2 for every iFSi\in F\setminus S. Replacing 𝒬{\mathcal{Q}} with each of 𝒫C{\mathcal{P}}_{\mathrm{C}}, 𝒫F{\mathcal{P}}_{\mathrm{F}} and 𝒫C𝒫F{\mathcal{P}}_{\mathrm{C}}\biguplus{\mathcal{P}}_{\mathrm{F}}, we obtain

𝖼𝗈𝗌𝗍λ(S0,σ0)𝔼[𝖼𝗈𝗌𝗍λ(S1,σ1)]13|F|max{𝖼𝖼(σ0)(λf(S)+𝖼𝖼(σ))λf(S)(λf(S)+2𝖼𝖼(σ))𝖼𝗈𝗌𝗍λ(S0,σ0)(2λf(S)+3𝖼𝖼(σ))}.\displaystyle\mathsf{cost}_{\lambda}(S^{0},\sigma^{0})-\operatorname*{\mathbb{E}}[\mathsf{cost}_{\lambda}(S^{1},\sigma^{1})]\geq\frac{1}{3|F|}\max\left\{\begin{array}[]{c}\mathsf{cc}(\sigma^{0})-(\lambda f(S^{*})+\mathsf{cc}(\sigma^{*}))\\ \lambda f(S)-(\lambda f(S^{*})+2\mathsf{cc}(\sigma^{*}))\\ \mathsf{cost}_{\lambda}(S^{0},\sigma^{0})-(2\lambda f(S^{*})+3\mathsf{cc}(\sigma^{*}))\end{array}\right\}.

This finishes the proof of the lemma. ∎

See 14

Proof.

We break the procedure in two stages. The first stage contains M1=O(|F|logΓϵ)M_{1}=O\left(|F|\log\frac{\Gamma}{\epsilon^{\prime}}\right) iterations of the for-loop in 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾(M)\mathsf{FL\mathchar 45\relax iterate}(M), where M1M_{1} is sufficiently large. Applying Lemma 13 and using the third term in the max\max operator, for any execution of 𝗌𝖺𝗆𝗉𝗅𝖾𝖽𝗅𝗈𝖼𝖺𝗅𝗌𝖾𝖺𝗋𝖼𝗁\mathsf{sampled\mathchar 45\relax local\mathchar 45\relax search}, we have

𝔼[(𝖼𝗈𝗌𝗍λ(S1,σ1)(2λf(S)+3𝖼𝖼(σ)))+]\displaystyle\quad\operatorname*{\mathbb{E}}\big{[}\big{(}\mathsf{cost}_{\lambda}(S^{1},\sigma^{1})-(2\lambda f(S^{*})+3\mathsf{cc}(\sigma^{*}))\big{)}_{+}\big{]}
(113|F|)(𝖼𝗈𝗌𝗍λ(S0,σ0)(2λf(S)+3𝖼𝖼(σ)))+,\displaystyle\leq\left(1-\frac{1}{3|F|}\right)\big{(}\mathsf{cost}_{\lambda}(S^{0},\sigma^{0})-(2\lambda f(S^{*})+3\mathsf{cc}(\sigma^{*}))\big{)}_{+},

where (S0,σ0)(S^{0},\sigma^{0}) and (S1,σ1)(S^{1},\sigma^{1}) are as defined w.r.t the execution, and x+x_{+} is defined as max{x,0}\max\{x,0\} for every real number xx. Notice that when 𝖼𝗈𝗌𝗍λ(S0,σ0)2λf(S)+3𝖼𝖼(σ)\mathsf{cost}_{\lambda}(S^{0},\sigma^{0})\leq 2\lambda f(S^{*})+3\mathsf{cc}(\sigma^{*}), the inequality holds trivially. Truncating at 0 is needed later when we apply the Markov inequality.

So, after M1M_{1} iterations, we have

𝔼[(𝖼𝗈𝗌𝗍λ(S,σ)(2λf(S)+3𝖼𝖼(σ)))+]\displaystyle\quad\operatorname*{\mathbb{E}}\big{[}\big{(}\mathsf{cost}_{\lambda}(S,\sigma)-(2\lambda f(S^{*})+3\mathsf{cc}(\sigma^{*}))\big{)}_{+}\big{]}
(113|F|)M1(𝖼𝗈𝗌𝗍λ(S,σ)(2λf(S)+3𝖼𝖼(σ)))+ϵ2Γ𝗈𝗉𝗍.\displaystyle\leq\left(1-\frac{1}{3|F|}\right)^{M_{1}}\big{(}\mathsf{cost}_{\lambda}(S^{\circ},\sigma^{\circ})-(2\lambda f(S^{*})+3\mathsf{cc}(\sigma^{*}))\big{)}_{+}\leq\frac{\epsilon^{\prime}}{2\Gamma}\mathsf{opt}.

The second inequality holds since 𝖼𝗈𝗌𝗍λ(S,σ)λ𝖼𝗈𝗌𝗍(S,σ)O(1)𝗈𝗉𝗍\mathsf{cost}_{\lambda}(S^{\circ},\sigma^{\circ})\leq\lambda\mathsf{cost}(S^{\circ},\sigma^{\circ})\leq O(1)\mathsf{opt} and M=O(|F|ϵlogΓ)M=O\left(\frac{|F|}{\epsilon^{\prime}}\log\Gamma\right) is sufficiently large. Using Markov’s inequality, with probability at least 112Γ1-\frac{1}{2\Gamma}, we have at the end of the first stage,

(𝖼𝗈𝗌𝗍λ(S,σ)(2λf(S)+3𝖼𝖼(σ)))+ϵ𝗈𝗉𝗍.(\mathsf{cost}_{\lambda}(S,\sigma)-(2\lambda f(S^{*})+3\mathsf{cc}(\sigma^{*})))_{+}\leq\epsilon^{\prime}\cdot\mathsf{opt}.

If the event happens, we say the first stage is successful.

We assume the first stage is successful and analyze the second stage. The second stage contains log2(2Γ)\log_{2}(2\Gamma) phases, and each phase contains 48|F|ϵ\frac{48|F|}{\epsilon^{\prime}} iterations. We focus on one phase in the stage. Assume that at the beginning of an iteration in the phase, we have

𝖼𝖼(σ)(λ+ϵ2)f(S)+(1+ϵ2)𝖼𝖼(σ) and λf(S)(λ+λϵ2)f(S)+(2+λϵ2)𝖼𝖼(σ).\displaystyle\mathsf{cc}(\sigma)\leq\big{(}\lambda+\frac{\epsilon^{\prime}}{2}\big{)}f(S^{*})+\big{(}1+\frac{\epsilon^{\prime}}{2}\big{)}\mathsf{cc}(\sigma^{*})\text{ and }\lambda f(S)\leq\big{(}\lambda+\frac{\lambda\epsilon^{\prime}}{2}\big{)}f(S^{*})+\big{(}2+\frac{\lambda\epsilon^{\prime}}{2}\big{)}\mathsf{cc}(\sigma^{*}).

Then at the moment, we have 𝖼𝗈𝗌𝗍(S,σ)(1+λ+ϵ)f(S)+(1+2/λ+ϵ)𝖼𝖼(σ)=(α𝖥𝖫+ϵ)𝗈𝗉𝗍\mathsf{cost}(S,\sigma)\leq(1+\lambda+\epsilon^{\prime})f(S^{*})+(1+2/\lambda+\epsilon^{\prime})\mathsf{cc}(\sigma^{*})=(\alpha_{\mathsf{FL}}+\epsilon^{\prime})\mathsf{opt} (obtained by adding the first inequality and 1/λ1/\lambda times the second inequality). Then we must have 𝖼𝗈𝗌𝗍(S𝖻𝖾𝗌𝗍,σ𝖻𝖾𝗌𝗍)(α𝖥𝖫+ϵ)𝗈𝗉𝗍\mathsf{cost}(S^{\mathsf{best}},\sigma^{\mathsf{best}})\leq(\alpha_{\mathsf{FL}}+\epsilon^{\prime})\mathsf{opt} in the end of this execution of 𝖥𝖫𝗂𝗍𝖾𝗋𝖺𝗍𝖾\mathsf{FL\mathchar 45\relax iterate} since (S𝖻𝖾𝗌𝗍,σ𝖻𝖾𝗌𝗍)(S^{\mathsf{best}},\sigma^{\mathsf{best}}) is the best solution according to the original (i.e, non-scaled) cost.

Thus, we say a phase in the second stage is successful if both inequalities hold at the end of some iteration in the phase; then we can pretend that the phase ends at the moment it is successful. If one of the two inequalities does not hold at the end of an iteration, then by Lemma 13, for the execution of 𝗌𝖺𝗆𝗉𝗅𝖾𝖽𝗅𝗈𝖼𝖺𝗅𝗌𝖾𝖺𝗋𝖼𝗁\mathsf{sampled\mathchar 45\relax local\mathchar 45\relax search} in the next iteration, we have 𝖼𝗈𝗌𝗍λ(S0,σ0)𝔼[𝖼𝗈𝗌𝗍λ(S1,σ1)]ϵ6|F|(f(S)+𝖼𝖼(σ))=ϵ6|F|𝗈𝗉𝗍\mathsf{cost}_{\lambda}(S^{0},\sigma^{0})-\operatorname*{\mathbb{E}}[\mathsf{cost}_{\lambda}(S^{1},\sigma^{1})]\geq\frac{\epsilon^{\prime}}{6|F|}(f(S^{*})+\mathsf{cc}(\sigma^{*}))=\frac{\epsilon^{\prime}}{6|F|}\mathsf{opt}. Then, by stopping times of martingales, in expectation, the phase stops in at most 24|F|ϵ\frac{24|F|}{\epsilon^{\prime}} iterations since at the beginning of the phase we have 𝖼𝗈𝗌𝗍λ(S,σ)max{3+ϵ,2λ+ϵ}(f(S)+𝖼𝖼(σ))4𝗈𝗉𝗍\mathsf{cost}_{\lambda}(S,\sigma)\leq\max\{3+\epsilon^{\prime},2\lambda+\epsilon^{\prime}\}(f(S^{*})+\mathsf{cc}(\sigma^{*}))\leq 4\cdot\mathsf{opt} and 𝖼𝗈𝗌𝗍λ(S,σ)\mathsf{cost}_{\lambda}(S,\sigma) is always positive. By Markov’s inequality, the probability that the phase does not stop early (i.e, is not successful) is at most 1/21/2. The probability that the second stage succeeds, i.e, at least one of its phases succeeds is at least 11/(2Γ)1-1/(2\Gamma). Thus with probability at least 11/Γ1-1/\Gamma, both stages succeed and we have 𝖼𝗈𝗌𝗍(Sbest,σbest)(α𝖥𝖫+ϵ)𝗈𝗉𝗍\mathsf{cost}(S^{\mathrm{best}},\sigma^{\mathrm{best}})\leq(\alpha_{\mathsf{FL}}+\epsilon^{\prime})\mathsf{opt}. The number of iterations we need in the two stages is O(|F|ϵlogΓ)O\left(\frac{|F|}{\epsilon^{\prime}}\log\Gamma\right). ∎