Efficient and Stable Fully Dynamic Facility Location
Abstract
We consider the classic facility location problem in fully dynamic data streams, where elements can be both inserted and deleted.
In this problem, one is interested in maintaining a stable and high quality solution throughout the data stream while using only little time per update (insertion or deletion).
We study the problem and provide the first algorithm that at the same time maintains a constant approximation and incurs polylogarithmic amortized recourse per update.
We complement our theoretical results with an experimental analysis showing the practical efficiency of our method
Introduction
Clustering is a fundamental problem in unsupervised learning with many practical applications in community detection, spam detection, image segmentation and many others.
A central problem in this space with a long and rich history in computer science and operations research Korte and Vygen [2018] is the facility location problem(which can also be seen as the Lagrangian relaxation of the classic k–median clustering).
Due to its scientific importance and practical applications the problem has been studied extensively and several approximation algorithms are known for the problem Guha and Khuller [1999], Jain et al.
[2003], Li [2013].
In addition, the problem has also been extensively studied in various computational model as the streaming model Indyk [2004], Lammersen and
Sohler [2008], Czumaj et al.
[2013], the online model Meyerson [2001], Fotakis [2008] and dynamic algorithm model Cygan et al.
[2018], Goranci et al.
[2018], Cohen-Addad et al.
[2019], Guo et al.
[2020] and many more.
Real world applications nowadays often process evolving data-sets, i.e. social networks continuously evolve in time, videos and pictures are constantly uploaded and taken down from media platforms, news article and blog posted are uploaded or taken down and so on so for.
For this reason, it is important to design algorithms that are able to maintain a stable and high quality solution and that at the same time can process updates efficiently.
As a consequence, the dynamic and online model have been extensively studied and several interesting results are known for classic learning problems Lattanzi and Vassilvitskii [2017], Chan et al.
[2018], Cohen-Addad et al.
[2019], Jaghargh et al.
[2019], Lattanzi et al.
[2020], Fichtenberger et al.
[2021], Guo et al.
In this paper, we extend this line of work by studying the classic facility location problem in the fully dynamic setting.
Problem definition.
The input to our problem consists of a collection F of facilities and a collection
D of clients in a general metric space.
For all i ∈ F, j ∈ D , we let d ij denote the distance between facility i and client j 1 .
These distances satisfy triangle inequality.
Let f i denote the opening cost of facility i ∈ F .
Our goal is to open a subset of facilities F ′ ⊆
F and then connect every client j ∈ D to some open facility i j ∈ F ′ , so as to minimise the objective (cid:80) i ∈
F ′ f i + (cid:80)
j ∈ D
d i j ,j .
The first sum in the objective denotes the sum of the opening costs of the facilities in F ′ , whereas the second sum denotes the sum of the connection costs for the clients.
Throughout the rest of this paper, we will let m = | F | and n = | D | respectively denote the number of facilities and clients.
We consider a dynamic setting , where the input to the problem keeps changing via a sequence of updates.
Each update inserts or deletes a client in the metric space.
Throughout this sequence of updates, we wish to maintain an approximately optimal solution to the current input instance with small recourse .
The recourse of the algorithm is defined as follows.
Whenever we open a new facility or close an already open facility, we incur one unit of facility-recourse .
Similarly, whenever we reassign a client from one facility to another, we incur one unit of client-recourse .
The recourse of the algorithm after an update is the sum of facility-recourse and client-recourse.
Note that the recourse of an algorithm naturally captures the consistency of the solution throughout the input updates.
So having small recourse is particularly important for real world application where a clustering is served to the user or used in a machine learning pipeline Lattanzi and Vassilvitskii [2017].
Our main result in this paper is summarized in the theorem below.
Theorem 1.
There is a deterministic O (1) -approximation algorithm for fully dynamic facility location problem that has O (log m ) amortized recourse, under the natural assumption that the distances between facilities and clients and the facility opening-costs are bounded by some polynomial in m .
Our Technique.
To the best of our knowledge, this is the first algorithm for fully dynamic facility location that can handle non-uniform facility costs and maintains a O (1) approximation with polylogarithmic recourse per update.
To obtain our result, we consider a relaxed version of the natural greedy algorithm in the static setting.
This relaxed greedy algorithm proceeds in iterations.
In each iteration the algorithm picks a cluster , which specifies a set of currently unassigned clients and the facility they will get assigned to, that has approximately minimum average marginal cost.
The algorithm stops when every client gets assigned to some facility.
In the dynamic setting, we ensure that the solution maintained by our algorithm always corresponds to an output of the relaxed greedy algorithm (assuming the relaxed-greedy algorithm receives the current input instance).
To be a bit more precise, we formulate a set of invariants which capture the workings of the relaxed greedy algorithm, and fix the invariants using a simple heuristic whenever one or more of them get violated in the dynamic setting.
The approximation guarantee now follows from the observation that the relaxed greedy algorithm returns a O (1) approximation in the static setting.
The recourse bound, on the other hand, follows from a careful token-based argument that is inspired by the analysis of a fully dynamic greedy algorithm for minimum set cover Gupta et al.
In addition, using standard data structures it is easy to show that the amortized update time of our algorithm is ˜ O ( m ) .
We note that this update time is near-optimum, as each arriving client needs to reveal its distances to the facilities, which also holds for the uniform facility opening cost as pointed out in Cohen-Addad et al.
We also complement our theoretical analysis with an in-depth study of the performance of our algorithm showing that our algorithm is very efficient and effective in practice.
Related Works.
Facility location and dynamic algorithms have been extensively studied in the algorithm and machine learning literature.
Here we give an overview of closely related results.
Facility Location.
The classic offline metric facility location problem has been extensively studied (see Korte and Vygen [2018]).
The best-known approximation for the problem algorithm gives a 1 . 488 approximation Li [2013].
The problem is known to be NP-hard, and it cannot be approximated within a factor of 1 . 463 unless NP ⊆ DTIME ( n loglog( n ) )
Guha and Khuller [1999].
Dynamic algorithm for clustering and facility location.
Recently several dynamic algorithms have been introduced for clustering and facility location problems Lattanzi and Vassilvitskii [2017], Chan et al.
[2018], Cygan et al.
[2018], Goranci et al.
[2018], Cohen-Addad et al.
[2019], Henzinger et al.
[2020], Guo et al.
[2020], Goranci et al.
[2021], Fichtenberger et al.
The recourse for clustering problems was studied in Lattanzi and Vassilvitskii [2017], then several papers followed up with interesting results on recourse and dynamic algorithms Chan et al.
[2018], Cohen-Addad et al.
[2019], Henzinger et al.
[2020], Fichtenberger et al.
Efficient algorithm for the fully-dynamic facility location problem are known either when the doubling dimension of the problem is bounded Goranci et al.
[2018, 2021] or when the facility have uniform cost Cygan et al.
[2018], Cohen-Addad et al.
When the facilities can have arbitrary nonuniform costs in a general metric space, prior to our work the best known fully dynamic algorithm achieved a O (log | F | ) approximation with polylogarithmic recourse Guo et al.
Our Dynamic Algorithm
In Section 2.1, we present an intuitive overview of our algorithm.
We formally describe our algorithm in Section 2.2 and Section 2.3, and analyze its recourse and approximation guarantee in Section 2.4.
2.1 An Informal Overview of Our Algorithm
We start by recalling a natural greedy algorithm for the facility location problem in the static setting .
This (static) algorithm is known to return a constant approximation for the problem Jain et al.
The algorithm proceeds in rounds .
Throughout the duration of the algorithm, let F ∗ ⊆ F and
D ∗ ⊆
D respectively denoted the set of opened facilities and the set of clients that are already assigned to some open facility.
Initially, before the start of the first round, we set F ∗ ← ∅ and
D ∗ ← ∅ .
The next paragraph describes what happens during a given round of this algorithm.
Say that a cluster C is an ordered pair ( i, A ) , where i ∈ F and A ⊆ D .
A cluster is either satellite or critical .
If a cluster C =
( i, A ) is satellite (resp. critical), then its cost is given by cost ( C ) :
= (cid:80) j ∈
A d ij (resp.
cost ( C ) :
= f i + (cid:80)
j ∈
A d ij ).
Thus, the only difference between an satellite cluster and a critical cluster is that the cost of the former (resp. latter) does not (resp.
does) include the opening cost of the concerned facility.
The average cost of a cluster C
=
( i, A ) is defined as cost avg ( C ) :
= cost ( C ) /
| A | .
Let C ord ( F ∗ , D ∗ ) be the set of all satellite clusters
C =
( i, A ) with i ∈ F ∗ and
A ⊆ D \ D ∗ , and let C crit ( F ∗ , D ∗ ) be the set of all critical clusters
C =
( i, A ) with i ∈ F \ F ∗ and A ⊆ D \ D ∗ .
In the current round, we pick a cluster C
=
( i, A ) ∈
C crit ( F ∗ , D ∗ ) ∪ C ord ( F ∗ , D ∗ ) with minimum average cost , set F ∗ ← F ∗ ∪ { i } and D ∗ ← D ∗ ∪ A , and assign all the clients j ∈ A to the facility i .
At this point, if D ∗ =
D , then we terminate the algorithm.
Otherwise, we proceed to the next round.
Intuitively, in each round the above greedy algorithm picks a cluster with minimum average cost , which is defined in such a way that takes into account the opening cost of a facility the first time some client gets assigned to it.
Let C denote the collection of all clusters picked by this algorithm, across all the rounds.
Note: (1) Every client j ∈ A belongs to exactly one cluster in C .
(2) Let C ( i ) ⊆
C denote the subset of clusters in C which contain a given facility i ∈ F .
If C ( i ) ̸ = ∅ , then exactly one of the clusters in C ( i ) is critical.
We refer to a collection C which satisfy these two properties as a clustering .
It is easy to check that a clustering C defines a valid solution to the concerned instance of the facility location problem, where the objective value of the solution is given by obj ( C ) :
= (cid:80) C ∈C cost ( C ) .
Note that if the above algorithm picks an satellite cluster C
= ( i, A ) in a given round, then w.l.o.g.
we can assume that | A | = 1 .
This is because if | A | > 1 , then we can only decrease the average cost of C by deleting from A all but the one client that is closest to facility i .
Accordingly, from now on we will only consider those satellite clusters that have exactly one client.
Our dynamic algorithm is based on a relaxation of the above static greedy algorithm, where in each round we have the flexibility of picking a cluster with approximately minimum average cost.
The output of this relaxed greedy algorithm corresponds to what we call a nice clustering (see Section 2.
for a formal definition).
We now present a high-level, informal overview of our dynamic algorithm.
Preprocessing: Upon receiving an input ( F, D ) at preprocessing, we run the relaxed greedy algorithm which returns a nice clustering C .
We assign each cluster C ∈ C to an (not necessarily positive
) integer level ℓ ( C ) ∈
Z such that cost avg ( C ) =
Θ(2 ℓ ( C ) ) .
Thus, the level of a cluster encodes its average cost upto a constant multiplicative factor.
Define the level of a client j ∈ C to be ℓ ( j ) :=
ℓ ( C ) .
Handling an update: When a client j gets deleted from D , we simply delete the concerned client from the cluster in C it appears in.
Similarly, when a client j gets inserted into D , we arbitrarily assign it to any open facility i by creating an satellite cluster ( C =
( i, { j } ) at the minimum possible level k ≥ Θ(log d ij ) .
At this point, we check if the clustering C being maintained by our algorithm still remains nice , i.e., whether C can correspond to an output of the relaxed greedy algorithm on the current input.
If the answer is yes, then our dynamic algorithm is done with handling the current update.
Thus, for the rest of this discussion, assume that the clustering C is no longer nice .
It turns out that in this event we can always identify a cluster C
= ( i, A ) (not necessarily part of
C ) and a level k ∈
Z such that: cost avg ( C ) ≤ O (2 k ) and ℓ ( j ) > k for all clients j ∈ A .
We refer to such a cluster C
=
( i, A ) as a blocking cluster .
Intuitively, the existence of a blocking cluster is a certificate that the current clustering C is not nice.
This is because the relaxed greedy algorithm constructs the levels in a bottom-up manner, in increasing order of average costs of the clusters that get added to the solution in successive rounds.
Accordingly, the relaxed greedy algorithm would have added the cluster C to its solution at level ≤ k before proceeding to level k + 1 , and this contradicts the fact that a client j ∈ A appears at level > k in the current clustering C .
As long as there is a blocking cluster C
= ( i, A ) at some level k , we update the current clustering C by calling a subroutine F IX -B LOCKING ( C, k ) which works as follows: (1) it adds the cluster C to level k , and (2) it removes each client j ∈ A from the cluster in C it belonged to prior to this step.
Next, note that because of step (2) above, some cluster C ′ =
( i ′ , A ′ ) might lose one or more clients j as they move from C ′ to the newly formed cluster C , and this might increase the average cost of the cluster C ′ .
Thus, we might potentially end up in a situation where a cluster C ′ =
( i ′ , A ′ ) has cost avg ( C ′ )
≫ 2 ℓ ( C ′ ) .
As long as this happens to be the case, we call a subroutine F IX -L EVEL ( C ) whose job is to increase the level of the affected cluster C ′ by one.
Our algorithm repeatedly calls the subroutines F IX -B LOCKING ( ., . ) and F IX -L EVEL ( . ) until there is no blocking cluster and every cluster C ∈ C has cost avg ( C )
=
Θ(2 ℓ ( C ) ) .
At this point, we are guaranteed that the current clustering is nice and we are done with processing the concerned update.
The approximation ratio of our algorithm follows from the observation that a nice clustering corresponds to the output of the relaxed greedy algorithm in the static setting, which in turn gives a
O (1) -approximation.
We bound the amortized recourse by a careful token-based argument.
2.2 Nice clustering
In Section 2.1, we explained that a nice clustering corresponds to an output of the relaxed greedy algorithm in the static setting.
We now give a formal definition of this concept by introducing four invariants.
Specifically, we define a clustering C to be nice iff it satisfies Invariants 1, 2, 3 and 4.
Every cluster C ∈ C is assigned a (not necessarily positive
) integer level ℓ ( C ) ∈ Z .
For any cluster
C =
( i, A ) ∈ C and any client j ∈ A , we define the level of the client j to be ℓ ( j ) :
= ℓ ( C ) .
Invariant 1.
For every cluster C ∈ C , we have cost avg ( C ) < 2 ℓ ( C ) .
The relaxed greedy algorithm constructs these levels in a “bottom-up” manner: it assigns the relevant clusters to a level k before moving on to level k + 1 .
This holds because the algorithm picks the clusters in (approximately) increasing order of their average costs.
Also, before picking an satellite cluster C =
( i, { j } ) , the algorithm ensures that facility i is open.
This leads to the invariant below.
Invariant 2.
Consider any facility i ∈ F with C ( i ) ̸ = ∅ .
Then the unique critical cluster C ∗ ∈ C ( i ) satisfies: ℓ ( C ∗ ) ≤ ℓ ( C ) for all C ∈ C ( i ) .
The next invariant captures the fact that in an output of the relaxed greedy algorithm, if a client j ∈ D gets assigned to a facility i ∈ F then ℓ ( j ) ≥ Θ(log d ij ) .
Invariant 3.
For every cluster C
= ( i, A ) ∈ C and every client j ∈ A , we have ℓ ( j ) ≥ κ ∗ ij , where κ ∗ ij is the unique level s.t.
κ ∗ ij − 4 ≤ d ij < 2 κ ∗ ij − 3 .
Finally, we formulate an invariant which captures the fact that the relaxed greedy algorithm picks the clusters in an (approximately) increasing order of their average costs.
Towards this end, we define the notion of a blocking cluster , as described below.
Definition 1.
Consider any clustering C , any level k ∈ Z , and any cluster C
=
( i, A ) that does not necessarily belong to C .
The cluster C is a blocking cluster at level k w.r.t.
C iff three conditions hold.
(a) We have cost avg ( C ) < 2 k − 3 .
(b) For every j ∈ A , we have ℓ ( j ) >
k ≥ κ ∗ ij , where κ ∗ ij is the unique level s.t. 2 κ ∗ ij − 4 ≤ d ij < 2 κ ∗ ij − 3 .
(c) If C is an satellite cluster, then there is a critical cluster
C
∗ ∈ C ( i ) with ℓ ( C ∗ ) ≤ k .
Else if C is a critical cluster, then k ≤ ℓ ( C for all C ′ ∈ C ( i
Intuitively, if C = ( i, A ) is a blocking cluster at level k w.r.t.
C , then the relaxed greedy algorithm should have formed the cluster C at some level k ′ <
k
before proceeding to construct the subsequent levels which currently contain all the clients in A .
This leads us to the invariant below.
Invariant 4.
There is no blocking cluster w.r.t.
the clustering C at any level k ∈ Z .
Remark.
Consider a cluster C
= ( i, A ) ∈ C at level ℓ ( C ) =
k .
If cost avg ( C ) ≪ 2 k , then it is not difficult to show that there exists a subset of clients
A ′ ⊆
A such that C ′
=
( i, A ′ ) is a blocking cluster at level k − 1 .
This, along with Invariant 1, implies that cost avg ( C ) =
Θ(2 ℓ ( C ) ) for all C ∈ C .
The next theorem holds since a nice clustering corresponds to the output of the relaxed greedy algorithm, and since the (original) greedy algorithm is known to have an approximation ratio of O (1) .
We defer the proof of Theorem 2 to Appendix B.
Theorem 2.
Any nice clustering forms a O (1) -approximate optimal solution to the concerned input instance of the facility location problem.
2.3 Description of Our Dynamic Algorithm
In the dynamic setting, we simply maintain a nice clustering.
To be more specific, w.l.o.g.
we assume that D = ∅ at preprocessing.
Subsequently, during each update, a client gets inserted into / deleted from the set D .
We now describe how our algorithm handles an update.
Handling the deletion of a client j : Suppose that client j belonged to the cluster C
= ( i, A ) ∈ C just before getting deleted.
We set A ← A \ { j } , and then we call the subroutine described in Figure 1.
Handling the insertion of a client j : We identify any open facility i ∈ F .
4 Let κ ∗ ij ∈
Z be the unique level such that 2 κ ∗ ij − 4 ≤ d ij < 2 κ ∗ ij − 3 .
Let C
= ( i, A ) be the unique critical cluster with facility i .
If κ ∗ ij ≤ ℓ ( C ) , then we set A ← A ∪ { j } .
In this case the client j becomes part of the critical cluster C at level ℓ ( C ) .
Else if κ ∗ ij > ℓ ( C ) , then we create a new satellite cluster ( i, { j } ) at level ℓ (( i, { j } ))
=
κ ∗ ij , and set C ← C ∪ { ( i, j ) } .
Next, we call the subroutine described in Figure 1.
The subroutine F IX -C LUSTERING (.): The insertion / deletion of a client might lead to a violation of Invariant 4 or Invariant 1 (the procedure described in the preceding two paragraphs ensure that
Invariant 2 and Invariant 3 continue to remain satisfied).
The subroutine F IX -C LUSTERING (.) handles this issue.
It repeatedly checks whether Invariant 4 or Invariant 1 is violated, and accordingly calls
F IX -B LOCKING ( C, k ) or F IX -L
EVEL
( C ) .
Each of these last two subroutines has the property that it does not lead to any new violation of Invariant 2 or Invariant 3.
Thus, when the W HILE loop in
Figure 1 terminates, all the invariants are restored and we end up with a nice clustering.
W HILE either Invariant 4 or Invariant 1 is violated: 2.
I F Invariant 4 is violated, T HEN 3.
Find a cluster C
= ( i, A ) that is blocking at level k (say).
Call the subroutine F IX -B LOCKING ( C, k ) .
E LSE I F Invariant 1 is violated, T HEN 6.
Find a cluster C
= ( i, A ) (say) that violates Invariant 1. 7.
Call the subroutine F IX -L EVEL ( C ) .
The subroutine F IX -B LOCKING ( C, k ) :
This subroutine works as follows.
We first add the cluster
C =
( i, A ) to the current clustering.
Towards this end, we set ℓ ( C ) ← k , C ← C ∪ { C } , and perform the following operations for all clients j ∈ A .
• Let C ′
j =
( i ′ j , A ′ j )
be the cluster the client j belonged to just before the concerned call to the subroutine F IX -B LOCKING ( C, k ) .
Set A ′
j ← A ′ j \ { j } .
At this point, we fork into one of two cases.
Case (a): If C is an satellite cluster, then there is nothing further that needs to be done, and we terminate the call to this subroutine.
Case (b): If C =
( i, A ) is a critical cluster, then let C ′
=
( i, A ′ ) denote the unique critical cluster with facility
i just before the concerned call to the subroutine.
Since there has to be exactly one critical cluster with facility i , we now convert the cluster C ′
=
( i, A ′ ) into (possibly) multiple satellite clusters by performing the following operations for all clients j ∈ A ′ .
• Create an satellite cluster ( i, { j } ) at level ℓ (( i, { j } )) =
ℓ ( C ′ ) , and set C ← C ∪ { ( i, { j } ) } .
Finally, we remove the previous critical cluster C ′ from the current clustering, by setting C ← C\{ C ′ } , and then terminate the call to this subroutine.
The subroutine F IX -L EVEL ( C ) : Suppose that the cluster C
=
( i, A ) is currently at level k = ℓ ( C ) .
We first deal with the corner case where C ( i ) =
{ C } and A = ∅ .
In this case, we simply set
C ← C \ { C } , and then terminate the call to this subroutine.
Next, we check if C is a critical cluster.
If the answer is yes, then the cluster C absorbs all the existing satellite clusters involving facility i at level k .
To be more specific, for all satellite clusters ( i, { j } ) at level k , we set A ← A ∪ { j } and
C ← C \ { ( i, { j } ) } .
This ensures that Invariant 2 continues to remain satisfied.
Finally, at this point if it continues to be the case that cost avg ( C ) ≥ 2 k , then we move the cluster C up to level k + 1 , by setting ℓ ( C ) ← ℓ ( C ) + 1 .
We now terminate the call to this subroutine.
2.4 Analysis of Our Dynamic Algorithm
The approximation guarantee of our dynamic algorithm follows from Theorem 2 and Theorem 3.
We defer the proof of Theorem 3 to Appendix A.
Theorem 3.
The clustering C maintained by our dynamic algorithm always remains nice.
For the rest of this section, we focus on bounding the amortized recourse of our algorithm.
Towards this end, whenever a client moves up (resp.
down) one level, we say that the algorithm performs one unit of up-work (resp.
down-work ).
Lemma 1.
During any sequence of t updates, the total recourse of the algorithm is at most t plus
O (1) times the total number of units of down-work that get performed.
Proof.
First, note that the total facility-recourse is upper bounded, within a constant multiplicative factor, by the total client-recourse.
This is because if we open a new facility, then it necessarily implies that at least one client gets reassigned to the newly open facility.
Next, observe that a client j gets assigned to a new facility i only if one of the following two events occurs.
The client j gets inserted during an update.
The client j participates in a blocking cluster C
=
( i, A ) at level k
(say), and the algorithm calls the subroutine F IX -B LOCKING ( C, k ) .
The total recourse incurred due to events of type (1) is at most t .
On the other hand, during an event of type (2) the concerned client j moves down from its current level ℓ ( j ) to a smaller level k , as per condition (b) in Definition 1.
Thus, the total recourse incurred due to events of type (2) is at most the total units of down-work performed by the algorithm.
The lemma follows.
It now remains to bound the total units of down-work performed by our algorithm.
We achieve this by means of a token based argument, which in turn, requires us to first introduce the notion of an epoch of a cluster, and then bound the total units of up-work performed by our algorithm during an epoch.
Epoch: Observe that when a concerned cluster C =
( i, A ) first becomes part of the clustering C at some level (say) k , we have cost avg ( C ) <
2 k − 3 (see condition (a) in Definition 1).
Subsequently, during its entire lifetime, the level of the cluster C can only increase (this can happen because of calls to the subroutine F IX -L EVEL ( C ) ).
Accordingly, we partition the lifetime of the concerned cluster
C =
( i, A ) into multiple epochs , where an epoch refers to a maximal time-interval during which the level of the cluster does not increase.
To be a bit more specific, suppose that the lifetime of cluster
C consists of epochs { 0 , 1 , . . .
, λ } , for some integer λ ≥ 0 .
An epoch r ∈ [0 , λ ] begins when the cluster C
=
( i, A ) arrives at level k + r , and ends when the cluster moves up from level k + r to level k + r + 1 .
Let A r denote the state of the set
A just before the end of epoch r .
The algorithm performs | A r | units of up-work for the cluster C
= ( i, A ) in epoch r .
We will now upper bound the total units of up-work performed for the cluster C during its entire lifetime, which is given by (cid:80) λr =
| A r | .
The proof of Lemma 2 appears in Appendix C.
Lemma 2.
Consider a cluster C
= ( i, A ) that first became part of the clustering C at level k .
During its entire lifetime, our algorithm performs at most f i / 2 k − 2 units of up-work on this cluster C .
Tokens: Recall that the opening costs of the facilities and the distances between the clients and facilities are all polynomially bounded by m = | F | .
Hence, there are at most O (log m ) levels in the clustering C .
To be more specific, there are two integral parameters L,
U ∈ Z , with 0 ≤ U − L =
O (log m ) , such that ℓ ( j ) ∈
[ L, U ] for all clients j ∈ D
at all times.
To analyse the amortised recourse of our algorithm, we now associate some tokens with each client in the following manner.
For each client j ∈ D, there is a token at each level
k ∈
[ L, ℓ ( j )] .
Observation 1 holds since there are only O (log m ) levels in the clustering C .
Observation 1.
Whenever a client is inserted, it leads to the creation of at most O (log m ) tokens.
In contrast, whenever a client is deleted, it leads to the release of at most O (log m ) tokens.
We assume that these released tokens get deposited into a special bank-account .
Observation 2.
Whenever the algorithm performs one unit of down-work, it releases one token.
We assume that 1 / 2 of this released token gets deposited into the special bank-account , and the remaining 1 / 2 of the token disappears after paying for the cost of the down-work being performed.
In contrast, whenever the algorithm performs one unit of up-work, it withdraws one token from the special bank-account to ensure that (1) continues to hold.
We assume that just before preprocessing, the special bank-account had zero balance.
We will show that throughout the duration of our algorithm, the balance in this bank-account always remains non-negative.
Towards this end, observe that the algorithm withdraws tokens from this account only when it performs up-work, and it performs up-work only when some cluster increases its level by one.
Accordingly, we focus on a cluster C =
( i, A ) that first becomes part of the clustering C at time τ 0 (say).
Suppose that C was assigned to level k (say) at time τ 0 .
Let A ∗ denote the state of A at time τ 0 .
As per condition (a) of Definition 1, at time τ
we have:
[Equation]
Hence, we get | A ∗ | ≥ f i / 2 k − 3 .
The next observation holds since every client in A ∗ had to move down at least one level before the cluster C is formed at level k , as per condition (b) of Definition 1.
Observation 3.
Just before a cluster C becomes part of the clustering C for the first time (say, at a level k ), the algorithm deposits at least f i / 2 k − 4 many tokens into the special bank-account.
Lemma 2 implies that at most f i / 2 k − 2 tokens get withdrawn from the bank-account because of the cluster C .
By Observation 3, this is at most the number of tokens that get deposited into the same account just before the cluster C is formed at time τ 0 .
It follows that the bank-account never runs into negative balance.
Theorem 4 now follows from Observations 1, 2 and Lemma 1.
Theorem 4.
Starting from an empty set of clients, our algorithms spends at most O ( t log m ) total recourse to handle a sequence of t updates.
So, the amortised recourse of our algorithm is O (log m ) .
2.5 Implementation of our algorithm in (cid:101) O ( m ) amortized update time.
In Appendix D we show how to implement our algorithm in amortized (cid:101) O ( m ) time per update.
Here, we briefly describe how to quickly (i.e., in (cid:101) O ( m ) time) check whether Invariant 4 is satisfied.
For every facility i and level k , let S ( i, k ) denote the sequence of clients that are at a level larger than k , in increasing order of their distances from the facility i .
The key observation is this: If there exists a blocking cluster involving facility i at level k , then there must exist a blocking cluster (with the same facility and at the same level) whose clients form a prefix of S ( i, k ) .
This has the following implication.
Suppose that we explicitly maintain these sequences { S ( i, k ) } .
Then given a specific pair ( i, k ) , we can determine in only (cid:101) O (1) time (via a simple binary search and some standard data structures) whether or not there is a blocking cluster involving facility i at level k .
Finally, note that we can indeed maintain the sequences { S ( i, k ) } by paying a factor (cid:101) O ( m ) overhead in our update time.
This is because whenever a client changes its level (or gets inserted / deleted) we need to modify at most mL =
(cid:101) O ( m ) of these sequences { S ( i, k ) } , where L is the number of levels.
In Appendix D, we present a more fine tuned data structure, where we discretize the distances in powers of (1 + ϵ ) .
However, the main idea behind the data structure is the same as described above.
Experimental Evaluation
Datasets We experiment with three classic datasets 5 from UCI library Dua and Graff [2017]: KDDCup Stolfo et al.
[2000] ( 311 , 029 points of dimension 74 )
and song Bertin-Mahieux et al.
[2011] ( 515 , 345 points of dimension 90 )
Census Kohavi et al.
[1996] ( 2 , 458 , 285 points of dimension 68 ).
We did not alter in any way the dimensions of the data.
For each dataset, we only keep a 5 , 000 points for each experiment as suffices to show the merits and limitations of the different approaches; we also confirm that the relative behavior of the algorithms remains the same over the whole sequence of updates on one of the dataset that we consider.
We consider the L 2 distances of the embedding, and add 1 / 5000 to each distance to avoid having distances zero while not disturbing the structure of the instance.
Order of updates.
We consider insertions and deletions of points under the sliding window model, where we order the points according to some permutation, and then we consider an interval (a.k.a., window) of ℓ = 1 , 000 indices, which we slide from the beginning to the end of the ordered points and at each step form an instance containing the points that lie within the window limits; that is, as we slide the window, the new point that gets within the limits of the window is treated as an insertion, while each point that falls outside the window limits is treated as a deletion.
Choice of facilities.
We consider two different processes for choosing the set of facilities and their opening cost.
The first way is to pick uniformly at random 5% of the point in the instance, remove them from the set of clients, and make them facilities.
In the second variant we use 50% of the points as facilities.
Using these two processes we generate six families of instances:
Census -
Census -50%, KDD-Cup -5%, KDD-Cup -50%, song -5%, and song -50%.
These instances aim to cover the settings where the set of facilities is very restrictive or very broad, in order to assess the behavior of the algorithms in both of these settings.
We set the facility opening costs within a range to ensure that the problem does not become too easy; that is, we don’t want to the trivially good solutions of either opening only a single, or opening all facilities.
We set the facility weights as follows: for a given instance, we calculated the median distance of clients to their nearest facility, and multiplied this number by 100 .
Algorithms We compare our algorithm against two main competing algorithms: 1) Following each point insertion or deletion, we rerun from scratch the offline Greedy algorithm Jain et al.
[2003], which we call G REEDY O FF and 2)
The state of the art
O
(log( m )) approximation algorithm for the fully-dynamic facility location problem from Guo et al.
[2020], which we call GKLX (from the authors last names).
We also compare our algorithm to the baseline that simply maintains open the nearest facility of each of client.
We call this baseline N EAREST F ACILITY .
The behavior of our algorithm depends on two parameters: µ and ϵ .
The parameter ϵ defines the base of the exponential bucketing scheme, and the parameter µ defines the level κ ∗ ij (see Invariant 3), so that (1+ ϵ ) κ ∗ ij − µ − 1 ≤ d ij < (1+ ϵ ) κ ∗ ij − µ .
In Section 2.2 we set ϵ = 1 and µ = 3 for ease of analysis.
Both of these control parameters trade-off between running time, approximation, and recourse.
While our theoretical part covers the case where µ ≥ 3 and ϵ = 1 , we go beyond what is proven and explore setting values µ ∈ { 1 , 3 } and ϵ ∈ { 0 . 05 , 1 } .
We use N ICE C LUSTERING ( µ = 1 , ϵ = 0 . 05) ,
N ICE C LUSTERING ( µ = 1 , ϵ = 1) , N ICE C LUSTERING ( µ = 3 , ϵ = 0 . 05) , N ICE C LUSTERING ( µ = 3 , ϵ = 1) to refer to the different configurations of our algorithm.
We note that we did not try to optimize µ and ϵ to minimize the approximation guarantee (the main goal was to get any constant) for simplicity of the presentation and the analysis, although we believe this is doable.
We defer the interested reader to Appendix D for implementation details.
Setup.
All of our code is written in C++ and is available online 6 .
We used a e2-standard-16 Google
Cloud instance, with 16 cores, 2.20GHz Intel(R) Xeon(R) processor, and 64 GiB main memory.
3.1 Results
Throughout this section, as the relative behavior of the algorithms is similar among the different datasets, we use the KDD-Cup -5% and KDD-Cup -50% datasets to analyze the performance of the algorithm, and summarize the behavior of the algorithms for the rest of the datasets (we defer the detailed description and the plots of the remaining datasets to Appendix E).
Given that our process of creating the instances contain randomized decisions, we repeat each of our experiments 10 times and report the mean relative behavior of the algorithms in Appendix F.
For visualization purposes, we discuss the outcome of a single experiment; repeating the experiment multiple times does not alter significantly the relative behavior of the algorithms.
Moreover, we assessed the performance of N ICE C LUSTERING ( µ = 1 , ϵ = 0 . 05) , it performs identically to N ICE C LUSTERING ( µ = 3 , ϵ = 0 . 05) in terms of solution cost and time, but exhibits slightly larger recourse.
Hence, we omit it to avoid complicating the plots and tables.
Finally, we only run G REEDY O FF on the datasets KDD-Cup -5% and KDD-Cup -50%, and only once, for illustration purposes as it is very computationally expensive to run.
Solution cost.
We analyze the different algorithms in terms of the cost of their solution.
Figuresummarizes the results for both settings where we consider 5% and 50% of the points to be facilities.
As expected, the smaller the values of µ and ϵ in N ICE C LUSTERING , the better the solution quality.
N ICE C LUSTERING ( µ = 3 , ϵ = 0 . 05) perform almost identically to G REEDY O FF , which is an algorithm that is very computationally expensive.
Over 10 repetitions, N ICE C LUSTERING ( µ = 3 , ϵ = 0 . 05) performs roughly 17% − 29% better and 55% − 67% better than GKLX on KDD-Cup5% and KDD-Cup -50%, respectively.
The > 55% happens because in this particular dataset there are a few facilities with small distances to many clients, GKLX prioritizes minimizing opening costs rather than connection cost in this case.
On the other datasets N ICE C LUSTERING ( µ = 3 , ϵ = 0 . 05) outperforms GKLX by 14% − 30% (see Appendix E).
Recourse.
Next, we study the recourse occurred by each of the algorithms that we consider on the datasets KDD-Cup -5% and KDD-Cup -50%.
Figure 3 summarizes the results of this experiment.
While all algorithms, except G REEDY O FF , have limited recourse (considering the window size is 1 , 000 and the length of the update sequence is 9 , 500 and 5 , 000 for KDD-Cup -5% and KDD-
Cup -50%, respectively)
, GKLX performs the best (N EAREST F ACILITY trivially has no recourse).
Naturally, smaller values of µ and ϵ in our algorithm make perform closer to G REEDY O FF (which has no recourse guarantees) in terms of cost, implying higher recourse.
While GKLX performs better than N ICE C LUSTERING on KDD-Cup -5%, they are comparable on KDD-Cup -50%.
Repeating the experiment 10 times show similar relative behavior.
Running time.
As expected, our algorithm is slower compared to GKLX.
N ICE C LUSTERING ( µ = 3 , ϵ = 1) N ICE C LUSTERING ( µ = 1 , ϵ = 1) are one order of magnitude slower.
This is dues to the fact that GKLX, apart from the initial preprocessing phase and determining the nearest facility to each client, spends only polylogarithmic time per update as it operates on a tree structure of logarithmic depth.
In fact, after the preprocessing phase, GKLX does not need to store the connections between clients and facilities; it suffices to remember the nearest facility to each client.
The reduced space allows better cashing and fewer main memory accesses.
On the other hand, our algorithm stores explicitly the connection costs of clients and visit them regularly.
N ICE C LUSTERING ( µ = 3 , ϵ = 0 . 05) is slower by another order of magnitude, due to the increased number of level in our algorithm.
We refer to Appendix E.1 for the running time plots.
Finally, G REEDY O FF is over two orders of magnitude slower compared to the slowest of the variants of our algorithm.
Consistency over the long sequence of updates To showcase that the relative behavior of the algorithms is not affected by our choice to restrict each datasets to the first 5000 points, we run the algorithm on whole KDD-Cup dataset consisting of 311,029 points, where we choose 250 points as facilities (the same absolute number as in the case of KDD-Cup -5%).
Similarly to the rest of the experiments, we consider insertions and deletions of points under the sliding window model (with ℓ = 1000 ).
We refer to this instance as Full- KDD-Cup .
We compare the most competitive algorithms, that is N ICE C LUSTERING ( µ = 3 , ϵ = 1) ,
N ICE C LUSTERING ( µ = 1 , ϵ = 1) , and GKLX in terms of the total cost, and recourse; the results are shown in Figure 4.
The conclusions from the previous experiments on the restricted dataset hold also in this experiment.
However, we observe two behaviors.
First, the performance of GKLX fluctuates more compared to N ICE C LUSTERING ( µ = 3 , ϵ = 1) and N ICE C LUSTERING ( µ = 1 , ϵ = 1) .
This can be attributed to the fact that the algorithm doesn’t adapt rapidly to the changes in the instance.
To a lesser extend, the behavior of N ICE C LUSTERING ( µ = 3 , ϵ = 1) also fluctuates more than N ICE C LUSTERING ( µ = 1 , ϵ = 1) , for the same reasons.
The second observation is that while N ICE C LUSTERING ( µ = 3 , ϵ = 1) and GKLX incur very little recourse, while N ICE C LUSTERING ( µ = 1 , ϵ = 1) continuously incurs (limited) recourse.
These two observations are related.
This implies that N ICE C LUSTERING ( µ = 1 , ϵ = 1) adapts more rapidly to the changing dataset so that it is able to maintain a better solution.
Conclusion of Experiments.
We showed that our algorithm outperforms, often significantly, in terms of solution cost the GKLX algorithm, but in some cases exhibits an increase in recourse (while still being a small absolute number) and it is also slower.
We believe the our algorithm is a good fit for applications where solution quality is very important, and one wants to maintain a stable solution in reasonable time.
Given that our algorithm performs almost in par with G REEDY O FF , it becomes a good choice in cost-sensitive applications on dynamic data.
Acknowledgments and Disclosure of Funding
Paper checklist
Q (a
Do
the main claims
made in the abstract and introduction accurately reflect the paper’s contributions and scope
A:
Yes.
We prove the claims for
theoretical
guarantee, and
conduct the appropriate experiments to support
our
claims on
performance.
Q (b): Have you read the ethics review guidelines and ensured that
your
paper conforms to them?
A:
Yes.
Q (c):
Did you discuss any potential negative societal impacts of your work
A: No.
This paper studies a basic algorithmic question.
We are not aware of direct applications of the facility location problem with negative societal impact
Our findings and code are made openly available for all
Q (d): Did you describe the limitations of your work?
A:
Yes.
In the experimental section we discuss both strengths and weaknesses of our algorithm
On theoretical results
Q (a): Did you state the full set of assumptions of all theoretical results?
A: yes.
Q (b): Did you include complete proofs of all theoretical results?
A: yes.
On experiments
Q (a): Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
A:
No.
We will the code is made available.
Q (b): Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
A:
There is no training in this paper.
Q (c): Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
A:
Yes, we repeated the experiments 10 times, and report the mean and standard deviation in the Appendix F. Q (d): Did you include the amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
A:
Yes.
The experimental section reports the type of machine that we used.
On using existing assets.
Q (a): If your work uses existing assets, did you cite the creators?
A:
Yes.
We cited the datasets that we used.
Q (b): Did you mention the license of the assets?
A:
No.
These datasets have no individual licences in the UCI repository.
Q (c): Did you include any new assets either in the supplemental material or as a URL?
A:
No.
We released the code.
Q (d): Did you discuss whether
and how consent was obtained from people whose data you’re using/curating?
A:
Yes.
They the data are available at the UCI machine learning repository, and no additional licence is reported.
Q (e): Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
A:
No.
This is clear since the data are simply embeddings.
A Proof of Theorem
By induction hypothesis, suppose that the clustering C satisfies Invariant 1, Invariant 2, Invariantand Invariant 3 just before a given update.
While handling the update, our dynamic algorithm calls the subroutine in Figure 1.
The main W HILE loop in Figure 1 immediately ensures that Invariantand Invariant 4 continue to hold when our dynamic algorithm is done with processing the update.
Moving on to Invariant 2, it is easy to verify that this invariant is not violated by our dynamic algorithm at any point in time.
Specifically, this invariant does not get violated by any step in Figure 1, or by the steps performed immediately before calling the subroutine described in Figure 1.
It now remains to prove that our algorithm always satisfy Invariant 3.
Towards this end, fix any client j ∈ D .
If the client j gets assigned to facility i ∈ F immediately after getting inserted, then the manner in which our algorithm handles an insertion ensures that ℓ ( j ) ≥ κ ∗ ij at that point in time.
Subsequently, consider each of the following two three of events.
(1) The client j remains assigned to the facility i , but moves down to a smaller level (say) k .
This happens only if there is a blocking cluster C
= ( i, A ) with j ∈ A at level k , and we call the subroutine F IX -B LOCKING ( C, k ) .
Hence, Definition 1 ensures that k ≥ κ ∗ ij .
Thus, we continue to have ℓ ( j ) =
k ≥ κ ∗ ij immediately after this event.
The client j remains assigned to the facility i , but moves up to a larger level.
Clearly, this event cannot lead to a violation of Invariant 3.
The client j gets reassigned to a different facility i ′ , by joining a cluster at level k (say) that has facility i ′ as its center.
This happens only if the client j is part of a blocking cluster C ′
=
( i ′ , A ′ ) at level k , with j ′ ∈
A ′ , and we call the subroutine F IX -B LOCKING ( C ′ , k ) .
Hence, Definition 1 ensures that k ≥ κ ∗ i ′ j .
Thus, we continue to have ℓ ( j ) =
k ≥ κ ∗ i ′
j immediately after this event.
The above discussion implies that Invariant 3 continues to remain satisfied all the time, even when the algorithm is handling an update.
This concludes the proof of Theorem 3.
B Proof of Theorem
We first recall the LP relaxation for the facility location problem:
[Equation]
The dual LP is given below.
[Equation]
We will prove Theorem 2 using the primal-dual method.
Specifically, we will show that given any nice clustering, we can come up with a pair of feasible primal and dual solutions whose objectives are within a O (1) multiplicative factor of each other.
For the rest of the proof, fix any nice clustering C .
Based on the clustering C , we construct the following natural primal solution ( x, y ) .
For all i ∈ F , we set y i
= 1 if facility i is open (i.e., if C ( i ) ̸ = ∅ ); otherwise, we set y i = 0 .
Similarly, for all i ∈ F, j ∈ D , we set x ij = 1 if the clustering C assigns client j to facility i ; otherwise, we set x ij = 0 .
It is easy to check that this gives us a feasible primal solution.
Next, based on the clustering
C , we construct an (infeasible) dual solution ( α, β ) as described in Figure 5.
F OR ALL clusters C
= ( i, A ) ∈ C :
[Figure]
F OR ALL clients j ∈
[Figure] [Figure]
[Figure]
We now show that the primal objective at ( x, y ) is at most the dual objective at ( α, β ) .
Lemma 3.
We have
[Equation]
Proof.
The cost of the primal solution ( x, y ) is equal to the total cost of all the clusters in the dual solution ( α, β ) .
Thus, we have:
[Equation]
Next, fix any cluster C
= ( i, A ) ∈ C , and observe that:
[Equation]
The lemma now follows from (10) and (11) and the observation that each client j ∈ A appears in exactly one cluster C ∈ C .
The next lemma shows that ( α/ 2 10 , β ) is a feasible dual solution.
Lemma 4.
For all j ∈ D , define ˆ α j := α j / 2 10 .
Then (ˆ α, β ) is a feasible solution to LP (6).
Theorem 2 follows from Lemma 3 and Lemma 4.
The proof of Lemma 4 appears in Appendix B.1.
B.1 Proof of Lemma
Step 5 of Figure 5 ensures that the solution (ˆ α, β ) satisfies constraint (8) of the dual LP.
It now remains to show that the solution (ˆ α, β ) also satisfies constraint (7) of the dual LP.
This is achieved by Lemma 6.
In other words, Lemma 4 follows from Lemma 6.
Lemma 5.
Consider any facility i ∈ F and clients j, j ′ ∈ D with α j ≥ d ij and α j ′ ≥ d ij ′ .
Then we have:
[Equation]
Proof.
If α j ≤ α j ′ , then the lemma trivially holds; so we assume that α j > α j ′ throughout the rest of the proof.
From step 3 of Figure 5, it follows that each client j ∗ ∈ D appears at a level ℓ ( j ∗ )
= log( α j ∗ ) in the clustering C .
Accordingly, since α j ′ <
α j , we have ℓ ( j ′ ) ≤ ℓ ( j ) − 1 .
Let i ′ denote the facility to which the client j ′ gets assigned in the nice clustering C .
Now we claim that d i ′ j ≥ α j / 2 4 .
For the sake of contradiction, suppose d i ′
j < α j / 2 4 .
We will show that
C :=
( i ′ , { j } ) forms an satellite blocking cluster at level k :=
ℓ ( j ) − 1 .
Towards this end, we note:
• (a) cost avg ( C ) =
d i ′ j < α j · 2 − 4 = 2 ℓ ( j ) − 4 = 2 k − 3 .
• (b) ℓ ( j ) >
k ≥ κ ∗ i ′ j , where κ ∗ i ′
j is the unique level such that 2 κ ∗ i ′
j − 4 ≤ d i ′ j < 2 κ ∗ i ′ j − 3 .
Here, the first inequality holds because k
=
ℓ (
j
− 1 , whereas the second inequality holds
because 2 κ ∗ i ′ j − 4 ≤ d i ′ j < 2 k − 3 as per condition (a) above.
• (c) Since i ′ is the center of a cluster at level ℓ ( j ′ ) and C is a nice clustering, there exists a critical cluster C ′ ∈ C
( i ′ )
with ℓ ( C ′ ) ≤ ℓ ( j ′ ) ≤ ℓ ( j ) − 1 = k .
Conditions (a), (b) and (c) imply that C
=
( i ′ , { j } ) is an satellite blocking cluster at level ℓ ( j ) − 1 , as per Definition 1.
This contradicts the fact that C is a nice clustering.
Hence, we get:
[Equation]
Next, since client j ′ ∈ D is assigned to facility i ′ ∈ F in the nice clustering C , by Invariant 3 we have κ ∗ ij ′ ≤ ℓ ( j ′ ) .
This implies that:
[Equation]
i
[Equation]
Applying triangle inequality, we now obtain d
i ′ j ≤ d i
[Equation]
(the last inequality follows from (13)), and d ij ′ ≤ α j ′ by our starting assumption).
Thus, from (12) we infer that: α j / 2 4 ≤ d i ′ j ≤
α ′ j + d ij .
Lemma 6.
For every facility i ∈ F , we have (cid:80) j ∈ D max (cid:0) 0 , α j 2 10 − d ij (cid:1) ≤ f i .
Proof.
Fix a facility i ∈ F for the rest of the proof.
Define C i := (cid:8) j ∈ D | α j 2 10 ≥ d ij (cid:9) .
Note that:
[Equation] [Equation]
Accordingly, for the rest of the proof, we focus on upper bounding the right hand side of (14).
For ease of notations, we assume that C i
= { j 1 , . .
. , j q } and w.l.o.g.
α j 1 ≤ α j 2 ≤ · · · ≤ α j q .
Say that a client j ∈ C i is big if d ij ≥ α j 1 / 2 4 and small otherwise.
Let B ⊆ C
i and S =
C i \ B respectively denote the set of all big and small clients in C i .
Observe that:
[Equation]
Next, we claim that:
[Equation]
For the sake of contradiction, suppose that (16) does not hold.
Then we have:
[Equation]
We now consider two possible cases.
Case 1: There is no critical cluster in C ( i ) at level ≤ k := ℓ ( j 1 ) − 1 = log( α j 1 ) − 1 .
In this case, consider the critical cluster C :
= ( i, S ) .
We will show that C is a blocking cluster at level k w.r.t.
the clustering C .
To see why this is true, observe that:
• (a) cost avg ( C ) :
=
f i + (cid:80) j ∈ S
d ij | S
[Equation]
• (b) Consider any client j ∈ S .
Since α j ≥ α j 1 , we have ℓ ( j ) =
log
( α j ) ≥ log( α j 1 ) =
ℓ ( j 1 ) > k .
Furthermore, since j ∈ S , we have d ij < α j 1 / 2
= 2 k − 3 .
This implies that k ≥ κ ∗ ij , where κ ∗ ij is the unique level such that 2 κ ∗ ij − 4 ≤ d ij < 2 κ ∗ ij − 3 .
To summarize, we infer that ℓ ( j ) > k ≥ κ ∗ ij for all clients j ∈ S .
• (c) We have ℓ ( C ′ ) >
k for all clusters C ′ ∈ C
( i ) .
This follows from Invariant 2 and our assumption that there is no critical cluster in C ( i ) at level ≤ k .
Conditions (a), (b) and (c) above imply that C is a critical blocking cluster at level k w.r.t.
the clustering C , as per Definition 1.
But this contradicts the fact that C is a nice clustering.
Thus, we conclude that (16) holds in this case.
Case 2: There is a critical cluster C ∗ ∈ C ( i ) at level ℓ ( C ∗ ) ≤ k .
In this case, let j ∈ S be a client
such that d ij = min j ′ ∈ S
d ij ′ .
Consider the satellite cluster
C :=
( i, { j } ) .
We will show that C is a blocking cluster at level k :=
ℓ ( j 1 ) − 1 w.r.t.
the clustering
C .
To see why this is true, observe that:
• (a) cost avg ( C ) :
[Equation]
ij
[Equation]
• (b) Since α j ≥ α j 1 , we have ℓ ( j ) =
log
( α j ) ≥ log( α j 1 ) =
ℓ ( j 1 ) > k .
Furthermore, since j ∈ S , we have d ij < α j 1 / 2
= 2 k − 3 .
This implies that k ≥ κ ∗ ij , where κ ∗ ij is the unique level such that 2 κ ∗ ij − 4 ≤ d ij < 2 κ ∗ ij − 3 .
To summarize, we infer that ℓ ( j ) > k ≥ κ ∗ ij .
• (c) There is a critical cluster C ∗ ∈ C ( i ) at level ℓ ( C ∗ ) ≤ k .
Conditions (a), (b) and (c) above imply that C is an satellite blocking cluster at level k w.r.t.
the clustering C , as per Definition 1.
But this contradicts the fact that C is a nice clustering.
Thus, we conclude that (16) holds in this case as well.
To summarize, we have proved that (16) holds.
Thus, from (15) and (16), we get:
[Equation]
Now consider any client j ∈ C i .
Since j, j 1 ∈ C i , by definition we have d ij ≤ α j and d ij 1 ≤ α j 1 .
Accordingly, Lemma 5 gives us:
[Equation]
Summing (19) over all the clients j ∈ C
i , we get:
[Equation]
(follows from (18))
[Equation]
The lemma now follows from (14) and (20).
C Proof of Lemma
We use the notations introduced in the paragraph just before the statement of Lemma 2.
Note that during its entire lifetime, our algorithm performs (cid:80) λr =
| A r | units of up-work on the cluster C .
Accordingly, Lemma 2 follows from Claim 1.
Claim 1.
We have (cid:80) λr =
| A r | ≤ f i / 2 k − 2 .
Proof.
Consider a given round r ∈ [0 , λ ] .
For all j ∈ A r , we have d ij < 2 κ ∗ ij − 3 ≤ 2 k + r − 3 , where the last inequality follows from Invariant 3 (this is because every client j ∈
A r is at level k + r just before the end of epoch r ).
The cluster C =
( i, A ) moves up to level k + r + 1 because cost avg ( C ) > 2 k + r .
Thus, we conclude that:
[Equation]
A r | = cost avg (( i, A r )) > 2 k + r .
Multiplying both sides of the above inequality by | A r | and then rearranging the terms, we get: f i > (cid:0) 2 k + r − 2 k + r − 3 (cid:1) · | A r | ≥ 2 k + r − 1 · | A r | .
So, we have | A r | ≤ f i 2 k
+ r − 1 for all r ∈ [0 , λ ] .
This gives us: (cid:80) λr =
| A r | ≤ (cid:80) λr =
f
i 2 k + r ≤ f i 2 k − 2 .
D Implementation details
In this section we describe how to implement our algorithm to perform only ˜ O ( m ) amortized time per update, and also the cases where we deviate from the straightforward implementation as described in Section 2.3.
Client insertions.
Following the insertion of a client j , we first try to connect it to its nearest open facility
i (by either adding it to the critical cluster centered at i , or create the satellite cluster ( i, { j } ) ), instead trying to connect it to any open facility i ∈ F as described in Section 2.3.
Efficient implementation of Routine F IX -C LUSTERING ( . ) .
We describe how to implement the routine so that, it requires ˜ O ( m ) amortized time per update.
In particular, we describe an implementation that takes ˜ O ( m ) per update, plus O ( m ) time per each level change of a client.
The latter is still withing the ˜ O ( m ) amortized bound, as each client changes levels O (log m ) times on average (see
Section 2.4).
First we need an efficient mechanism to detect whether there is a blocking cluster violating invariant 4, or if there exists a cluster violating invariant 1.
Then, we are going to describe how we implement the subroutines
F IX -B LOCKING ( C, k ) and F IX -L EVEL ( C ) that restore the invariants of the algorithm.
We describe our data structure as if we had a parameter ϵ that defines the base of the exponential bucketing scheme, despite setting it to ϵ ← 1 in Section 2.3.
Checking for violations of invariants 4 and 1.
Notice, that by simply maintaining the average cost of each critical cluster one can simply iterate over all critical clusters (which are O ( m ) ) and check whether Invariant 1 is violated.
Satellite clusters need to be checked only at their creation time, as their set of clients and subsequently their average cost does not change.
Hence, we don’t need to iterate over the satellite clusters at each iteration inside F IX -C LUSTERING ( . ) .
In fact, each satellite cluster is checked iteratively until it is placed at the right level following its creation (either by inserting a new client, or by converting a critical cluster into an satellite one), and the time for all of these check is accounted in the bound of the up-work and down-work, which is O (log m ) amortized per update.
Checking for violations of Invariant 4 efficiently requires an additional data structure.
Conceptually, for each facility i , we maintain a two-dimensional matrix W of counters of dimensions log (1+ ϵ ) (∆) × ( ℓ max − ℓ min ) , where ℓ max , ℓ min the maximum and minimum level that are non-empty at any point in time ∆ the ratio of the largest distance over the smallest distance between a client and a facility.
The entry W [ x, y ] contains the number of clients that are at distance in the interval [(1 + ϵ ) x − 1 , (1 + ϵ ) x ) from facility i and are currently placed at level y .
This matrix has size at most O (log 2(1+ ϵ ) (∆))
(which is O (log 2 ( m )) as we assume ∆ is polynomially bounded by m ), but can be sparsified by maintaining a two dimensional hash table containing only the entries with positive counter values, while still maintaining constant time access with high probability.
Although we implement the sparse version of this data structure, for ease of description we assume that we maintain the full matrix W .
Using the matrix W for facility i , we check whether there exists a blocking cluster at level ℓ centered at a facility i as follows.
We iterate over all entries of W [ x, y ] such that y > ℓ , and in increasing order of the x coordinate.
Each time we visit an entry W [ x, y ] we check whether the following inequality holds:
[Equation]
and if it does then we determine that facility i forms a blocking cluster at level ℓ .
By maintaining appropriate running summations, we can iterate over the appropriate entries of the matrix, each time testing the aforementioned inequality, in time linear in the size of the matrix.
Notice that due to the bucketisation of the distances in powers of (1 + ϵ ) , we lose another factor of (1 + ϵ ) in the approximation; that is we say that a cluster is blocking at level ℓ only if its average cost is below (1 + ϵ ) ( ℓ − 1) instead of if its average cost is below (1 + ϵ ) ℓ , which increases the approximation by another (1 + ϵ ) factor.
Finally, notice that to maintain the matrix W of each facility updated, we only need to spend constant time each time a client changes levels (as the distance between a facility and a client does not change).
That is, for each client changing levels, we spend O ( m ) time to update the matrices of all facilities.
A client can change levels at most O (log m ) times, as described in Section 2.4.
Hence, one can check whether there exists a blocking cluster in amortized time ˜ O
( m ) over the sequence of all updates.
In order to identify the actual blocking cluster one can do that in time proportional to the size of the blocking cluster: One needs to maintain the neighbors of each facility in increasing distance at each level and visit them in increasing distance from the facility and only at the levels that are eligible (that is, levels greater then ℓ ).
Implementing subroutines F IX -B LOCKING ( C, k ) and F IX -L EVEL ( C ) .
The subroutines F IXB LOCKING ( C, k ) and F IX -L EVEL ( C ) perform the necessary changes to the maintained clustering to restore any violations to the invariants of the algorithm.
The only two scenarios that causes a client to be assigned to a different cluster at the same level are 1) the case where operation F IX -L EVEL ( C ) increases the level of a critical cluster, which causes the critical cluster to merge with other satellite clusters of the destination level, and 2) the case where a critical cluster gets converted into a set of satellite clusters at the same level.
In both of these scenarios, we can charge the work to the time spent creating the satellite clusters by insertions of new (which is O (1) per update), plus the time of creating the critical clusters which then get converted into satellite clusters and is at most O
log m ) amortized per udpate.
In all other cases, whenever a client changes the cluster to which it is assigned, it also changes levels.
As discussed in Section 2.4, the number of changes of levels of clients is O (log m ) amortized.
This implies that the amortized time spent in the subroutines F IX -B LOCKING ( C, k ) and
F IX -L EVEL ( C ) is O (log m ) per update.
E Missing experiments E.1 Missing experiments for KDD-Cup dataset
E.2 Experiments for Census dataset
In terms of cost, N ICE C LUSTERING ( µ = 3 , ϵ = 0 . 05) algorithm performs overall the best on the Census -
% and Census -50% instances.
In particular, it maintains solutions that are 20%- 30% better compared to GKLX on average over the whole sequence of updates on the Census datasets.
On the other hand N ICE C LUSTERING ( µ = 1 , ϵ = 1) performs roughly 10% worse than
N ICE C LUSTERING ( µ = 3 , ϵ = 0 . 05) , but better than GKLX.
N ICE C LUSTERING ( µ = 3 , ϵ = 1) runs roughly 70%-80% worse than N ICE C LUSTERING ( µ = 3 , ϵ = 0 . 05) , and has the worse performance in terms of cost overall.
The behavior of the algorithms, for a single run, is summarized in Figure 7.
In terms of recourse, N ICE C LUSTERING ( µ = 3 , ϵ = 0 . 05) exhibits higher recourse than GKLX, by nearly two orders of magnitude on Census
-5%, while GKLX11 incurs around 10 × recourse compared to GKLX.
In all cases, recourse remains relatively low in absolute value (around 100 ), especially considering the lengths of the update sequence and the instance sizes.
The behavior of the algorithms, for a single run, is summarized in Figure 8.
The running time of the algorithms on the Census instances is very similar to that on the KDD-Cup instances, as described in the main body of the paper.
F Comparing the relative behavior of the algorithms over multiple runs
Comparison of algorithms In order to compare the relative behavior over multiple repetitions of each experiment that we consider, we proceed as follows.
Consider the case where we want to compare the cost of the solution produced by algorithm A 1 to the cost of the solution produced by algorithm
A 2 .
For each dataset that we consider and each repetition of an experiment we average the ratio cost i ( A 1 ) /cost
i ( A 2 ) , for all 1 ≤ i ≤ max u , where cost i ( A ) the cost of the solution produced by algorithm A on the instance following the i -th update and max u the total number of updates.
Denote this average by ϕ ( A 1 , A 2 ) =
(cid:16)(cid:80) max u i =
[Table]
i ( A 2 ) (cid:17) /max
u .
This gives us the relative behavior of the two algorithms with respect to the cost of the solution that they produce, on average, over the whole sequence of updates, for a single repetition.
We use the same methodology to compare the cumulative recourse of two algorithms, which we spell out for clarity.
For each dataset that we consider and each repetition of an experiment we average the ratio recourse i ( A 1 ) /recourse
i ( A 2 ) , for all 1 ≤ i ≤ max u , where recourse i ( A ) the cumulative recourse of the solution maintained by algorithm A following the i -th update.
Denote this average by ψ ( A 1 , A 2 ) =
(cid:16)(cid:80) max u i =
recourse i (
A 1 )+1 recourse i
( A 2 )+1 (cid:17) /max
u .
We add +1 to both the nominator and denominator to avoid division with 0.
To aggregate the behavior over multiple repetitions, we report the mean and the standard deviation of ϕ
( A 1 , A 2 ) and ψ ( A 1 , A 2 ) over 10 repetitions of the experiment.
F.1 Results
[Table]
[Table]
[Table] [Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Equation]
[Table]