Competitive Analysis for Two Variants of Online Metric Matching Problem
aa r X i v : . [ c s . D S ] S e p Competitive Analysis for Two Variants of OnlineMetric Matching Problem ⋆ Toshiya Itoh , Shuichi Miyazaki , and Makoto Satake Department of Mathematical and Computing Science, Tokyo Institute ofTechnology, 2-12-1 Ookayama, Meguro-ku, Tokyo 152-8550, Japan [email protected] Academic Center for Computing and Media Studies, Kyoto University,Yoshida-Honmachi, Sakyo-ku, Kyoto 606-8501, Japan [email protected] Graduate School of Informatics, Kyoto University,Yoshida-Honmachi, Sakyo-ku, Kyoto 606-8501, Japan [email protected]
Abstract.
In this paper, we study two variants of the online metricmatching problem. The first problem is the online metric matching prob-lem where all the servers are placed at one of two positions in the metricspace. We show that a simple greedy algorithm achieves the competi-tive ratio of 3 and give a matching lower bound. The second problemis the online facility assignment problem on a line, where servers havecapacities, servers and requests are placed on 1-dimensional line, and thedistances between any two consecutive servers are the same. We showlower bounds 1+ √ > . √ ( > . ( > . Keywords:
Online algorithm, Competitive analysis, Online matchingproblem
The online metric matching problem was introduced independently by Kalyana-sundaram and Pruhs [7] and Khuller, Mitchell and Vazirani [10]. In this problem, n servers are placed on a given metric space. Then n requests , which are pointson the metric space, are given to the algorithm one-by-one in an online fashion.The task of an online algorithm is to match each request immediately to oneof n servers. If a request is matched to a server, then it incurs a cost which isequivalent to the distance between them. The goal of the problem is to minimizethe sum of the costs. The papers [7] and [10] presented a deterministic online ⋆ This work was partially supported by the joint project of Kyoto University andToyota Motor Corporation, titled “Advanced Mathematical Science for MobilitySociety” and JSPS KAKENHI Grant Numbers JP16K00017 and JP20K11677. T. Itoh et al. algorithm (called
Permutation in [7]) and showed that it is (2 n − online matching problem on a line . Since then,this problem has been extensively studied, but there still remains a large gapbetween the best known lower bound 9.001 [5] and upper bound O (log n ) [16]on the competitive ratio.In 2020, Ahmed, Rahman and Kobourov [1] proposed a problem called the online facility assignment problem and considered it on a line, which we denote OFAL for short. In this problem, all the servers (which they call facilities ) andrequests (which they call customers ) lie on a 1-dimensional line, and the dis-tance between every pair of adjacent servers is the same. Also, each server hasa capacity , which is the number of requests that can be matched to the server.In their model, all the servers are assumed to have the same capacity. Let usdenote OFAL( k ) the OFAL problem where the number of servers is k . Ahmedet al. [1] showed that for OFAL( k ) the greedy algorithm is 4 k -competitive forany k and a deterministic algorithm Optimal-fill is k -competitive for any k > In this paper, we study a variant of the online metric matching problem whereall the servers are placed at one of two positions in the metric space. This isequivalent to the case where there are two servers with capacities. We show thata simple greedy algorithm achieves the competitive ratio of 3 for this problem,and show that any deterministic online algorithm has competitive ratio at least3. We also study OFAL( k ) for small k . Specifically, we show lower bounds 1+ √ > . √ ( > . ( > . √ √ for OFAL(4) do not contradict the above-mentioned upper bound of Optimal-fill, since upper bounds by Ahmed et al. [1]are with respect to the asymptotic competitive ratio, while our lower bounds arewith respect to the strict competitive ratio (see Sec. 2.3). In 1990, Karp, Vazirani and Vazirani [9] first studied an online version of thematching problem. They studied the online matching problem on unweighted bi-partite graphs with 2 n vertices that contain a perfect matching, where the goalis to maximize the size of the obtained matching. In [9], they first showed thata deterministic greedy algorithm is -competitive and optimal. They also pre-sented a randomized algorithm Ranking and showed that it is (1 − e )-competitiveand optimal. See [12] for a survey of the online matching problem. ompetitive Analysis for Two Variants of Online Metric Matching Problem 3 As mentioned before, Kalyanasundaram and Pruhs [7] studied the onlinemetric matching problem and showed that the algorithm
Permutation is (2 n − Work-Function algorithm has a constant competitive ratio,both of which were later disproved in [11] and [5], respectively. This problemwas studied in [2, 3, 6, 14–16], and the best known deterministic algorithm is the
Robust Matching algorithm [15], which is Θ (log n )-competitive [14, 16].Besides the problem on a line, Ahmed, Rahman and Kobourov [1] studiedthe online facility assignment problem on an unweighted graph G ( V, E ). Theyshowed that the greedy algorithm is 2 | E | -competitive and Optimal-Fill is | E | kr -competitive, where | E | is the number of edge of G and r is the radius of G . In this section, we give definitions and notations.
We define the online metric matching problem with two servers, denotedOMM(2) for short. Let (
X, d ) be a metric space, where X is a (possibly infi-nite) set of points and d ( · , · ) is a distance function. Let S = { s , s } be a set ofservers and R = { r , r , . . . , r n } be a set of requests. A server s i is characterizedby the position p ( s i ) ∈ X and the capacity c i that satisfies c + c = n . Thismeans that s i can be matched with at most c i requests ( i = 1 , r i is also characterized by the position p ( r i ) ∈ X . S is given to an online algorithm in advance, while requests are given one-by-one from r to r n . At any time of the execution of an algorithm, a server iscalled free if the number of requests matched with it is less than its capacity, and full otherwise. When a request r i is revealed, an online algorithm must match r i with one of free servers. If r i is matched with the server s j , the pair ( r i , s j )is added to the current matching and the cost d ( r i , s j ) is incurred for this pair.The cost of the matching is the sum of the costs of all the pairs contained in it.The goal of OMM(2) is to minimize the cost of the final matching. We give the definition of the online facility assignment problem on a line with k servers, denoted OFAL( k ). We state only differences from Sec. 2.1. The setof servers is S = { s , s , . . . , s k } and all the servers have the same capacity ℓ ,i.e., c i = ℓ for all i . The number of requests must satisfy n ≤ P ki =1 c i = kℓ .All the servers and requests are placed on a real number line, so their positionsare expressed by a real, i.e., p ( s i ) ∈ R and p ( r j ) ∈ R . Accordingly, the distance T. Itoh et al. function is written as d ( r i , s j ) = | p ( r i ) − p ( s j ) | . We assume that the servers areplaced in an increasing order of their indices, i.e., p ( s ) ≤ p ( s ) ≤ . . . ≤ p ( s k ).In this problem, any distance between two consecutive servers is the same, thatis, | p ( s i ) − p ( s i +1 ) | = d (1 ≤ i ≤ n −
1) for some constant d . Without loss ofgenerality, we let d = 1. To evaluate the performance of an online algorithm, we use the strict competitiveratio . (Hereafter, we omit “strict”.) For an input σ , let ALG ( σ ) and OP T ( σ ) bethe costs of the matchings obtained by an online algorithm ALG and an optimaloffline algorithm
OP T , respectively. Then the competitive ratio of
ALG is thesupremum of c that satisfies ALG ( σ ) OP T ( σ ) ≤ c for any input σ . In this section, we define a greedy algorithm
GREEDY for OMM(2) and showthat it is 3-competitive.
Definition 1.
When a request is given,
GREEDY matches it with the closestfree server. If a given request is equidistant from the two servers and both serversare free,
GREEDY matches this request with s . In the following discussion, we fix an optimal offline algorithm
OP T . If arequest r is matched with the server s x by GREEDY and with s y by OP T , wesay that r is of type h s x , s y i . We then define some properties of inputs. Definition 2.
Let σ be an input to OMM( ). If every request in σ is matchedwith a different server by GREEDY and
OP T , σ is called anti-opt . Definition 3.
Let σ be an input to OMM( ). Suppose that GREEDY matchesits first request r to the server s x ∈ { s , s } . If GREEDY matches r through r c x to s x (note that c x is the capacity of s x ) and r c x +1 through r n to the otherserver s − x , σ is called one-sided-priority . For an input σ , we define Rate ( σ ) = GREEDY ( σ ) OP T ( σ ) . By the following twolemmas, we show that it suffices to consider inputs that are anti-opt and one-sided-priority. We then show that GREEDY is 3-competitive for such inputs.
Lemma 1.
For any input σ , there exists an anti-opt input σ ′ such that Rate ( σ ′ ) ≥ Rate ( σ ) .Proof. If σ is already anti-opt, we can set σ ′ = σ . Hence, in the following,we assume that σ is not anti-opt. Then there exists a request r in σ that ismatched with the same server s x by OP T and
GREEDY . Let σ ′′ be an input ompetitive Analysis for Two Variants of Online Metric Matching Problem 5 obtained from σ by removing r and subtracting the capacity of s x by 1. By thismodification, neither OP T nor
GREEDY changes a matching for the remainingrequests. Therefore,
Rate ( σ ′′ ) = GREEDY ( σ ) − d ( r, s x ) OP T ( σ ) − d ( r, s x ) ≥ GREEDY ( σ ) OP T ( σ )= Rate ( σ ) . Let σ ′ be the input obtained by repeating this operation until the inputsequence becomes anti-opt. Then σ ′ satisfies the conditions of this lemma. ⊓⊔ Lemma 2.
For any anti-opt input σ , there exists an anti-opt and one-sided-priority input σ ′ such that Rate ( σ ′ ) ≥ Rate ( σ ) .Proof. If σ is already one-sided-priority, we can set σ ′ = σ . Hence, in the follow-ing, we assume that σ is not one-sided-priority.Since σ is anti-opt, σ contains only requests of type h s , s i or h s , s i . With-out loss of generality, assume that in execution of GREEDY , the server s becomes full before s , and let r t be the request that makes s full (i.e., r t is thelast request of type h s , s i ).Because σ is not one-sided-priority, σ includes at least one request r i of type h s , s i before r t . Let σ ′′ be the input obtained from σ by moving r i to just after r t . Since the set of requests is unchanged in σ and σ ′′ , an optimal matching for σ is also optimal for σ ′′ , so OP T ( σ ′′ ) = OP T ( σ ). In the following, we show that GREEDY matches each request to the same server in σ and σ ′′ . The sequenceof requests up to r i − are the same in σ ′′ and σ , so the claim clearly holdsfor r through r i − . The behavior of GREEDY for r i +1 through r t in σ ′′ isalso the same for those in σ , because when serving these requests, both s and s are free in both σ and σ ′′ . Just after serving r t in σ ′′ , s becomes full, so GREEDY matches r i , r t +1 , . . . , r n with s in σ ′′ . Note that these requests arealso matched with s in σ . Hence GREEDY ( σ ′′ ) = GREEDY ( σ ) and it resultsthat Rate ( σ ′′ ) = Rate ( σ ). Note that σ ′′ remains anti-opt.Let σ ′ be the input obtained by repeating this operation until the input se-quence becomes one-sided-priority. Then σ ′ satisfies the condition of the lemma. ⊓⊔ We can now prove the upper bound.
Theorem 1.
The competitive ratio of
GREEDY is at most 3 for OMM( ).Proof. By Lemma 1, it suffices to analyze only anti-opt inputs. In an anti-optinput, the number of requests of type h s , s i and that of type h s , s i are thesame and the capacities of s and s are n/ n/ h s , s i and theremaining n/ h s , s i . T. Itoh et al.
Let σ be an arbitrary such input. Then we have that GREEDY ( σ ) = n/ X i =1 d ( r i , s ) + n X i = n/ d ( r i , s )and OP T ( σ ) = n/ X i =1 d ( r i , s ) + n X i = n/ d ( r i , s ) . When serving r , r , . . . , r n/ , both servers are free but GREEDY matchedthem with s . Hence d ( r i , s ) ≤ d ( r i , s ) for 1 ≤ i ≤ n/
2. By the triangleinequality, we have d ( r i , s ) ≤ d ( s , s ) + d ( r i , s ) for n/ ≤ i ≤ n . Again,by the triangle inequality, we have d ( s , s ) ≤ d ( r i , s ) + d ( r i , s ) for 1 ≤ i ≤ n .From these inequalities, we have that GREEDY ( σ ) = n/ X i =1 d ( r i , s ) + n X i = n/ d ( r i , s ) ≤ n/ X i =1 d ( r i , s ) + n X i = n/ ( d ( s , s ) + d ( r i , s ))= OP T ( σ ) + n d ( s , s )= OP T ( σ ) + 12 n X i =1 d ( s , s ) ≤ OP T ( σ ) + 12 n X i =1 ( d ( r i , s ) + d ( r i , s ))= OP T ( σ ) + 12 ( OP T ( σ ) + GREEDY ( σ ))= 32 OP T ( σ ) + 12 GREEDY ( σ ) . Thus
GREEDY ( σ ) ≤ OP T ( σ ) and the competitive ratio of GREEDY is atmost 3. ⊓⊔ The competitive ratio of any deterministic online algorithm forOMM( ) is at least 3.Proof. We prove this lower bound on a 1-dimensional real line metric. Let p ( s ) = − d and p ( s ) = d for a constant d . Consider any deterministic algorithm ALG .First, our adversary gives c − p ( s ) and c − p ( s ). ompetitive Analysis for Two Variants of Online Metric Matching Problem 7 OP T matches the first c − s and the rest with s . If thereexists a request that ALG matches differently from
OP T , the adversary givestwo more requests, one at p ( s ) and the other at p ( s ). Then, the cost of OP T is zero, while the cost of
ALG is positive, so the ratio of them becomes infinity.Next, suppose that
ALG matches all these requests with the same server as
OP T . Then the adversary gives the next request at the origin 0. Let s x be theserver that ALG matches this request with. Then
OP T matches this requestwith the other server s − x . After that, the adversary gives the last request at p ( s x ). ALG has to match it with s − x and OP T matches it with s x . The costsof ALG and
OP T for this input is 3 d and d , respectively. This completes theproof. ⊓⊔ In this section, we show lower bounds on the competitive ratio of OFAL( k ) for k = 3 ,
4, and 5. To simplify the proofs, we recall useful properties that allow usto restrict online algorithms to consider [3, 11]. When a request r is given, the surrounding servers for r are the closest free server to the left of r and the closestfree server to the right of r . If, for any input, an algorithm ALG matches everyrequest with one of the surrounding servers,
ALG is called surrounding-oriented . Proposition 1.
For any algorithm
ALG , there exists a surrounding-orientedalgorithm
ALG ′ such that ALG ′ ( σ ) ≤ ALG ( σ ) for any input σ . By Proposition 1, it suffices to consider only surrounding-oriented algorithmsfor lower bound arguments.
Theorem 3.
The competitive ratio of any deterministic online algorithm forOFAL( ) is at least √ > . .Proof. Let
ALG be any surrounding-oriented algorithm. Our adversary firstgives ℓ − p ( s i ) for each i = 1 , OP T matches every re-quest r with the server at the same position p ( r ). If ALG matches some request r with a server not at p ( r ), then the adversary gives three more requests, one ateach position of the server. The cost of ALG is positive and the cost of
OP T iszero, so the ratio of the costs is infinity.Next, suppose that
ALG matches all these requests to the same server as
OP T . Let x = √ − ≃ . y = 3 √ − ≃ . r at p ( s ) + x . Case 1.
ALG matches r with s . See Fig. 1. The adversary gives the next request r at p ( s ). ALG matches itwith s . Finally, the adversary gives a request r at p ( s ) and ALG matches itwith s . The cost of ALG is 2 − x = 4 − √ OP T is x = √ − −√ √ − = 1 + √ Case 2.
ALG matches r with s . The adversary gives the next request r at p ( s ) − y . We have two subcases. T. Itoh et al.
Fig. 1.
Requests and
ALG ’s matching for Case 1 of Theorem 3.
Case 2-1.
ALG matches r with s . See Fig. 2. The adversary gives a request r at p ( s ) and ALG matches it with s .The cost of ALG is 3+ x − y = 8 − √ OP T is 1 − x + y = 2 √ − − √ √ − = 1 + √ Fig. 2.
Requests and
ALG ’s matching for Case 2-1 of Theorem 3.
Case 2-2.
ALG matches r with s . See Fig. 3. The adversary gives a request r at p ( s ) and ALG matches it with s .The cost of ALG is 3+ x + y = 4 √ − OP T is 1+ x − y = 6 − √ √ − − √ = 1 + √ Fig. 3.
Requests and
ALG ’s matching for Case 2-2 of Theorem 3.
In any case, the ratio of
ALG ’s cost to
OP T ’s cost is 1 + √
6. This completesthe proof. ⊓⊔ Theorem 4.
The competitive ratio of any deterministic online algorithm forOFAL( ) is at least √ ( > . . ompetitive Analysis for Two Variants of Online Metric Matching Problem 9 Proof.
Let
ALG be any surrounding-oriented algorithm. In the same way as theproof of Theorem 3, the adversary first gives ℓ − p ( s i ) for i = 1 , , OP T and
ALG match each of these requeststo the server at the same position. Then, the adversary gives a request r at p ( s )+ p ( s )2 . Without loss of generality, assume that ALG matches it with s .Let x = −√ ( ≃ . y = √ − ( ≃ . r at p ( s ) + x . We consider two cases depending on the behaviorof ALG . Case 1.
ALG matches r with s . See Fig. 4. The adversary gives the next request r at p ( s ). ALG has to matchit with s . Finally, the adversary gives a request r at p ( s ) and ALG matches itwith s . The cost of ALG is + x = −√ and the cost of OP T is − x = √ − .The ratio is −√ √ − = √ . Fig. 4.
Requests and
ALG ’s matching for Case 1 of Theorem 4.
Case 2.
ALG matches r with s . The adversary gives the next request r at p ( s ) + y . We have two subcases. Case 2-1.
ALG matches r with s . See Fig. 5. The adversary gives a request r at p ( s ). ALG has to match itwith s . The cost of ALG is − x − y = − √ and the cost of OP T is + x + y = √ − . The ratio is − √ √ − = √ . Fig. 5.
Requests and
ALG ’s matching for Case 2-1 of Theorem 4.0 T. Itoh et al.
Case 2-2.
ALG matches r with s . See Fig. 6. The adversary gives a request r at p ( s ) and ALG has to matchit with s . The cost of ALG is − x + y = √ − and the cost of OP T is − x − y = − √ . The ratio is √ − − √ = √ . Fig. 6.
Requests and
ALG ’s matching for Case 2-2 of Theorem 4.
In any case, the ratio of
ALG ’s cost to
OP T ’s cost is √ . This completesthe proof. ⊓⊔ Theorem 5.
The competitive ratio of any deterministic online algorithms forOFAL( ) is at least ( > . .Proof. Let
ALG be any surrounding-oriented algorithm. In the same way asthe proof of Theorem 3, the adversary first gives ℓ − p ( s i ) for i = 1 , , ,
4, and 5, and we can assume that
OP T and
ALG match each of theserequests to the server at the same position.Then, the adversary gives a request r at p ( s ). If ALG matches this with s or s , the adversary gives the remaining requests at p ( s ), p ( s ), p ( s ) and p ( s ). OP T ’s cost is zero, while
ALG ’s cost is positive, so the ratio is again infinity.Therefore, assume that
ALG matches r with s . The adversary then gives arequest r at p ( s ). Without loss of generality, assume that ALG matches it with s . Next, the adversary gives a request r at p ( s ) + . We consider two casesdepending on the behavior of ALG . Case 1.
ALG matches r with s . See Fig. 7. The adversary gives the next request r at p ( s ). ALG has to matchit with s . Finally, the adversary gives a request r at p ( s ) and ALG matchesit with s . The cost of ALG is and the cost of OP T is . The ratio is . Case 2.
ALG matches r with s . The adversary gives the next request r at p ( s ). We have two subcases. Case 2-1.
ALG matches r with s . See Fig. 8. The adversary gives a request r at p ( s ) and ALG has to match itwith s . The cost of ALG is and the cost of OP T is . The ratio is > . ompetitive Analysis for Two Variants of Online Metric Matching Problem 11 Fig. 7.
Requests and
ALG ’s matching for Case 1 of Theorem 5.
Fig. 8.
Requests and
ALG ’s matching for Case 2-1 of Theorem 5.
Case 2-2.
ALG matches r with s . See Fig. 9. The adversary gives a request r at p ( s ) and ALG has to match itwith s . The cost of ALG is and the cost of OP T is . The ratio is . Fig. 9.
Requests and
ALG ’s matching for Case 2-2 of Theorem 5.
In any case, the ratio of
ALG ’s cost to
OP T ’s cost is at least , whichcompletes the proof. ⊓⊔ In this paper, we studied two variants of the online metric matching problem.The first is a restriction where all the servers are placed at one of two positions in the metric space. For this problem, we presented a greedy algorithm andshowed that it is 3-competitive. We also proved that any deterministic onlinealgorithm has competitive ratio at least 3, giving a matching lower bound. Thesecond variant is the Online Facility Assignment Problem on a line with a smallnumber of servers. We showed lower bounds on the competitive ratio 1 + √ √ , and when the numbers of servers are 3, 4, and 5, respectively.One of the future work is to analyze the online metric matching problemwith three or more server positions. Another interesting direction is to consideran optimal online algorithm for the Online Facility Assignment Problem on aline when the numbers of servers are 3, 4, and 5. References
1. Ahmed, A., Rahman, M., Kobourov, S.: Online facility assignment. TheoreticalComputer Science , 455–467 (2020)2. Antoniadis, A., Barcelo, M., Nugent, M., Pruhs, N., Scquizzato, M.: A o ( n )-competitive deterministic algorithm for online matching on a line. WAOA 2012pp. 11–22 (2014)3. Antoniadis, A., Fischer, C., T¨onnis, A.: A collection of lower bounds for onlinematching on the line. LATIN 2018 pp. 52–65 (2018)4. Bansal, N., Buchbinder, N., Gupta, A., Naor, J.: An o (log k )-competitive algo-rithm for metric bipartite matching. ESA 2007 pp. 522–533 (2007)5. Fuchs, B., Hochst¨attler, W., Kern, W.: Online matching on a line. TheoreticalComputer Science , 251–264 (2005)6. Gupta, A., Lewi, K.: The online metric matching problem for doubling metrics.ICALP 2012 pp. 424–435 (2012)7. Kalyanasundaram, B., Pruhs, K.: Online weighted matching. Journal of Algorithms (3), 478–488 (1993)8. Kalyanasundaram, B., Pruhs, K.: Online network optimization problems. OnlineAlgorithms. Lecture Notes in Computer Science , 268–280 (1998)9. Karp, R., Vazirani, U., Vazirani, V.: An optimal algorithm for on-line bipartitematching. STOC 1990 pp. 352–358 (1990)10. Khuller, S., Mitchell, S., Vazirani, V.: On-line algorithms for weighted bipartitematching and stable marriages. Theoretical Computer Science (2), 255–267(1994)11. Koutsoupias, E., Nanavati, A.: The online matching problem on a line. WAOA 2003pp. 179–191 (2004)12. Mehta, A.: Online matching and ad allocation. Theoretical Computer Science (4),265–368 (2012)13. Meyerson, A., Nanavati, A., Poplawski, L.: Randomized online algorithms for min-imum metric bipartite matching. SODA 2006 pp. 954–959 (2006)14. Nayyar, K., Raghvendra, S.: An input sensitive online algorithm for the metricbipartite matching problem. FOCS 2017 pp. 505–515 (2017)15. Raghvendra, S.: A robust and optimal online algorithm for minimum metric bi-partite matching. APPROX/RANDOM 201660