Changing Bases: Multistage Optimization for Matroids and Matchings

Changing Bases: Multistage Optimization for Matroids and Matchings

Anupam Gupta Computer Science Dept., Carnegie Mellon University. Research performed while the author was at Microsoft Reserach Silicon Valley. Research was partly supported by NSF awards CCF-0964474 and CCF-1016799, and by a grant from the CMU-Microsoft Center for Computational Thinking.    Kunal Talwar Microsoft Research SVC, Mountain View, CA 94043.    Udi Wieder Microsoft Research SVC, Mountain View, CA

This paper is motivated by the fact that many systems need to be maintained continually while the underlying costs change over time. The challenge then is to continually maintain near-optimal solutions to the underlying optimization problems, without creating too much churn in the solution itself. We model this as a multistage combinatorial optimization problem where the input is a sequence of cost functions (one for each time step); while we can change the solution from step to step, we incur an additional cost for every such change.

We first study the multistage matroid maintenance problem, where we need to maintain a base of a matroid in each time step under the changing cost functions and acquisition costs for adding new elements. The online version of this problem generalizes onine paging, and is a well-structured case of the metrical task systems. E.g., given a graph, we need to maintain a spanning tree at each step: we pay for the cost of the tree at time , and also for the number of edges changed at this step. Our main result is a polynomial time -approximation to the online multistage matroid maintenance problem, where is the number of elements/edges and is the rank of the matroid. This improves on results of Buchbinder et al. [7] who addressed the fractional version of this problem under uniform acquisition costs, and Buchbinder, Chen and Naor [8] who studied the fractional version of a more general problem. We also give an approximation for the offline version of the problem. These bounds hold when the acquisition costs are non-uniform, in which case both these results are the best possible unless P=NP.

We also study the perfect matching version of the problem, where we must maintain a perfect matching at each step under changing cost functions and costs for adding new elements. Surprisingly, the hardness drastically increases: for any constant , there is no -approximation to the multistage matching maintenance problem, even in the offline case.

-1mm -1mm

1 Introduction

In a typical instance of a combinatorial optimization problem the underlying constraints model a static application frozen in one time step. In many applications however, one needs to solve instances of the combinatorial optimization problem that changes over time. While this is naturally handled by re-solving the optimization problem in each time step separately, changing the solution one holds from one time step to the next often incurs a transition cost. Consider, for example, the problem faced by a vendor who needs to get supply of an item from different producers to meet her demand. On any given day, she could get prices from each of the producers and pick the cheapest ones to buy from. As prices change, this set of the cheapest producers may change. However, there is a fixed cost to starting and/or ending a relationship with any new producer. The goal of the vendor is to minimize the sum total of these two costs: an ”acquisition cost” to be incurred each time she starts a new business relationship with a producer, and a per period cost of buying in period from the each of the producers that she picks in this period, summed over time periods. In this work we consider a generalization of this problem, where the constraint “pick producers” may be replaced by a more general combinatorial constraint. It is natural to ask whether simple combinatorial problems for which the one-shot problem is easy to solve, as the example above is, also admit good algorithms for the multistage version.

The first problem we study is the Multistage Matroid Maintenance problem (MMM), where the underlying combinatorial constraint is that of maintaining a base of a given matroid in each period. In the example above, the requirement the vendor buys from different producers could be expressed as optimizing over the uniform matroid. In a more interesting case one may want to maintain a spanning tree of a given graph at each step, where the edge costs change over time, and an acquisition cost of has to paid every time a new edge enters the spanning tree. (A formal definition of the MMM problem appears in Section 2.) While our emphasis is on the online problem, we will mention results for the offline version as well, where the whole input is given in advance.

A first observation we make is that if the matroid in question is allowed to be different in each time period, then the problem is hard to approximate to any non-trivial factor (see Section A.1) even in the offline case. We therefore focus on the case where the same matroid is given at each time period. Thus we restrict ourselves to the case when the matroid is the same for all time steps.

To set the baseline, we first study the offline version of the problem (in Section 3), where all the input parameters are known in advance. We show an LP-rounding algorithm which approximates the total cost up to a logarithmic factor. This approximation factor is no better than that using a simple greedy algorithm, but it will be useful to see the rounding algorithm, since we will use its extension in the online setting. We also show a matching hardness reduction, proving that the problem is hard to approximate to better than a logarithmic factor; this hardness holds even for the special case of spanning trees in graphs.

We then turn to the online version of the problem, where in each time period, we learn the costs of each element that is available at time , and we need to pick a base of the matroid for this period. We analyze the performance of our online algorithm in the competitive analysis framework: i.e., we compare the cost of the online algorithm to that of the optimum solution to the offline instance thus generated. In Section 4, we give an efficient randomized -competitive algorithm for this problem against any oblivious adversary (here is the universe for the matroid and is the rank of the matroid), and show that no polynomial-time online algorithm can do better. We also show that the requirement that the algorithm be randomized is necessary: any deterministic algorithm must incur an overhead of , even for the simplest of matroids.

Our results above crucially relied on the properties of matriods, and it is natural to ask if we can handle more general set systems, e.g., -systems. In Section 5, we consider the case where the combinatorial object we need to find each time step is a perfect matching in a graph. Somewhat surprisingly, the problem here is significantly harder than the matroid case, even in the offline case. In particular, we show that even when the number of periods is a constant, no polynomial time algorithm can achieve an approximation ratio better than for any constant .

1.1 Techniques

We first show that the MMM problem, which is a packing-covering problem, can be reduced to the analogous problem of maintaining a spanning set of a matroid. We call the latter the Multistage Spanning set Maintenance (MSM) problem. While the reduction itself is fairly clean, it is surprisingly powerful and is what enables us to improve on previous works. The MSM problem is a covering problem, so it admits better approximation ratios and allows for a much larger toolbox of techniques at our disposal. We note that this is the only place where we need the matroid to not change over time: our algorithms for MSM work when the matroids change over time, and even when considering matroid intersections. The MSM problem is then further reduced to the case where the holding cost of an element is in , this reduction simplifies the analysis.

In the offline case, we present two algorithms. We first observe that a greedy algorithm easily gives an -approximation. We then present a simple randomized rounding algorithm for the linear program. This is analyzed using recent results on contention resolution schemes [13], and gives an approximation of , which can be improved to when the acquisition costs are uniform. This LP-rounding algorithm will be an important constituent of our algorithm for the online case.

For the online case we again use that the problem can be written as a covering problem, even though the natural LP formulation has both covering and packing constraints. Phrasing it as a covering problem (with box constraints) enables us to use, as a black-box, results on online algorithms for the fractional problem [9]. This formulation however has exponentially many constraints. We handle that by showing a method of adaptively picking violated constraints such that only a small number of constraints are ever picked. The crucial insight here is that if is such that is not feasible, then is at least away in distance from any feasible solution; in fact there is a single constraint that is violated to an extent half. This insight allows us to make non-trivial progress (using a natural potential function) every time we bring in a constraint, and lets us bound the number of constraints we need to add until constraints are satisfied by .

1.2 Related Work

Our work is related to several lines of research, and extends some of them. The paging problem is a special case of MMM where the underlying matroid is a uniform one. Our online algorithm generalizes the -competitive algorithm for weighted caching [5], using existing online LP solvers in a black-box fashion. Going from uniform to general matroids loses a logarithmic factor (after rounding), we show such a loss is unavoidable unless we use exponential time.

The MMM problem is also a special case of classical Metrical Task Systems [6]; see [1, 4] for more recent work. The best approximations for metrical task systems are poly-logarithmic in the size of the metric space. In our case the metric space is specified by the total number of bases of the matroid which is often exponential, so these algorithms only give a trivial approximation.

In trying to unify online learning and competitive analysis, Buchbinder et al. [7] consider a problem on matroids very similar to ours. The salient differences are: (a) in their model all acquisition costs are the same, and (b) they work with fractional bases instead of integral ones. They give an -competitive algorithm to solve the fractional online LP with uniform acquisition costs (among other unrelated results). Our online LP solving generalizes their result to arbitrary acquisition costs. They leave open the question of getting integer solutions online (Seffi Naor, private communication), which we present in this work. In a more recent work, Buchbinder, Chen and Naor [8] use a regularization approach to solving a broader set of fractional problems, but once again can do not get integer solutions in a setting such as ours.

Shachnai et al. [28] consider “reoptimization” problems: given a starting solution and a new instance, they want to balance the transition cost and the cost on the new instance. This is a two-timestep version of our problem, and the short time horizon raises a very different set of issues (since the output solution does not need to itself hedge against possible subsequent futures). They consider a number of optimization/scheduling problems in their framework.

Cohen et al. [15] consider several problems in the framework of the stability-versus-fit tradeoff; e.g., that of finding “stable” solutions which given the previous solution, like in reoptimization, is the current solution that maximizes the quality minus the transition costs. They show maintaining stable solutions for matroids becomes a repeated two-stage reoptimization problem; their problem is poly-time solvable, whereas matroid problems in our model become NP-hard. The reason is that the solution for two time steps does not necessarily lead to a base from which it is easy to move in subsequent time steps, as our hardness reduction shows. They consider a multistage offline version of their problem (again maximizing fit minus stability) which is very similar in spirit and form to our (minimization) problem, though the minus sign in the objective function makes it difficult to approximate in cases which are not in poly-time.

In dynamic Steiner tree maintenance [21, 24, 18] where the goal is to maintain an approximately optimal Steiner tree for a varying instance (where terminals are added) while changing few edges at each time step. In dynamic load balancing [2, 16] one has to maintain a good scheduling solution while moving a small number of jobs around. The work on lazy experts in the online prediction community [11] also deals with similar concerns.

There is also work on “leasing” problems [25, 3, 26]: these are optimization problems where elements can be obtained for an interval of any length, where the cost is concave in the lengths; the instance changes at each timestep. The main differences are that the solution only needs to be feasible at each timestep (i.e., the holding costs are ), and that any element can be leased for any length of time starting at any timestep for a cost that depends only on , which gives these problems a lot of uniformity. In turn, these leasing problems are related to “buy-at-bulk” problems.

2 Maintaining Bases to Maintaining Spanning Sets

Given reals for elements , we will use for to denote . We denote by .

We assume basic familiarity with matroids: see, e.g., [27] for a detailed treatment. Given a matroid , a base is a maximum cardinality independent set, and a spanning set is a set such that ; equivalently, this set contains a base within it. The span of a set is . The matroid polytope is defined as . The base polytope . We will sometimes use to denote and to denote the rank of the matroid.

Formal Definition of Problems

An instance of the Multistage Matroid Maintenance (MMM) problem consists of a matroid , an acquisition cost for each , and for every timestep and element , a holding cost cost . The goal is to find bases to minimize


where we define . A related problem is the Multistage Spanning set Maintenance(MSM) problem, where we want to maintain a spanning set at each time, and cost of the solution (once again with ) is


Maintaining Bases versus Maintaining Spanning Sets

The following lemma shows the equivalence of maintaining bases and spanning sets. This enables us to significantly simplify the problem and avoid the difficulties faced by previous works on this problem.

Lemma 2.1

For matroids, the optimal solutions to MMM and MSM have the same costs.


Clearly, any solution to MMM is also a solution to MSM, since a base is also a spanning set. Conversely, consider a solution to MSM. Set to any base in . Given , start with , and extend it to any base of . This is the only step where we use the matroid properties—indeed, since the matroid is the same at each time, the set remains independent at time , and by the matroid property this independent set can be extended to a base. Observe that this process just requires us to know the base and the set , and hence can be performed in an online fashion.

We claim that the cost of is no more than that of . Indeed, , because . Moreover, let , we pay for these elements we just added. To charge this, consider any such element , let be the time it was most recently added to the cover—i.e., for all , but . The MSM solution paid for including at time , and we charge our acquisition of into to this pair . It suffices to now observe that we will not charge to this pair again, since the procedure to create ensures we do not drop from the base until it is dropped from itself—the next time we pay an addition cost for element , it would have been dropped and added in as well. ∎

Hence it suffices to give a good solution to the MSM problem. We observe that the proof above uses the matroid property crucially and would not hold, e.g., for matchings. It also requires that the same matroid be given at all time steps. Also, as noted above, the reduction is online: the instance is the same, and given an MSM solution it can be transformed online to a solution to MMM.

Elements and Intervals

We will find it convenient to think of an instance of MSM as being a matroid , where each element only has an acquisition cost , and it has a lifetime . There are no holding costs, but the element can be used in spanning sets only for timesteps . Or one can equivalently think of holding costs being zero for and otherwise.

An Offline Exact Reduction. The translation is the natural one: given instance of MSM, create elements for each and , with acquisition cost , and interval . (The matroid is extended in the natural way, where all the elements associated with are parallel to each other.) The equivalence of the original definition of MSM and this interval view is easy to verify.

An Online Approximate Reduction. Observe that the above reduction created at most copies of each element, and required knowledge of all the costs. If we are willing to lose a constant factor in the approximation, we can perform a reduction to the interval model in an online fashion as follows. For element , define , and create many parallel copies of this element (modifying the matroid appropriately). Now the interval for is , where is set to in case , else it is set to the largest time such that the total holding costs for this interval is at most . This interval is associated with element , which is only available for this interval, at cost .

A few salient points about this reduction: the intervals for an original element now partition the entire time horizon . The number of elements in the modified matroid whose intervals contain any time is now only , the same as the original matroid; each element of the modified matroid is only available for a single interval. Moreover, the reduction can be done online: given the past history and the holding cost for the current time step , we can ascertain whether is the beginning of a new interval (in which case the previous interval ended at ) and if so, we know the cost of acquiring a copy of for the new interval is . It is easy to check that the optimal cost in this interval model is within a constant factor of the optimal cost in the original acquisition/holding costs model.

3 Offline Algorithms

Given the reductions of the previous section, we can focus on the MSM problem. Being a covering problem, MSM is conceptually easier to solve: e.g., we could use algorithms for submodular set cover [29] with the submodular function being the sum of ranks at each of the timesteps, to get an approximation.

In Section B, we give a dual-fitting proof of the performance of the greedy algorithm. Here we give an LP-rounding algorithm which gives an approximation; this can be improved to in the common case where all acquisition costs are unit. (While the approximation guarantee is no better than that from submodular set cover, this LP-rounding algorithm will prove useful in the online case in Section 4). Finally, the hardness results of Section 3.2 show that we cannot hope to do much better than these logarithmic approximations.

3.1 The LP Rounding Algorithm

We now consider an LP-rounding algorithm for the MMM problem; this will generalize to the online setting, whereas it is unclear how to extend the greedy algorithm to that case. For the LP rounding, we use the standard definition of the MMM problem to write the following LP relaxation.


It remains to round the solution to get a feasible solution to MSM (i.e., a spanning set for each time) with expected cost at most times the LP value, since we can use Lemma 2.1 to convert this to a solution for MMM at no extra cost. The following lemma is well-known (see, e.g. [10]). We give a proof for completeness.

Lemma 3.1

For a fractional base , let be the set obtained by picking each element independently with probability . Then .


We use the results of Chekuri et al. [13] (extending those of Chawla et al. [12]) on so-called contention resolution schemes. Formally, for a matroid , they give a randomized procedure that takes the random set and outputs an independent set in , such that , and for each element in the support of , . (They call this a -balanced CR scheme.) Now, we get

The first inequality used the fact that is a subset of , the following equality used that is independent with probability 1, the second inequality used the property of the CR scheme, and the final equality used the fact that was a fractional base. ∎

Theorem 3.2

Any fractional solution can be randomly rounded to get solution to MSM with cost times the fractional value, where is the rank of the matroid and the number of timesteps.


Set . For each element , choose a random threshold independently and uniformly from the interval . For each , define the set ; if does not have full rank, augment its rank using the cheapest elements according to to obtain a full rank set . Since , the cost . Moreover, exactly when satisfies , which happens with probability at most

Hence the expected acquisition cost for the elements newly added to is at most . Finally, we have to account for any elements added to extend to a full-rank set .

Lemma 3.3

For any fixed , the set contains a basis of with probability at least .


The set is obtained by threshold rounding of the fractional base as above. Instead, consider taking different samples , where each sample is obtained by including each element independently with probability ; let . It is easy to check that , so it suffices to give a lower bound on the former expression. For this, we use Lemma 3.1: the sample has expected rank , and using reverse Markov, it has rank at least with probability at least . Now focusing on the matroid obtained by contracting elements in (which, say, has rank ), the same argument says the set has rank with probability at least , etc. Proceeding in this way, the probability that the rank of is less than is at most the probability that we see fewer than heads in flips of a coin of bias . By a Chernoff bound, this is at most . ∎

Now if the set does not have full rank, the elements we add have cost at most that of the min-cost base under the cost function , which is at most the optimum value for (LP2). (We use the fact that the LP is exact for a single matroid, and the global LP has cost at least the single timestep cost.) This happens with probability at most , and hence the total expected cost of augmenting over all timesteps is at most times the LP value. This proves the main theorem. ∎

Again, this algorithm for MSM works with different matroids at each timestep, and also for intersections of matroids. To see this observe that the only requirements from the algorithm are that there is a separation oracle for the polytope and that the contention resolution scheme works. In the case of matroid intersection, if we pay an extra penalty in the approximation ratio we have that the probability a rounded solution does not contain a base is so we can take a union bound over the multiple matroids.

An Improvement: Avoiding the Dependence on .

When the ratio of the maximum to the minimum acquisition cost is small, we can improve the approximation factor above. More specifically, we show that essentially the same randomized rounding algorithm (with a different choice of ) gives an approximation ratio of . We defer the argument to Section 4.2, as it needs some additional definitions and results that we present in the online section.

3.2 Hardness for Offline Msm

Theorem 3.4

The MSM and MMM problems are NP-hard to approximate better than even for graphical matroids.


We give a reduction from Set Cover to the MSM problem for graphical matroids. Given an instance of set cover, with sets and elements, we construct a graph as follows. There is a special vertex , and set vertices (with vertices for each set ). There are edges which all have inclusion weight and per-time cost for all . All other edges will be zero cost short-term edges as given below. In particular, there are timesteps. In timestep , define subset to be vertices corresponding to sets containing element . We have a set of edges for all , and all edges for . All these edges have zero inclusion weight , and are only alive at time . (Note this creates a graph with parallel edges, but this can be easily fixed by subdividing edges.)

In any solution to this problem, to connect the vertices in to , we must buy some edge for some . This is true for all , hence the root-set edges we buy correspond to a set cover. Moreover, one can easily check that if we acquire edges such that the sets form a set cover, then we can always augment using zero cost edges to get a spanning tree. Since the only edges we pay for are the edges, we should buy edges corresponding to a min-cardinality set cover, which is hard to approximate better than . Finally, that the number of time periods is , and the rank of the matroid is for these hard instances. This gives us the claimed hardness. ∎

4 Online Msm

We now turn to solving MMM in the online setting. In this setting, the acquisition costs are known up-front, but the holding costs for day are not known before day . Since the equivalence given in Lemma 2.1 between MMM and MSM holds even in the online setting, we can just work on the MSM problem. We show that the online MSM problem admits an -competitive (oblivious) randomized algorithm. To do this, we show that one can find an -competitive fractional solution to the linear programming relaxation in Section 3, and then we round this LP relaxation online, losing another logarithmic factor.

4.1 Solving the LP Relaxations Online

Again, we work in the interval model outlined in Section 2. Recall that in this model, for each element there is a unique interval during which it is alive. The element has an acquisition cost , no holding costs. Once an element has been acquired (which can be done at any time during its interval), it can be used at all times in that interval, but not after that. In the online setting, at each time step we are told which intervals have ended (and which have not); also, which new elements are available starting at time , along with their acquisition costs . Of course, we do not know when its interval will end; this information is known only once the interval ends.

We will work with the same LP as in Section 3.1, albeit now we have to solve it online. The variable is the indicator for whether we acquire element .


Note that this is not a packing or covering LP, which makes it more annoying to solve online. Hence we consider a slight reformulation. Let denote the spanning set polytope defined as the convex hull of the full-rank (a.k.a. spanning) sets . Since each spanning set contains a base, we can write the constraints of (LP3) as:


Here we define to be the vector derived from by zeroing out the values for . It is known that the polytope can be written as a (rather large) set of covering constraints. Indeed, , where is the dual matroid for . Since the rank function of is given by , it follows that (4.3) can be written as


Thus we get a covering LP with “box” constraints over . The constraints can be presented one at a time: in timestep , we present all the covering constraints corresponding to . We remark that the newer machinery of [8] may be applicable to LP4. We next show that a simpler approach suffices111Additionally, Lemma 4.1 will be useful in improving the rounding algorithm.. The general results of Buchbinder and Naor [9] (and its extension to row-sparse covering problems by [19]) imply a deterministic algorithm for fractionally solving this linear program online, with a competitive ratio of . However, this is not yet a polynomial-time algorithm, the number of constraints for each timestep being exponential. We next give an adaptive algorithm to generate a small yet sufficient set of constraints.

Solving the LP Online in Polynomial Time.

Given a vector , define as follows:


Clearly, and . We next describe the algorithm for generating covering constraints in timestep . Recall that [9] give us an online algorithm for solving a fractional covering LP with box constraints; we use this as a black-box. (This LP solver only raises variables, a fact we will use.) In timestep , we adaptively select a small subset of the covering constraints from (LP4), and present it to . Moreover, given a fractional solution returned by , we will need to massage it at the end of timestep to get a solution satisfying all the constraints from (LP4) corresponding to .

Let be the fractional solution to (LP4) at the end of timestep . Now given information about timestep , in particular the elements in and their acquisition costs, we do the following. Given , we construct and check if , as one can separate for . If , then is feasible and we do not need to present any new constraints to , and we return . If not, our separation oracle presents an such that the constraint is violated. We present the constraint corresponding to to to get an updated , and repeat until is feasible for time . (Since only raises variables and we have a covering LP, the solution remains feasible for past timesteps.) We next argue that we do not need to repeat this loop more than times.

Lemma 4.1

If for some and the corresponding , the constraint is violated. Then


Let and let . Let denote . Thus

Since both and are integers, it follows that . On the other hand, for every , and thus . Consequently

Finally, for any , , so the claim follows. ∎

The algorithm updates to satisfy the constraint given to it, and Lemma 4.1 implies that each constraint we give to it must increase by at least . The translation to the interval model ensures that the number of elements whose intervals contain is at most , and hence the total number of constraints presented at any time is at most . We summarize the discussion of this section in the following theorem.

Theorem 4.2

There is a polynomial-time online algorithm to compute an -approximate solution to (LP3).

We observe that the solution to this linear program can be trivially transformed to one for the LP in Section 3.1. Finally, the randomized rounding algorithm of Section 3.1 can be implemented online by selecting a threshold the beginning of the algorithm, where and selecting element whenever exceeds : here we use the fact that the online algorithm only ever raises values, and this rounding algorithm is monotone. Rerandomizing in case of failure gives us an expected cost of times the LP solution, and hence we get an -competitive algorithm.

4.2 An -Approximate Rounding

The dependence on the time horizon is unsatisfactory in some settings, but we can do better using Lemma 4.1. Recall that the -factor loss in the rounding follows from the naive union bound over the time steps. We now argue that when is small, we can afford for the rounding to fail occasionally, and charge it to the acquisition cost incurred by the linear program.

Let us divide the period into disjoint “epochs”, where an epoch (except for the last) is an interval for such that the total fractional acquisition cost . Thus an epoch is a minimal interval where the linear program spends acquisition cost , so that we can afford to build a brand new tree once in each epoch and can charge it to the LP’s fractional acquisition cost in the epoch. Naively applying Theorem 3.2 to each epoch independently gives us a guarantee of , where is the maximum length of an epoch.

However, an epoch can be fairly long if the LP solution changes very slowly. We break up each epoch into phases, where each phase is a maximal subsequence such that the LP incurs acquisition cost at most ; clearly the epoch can be divided into at most disjoint phases. For a phase , let denote the solution defined as . The definition of the phase implies that for any , the difference . Now Lemma 4.1 implies that is in , where is defined as in (4.4).

Suppose that in the randomized rounding algorithm, we pick the threshold for . Let be the event that the rounding algorithm applied to gives a spanning set. Since is in for a phase , Lemma 3.3 implies that the event occurs with probability . Moreover, if occurs, it is easy to see that the randomized rounding solution is feasible for all . Since there are phases within an epoch, the expected number of times that the randomized rounding fails any time during an epoch is .

Suppose that we rerandomize all thresholds whenever the randomized rounding fails. Each rerandomization will cost us at most in expected acquisition cost. Since the expected number of times we do this is less than once per epoch, we can charge this additional cost to the acquisition cost incurred by the LP during the epoch. Thus we get an -approximation. This argument also works for the online case; hence for the common case where all the acquisition costs are the same, the loss due to randomized rounding is .

4.3 Hardness of the online Mmm and online Msm

In the online set cover problem, one is given an instance of set cover, and in time step , the algorithm is presented an element , and is required to pick a set covering it. The competitive ratio of an algorithm on a sequence is the ratio of the number of sets picked by the algorithm to the optimum set-cover of the instance . Korman [23, Theorem 2.3.4] shows the following hardness for online set cover:

Theorem 4.3 ([23])

There exists a constant such that if there is a (possibly randomized) polynomial time algorithm for online set cover with competitive ratio , then .

Recall that in the reduction in the proof of Theorem 3.4, the set of long term edges depends only on . The short term edges alone depend on the elements to be covered. It can then we verified that the same approach gives a reduction from online set cover to online MSM. It follows that the online MSM problem does not admit an algorithm with competitive ratio better than unless . In fact this hardness holds even when the end time of each edge is known as soon as it appears, and the only non-zero costs are .

5 Perfect Matching Maintenance

We next consider the Perfect Matching Maintenance (PMM) problem where is the set of edges of a graph , and the at each step, we need to maintain a perfect matchings in .

The natural LP relaxation is:

The polytope is now the perfect matching polytope for .

Figure 5.1: Integrality gap example
Lemma 5.1

There is an integrality gap for the PMM problem.


Consider the instance in the figure, and the following LP solution for 4 time steps. In , the edges of each of the two cycles has , and the cross-cycle edges have . In , we have and , and otherwise it is the same as . and are the same as . In , we have and , and otherwise it is the same as . For each time , the edges in the support of the solution have zero cost, and other edges have infinite cost. The only cost incurred by the LP is the movement cost, which is .

Consider the perfect matching found at time , which must consist of matchings on both the cycles. (Moreover, the matching in time 3 must be the same, else we would change edges.) Suppose this matching uses exactly one edge from and . Then when we drop the edges and add in , we get a cycle on vertices, but to get a perfect matching on this in time we need to change edges. Else the matching uses exactly one edge from and , in which case going from time to time requires changes. ∎

5.1 Hardness of PM-Maintenance

In this section we prove the following hardness result:

Theorem 5.2

For any it is NP-hard to distinguish PMM instances with cost from those with cost , where is the number of vertices in the graph. This holds even when the holding costs are in , acquisition costs are for all edges, and the number of time steps is a constant.


The proof is via reduction from -coloring. We assume we are given an instance of -coloring where the maximum degree of is constant. It is known that the -coloring problem is still hard for graphs with bounded degree [20, Theorem 2].

Figure 5.2: Per-vertex gadget

We construct the following gadget for each vertex . (A figure is given in Figure 5.2.)

  • There are two cycles of length , where is odd. The first cycle (say ) has three distinguished vertices at distance from each other. The second (called ) has similar distinguished vertices at distance from each other.

  • There are three more “interface” vertices . Vertex is connected to and , similarly for and .

  • There is a special “switch” vertex , which is connected to all three of . Call these edges the switch edges.

Due to the two odd cycles, every perfect matching in has the structure that one of the interface vertices is matched to some vertex in , another to a vertex in and the third to the switch . We think of the subscript of the vertex matched to as the color assigned to the vertex .

At every odd time step , the only allowed edges are those within the gadgets : i.e., all the holding costs for edges within the gadgets is zero, and all edges between gadgets have holding costs . This is called the “steady state”.

At every even time step , for some matching of the graph, we move into a “test state”, which intuitively tests whether the edges of a matching have been properly colored. We do this as follows. For every edge , the switch edges in become unavailable (have infinite holding costs). Moreover, now we allow some edges that go between and , namely the edge , and the edges for and . Note that any perfect matching on the vertices of which only uses the available edges would have to match , and one interface vertex of must be matched to one interface vertex of . Moreover, by the structure of the allowed edges, the colors of these vertices must differ. (The other two interface vertices in each gadget must still be matched to their odd cycles to get a perfect matching.) Since the graph has bounded degree, we can partition the edges of into a constant number of matchings for some (using Vizing’s theorem). Hence, at time step , we test the edges of the matching . The number of timesteps is , which is a constant.

Figure 5.3: On the left, the steady-state edges incident to the interface and switch vertices of edge . The test-state edges are on the right.

Suppose the graph was indeed -colorable, say is the proper coloring. In the steady states, we choose a perfect matching within each gadget so that is matched. In the test state , if some edge is in the matching , we match and . Since the coloring was a proper coloring, these edges are present and this is a valid perfect matching using only the edges allowed in this test state. Note that the only changes are that for every test edge , the matching edges and are replaced by and . Hence the total acquisition cost incurred at time is , and the same acquisition cost is incurred at time to revert to the steady state. Hence the total acquisition cost, summed over all the timesteps, is .

Suppose is not -colorable. We claim that there exists vertex such that the interface vertex not matched to the odd cycles is different in two different timesteps—i.e., there are times such that and (for ) are the states. Then the length of the augmenting path to get from the perfect matching at time to the perfect matching at is at least . Now if we set , then we get a total acquisition cost of at least in this case.

The size of the graph is , so the gap is between and . This proves the claim. ∎

6 Conclusions

In this paper we studied multistage optimization problems: an optimization problem (think about finding a minimum-cost spanning tree in a graph) needs to be solved repeatedly, each day a different set of element costs are presented, and there is a penalty for changing the elements picked as part of the solution. Hence one has to hedge between sticking to a suboptimal solution and changing solutions too rapidly. We present online and offline algorithms when the optimization problem is maintaining a base in a matroid. We show that our results are optimal under standard complexity-theoretic assumptions. We also show that the problem of maintaining a perfect matching becomes impossibly hard.

Our work suggests several directions for future research. It is natural to study other combinatorial optimization problems, both polynomial time solvable ones such shortest path and min-cut, as well NP-hard ones such as min-max load balancing and bin-packing in this multistage framework with acquisition costs. Moreover, the approximability of the bipartite matching maintenance, as well as matroid intersection maintenance remains open. Our hardness results for the matroid problem hold when edges have acquisition costs. The unweighted version where all acquisition costs are equal may be easier; we currently know no hardness results, or sub-logarithmic approximations for this useful special case.


  • [1] J. Abernethy, P. L. Bartlett, N. Buchbinder, and I. Stanton. A regularization approach to metrical task systems. In ALT, pages 270–284, 2010.
  • [2] M. Andrews, M. X. Goemans, and L. Zhang. Improved bounds for on-line load balancing. Algorithmica, 23(4):278–301, 1999.
  • [3] B. M. Anthony and A. Gupta. Infrastructure leasing problems. In IPCO, pages 424–438, 2007.
  • [4] N. Bansal, N. Buchbinder, and J. Naor. Metrical task systems and the k-server problem on hsts. In ICALP (1), pages 287–298, 2010.
  • [5] N. Bansal, N. Buchbinder, and J. S. Naor. Randomized competitive algorithms for generalized caching. In STOC’08, pages 235–244. 2008.
  • [6] A. Borodin, N. Linial, and M. E. Saks. An optimal on-line algorithm for metrical task system. J. ACM, 39(4):745–763, Oct. 1992.
  • [7] N. Buchbinder, S. Chen, J. Naor, and O. Shamir. Unified algorithms for online learning and competitive analysis. JMLR, 23:5.1–5.18, 2012.
  • [8] N. Buchbinder, S. Chen, and J. S. Naor. Competitive analysis via regularization. In ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 436–444, 2014.
  • [9] N. Buchbinder and J. S. Naor. Online primal-dual algorithms for covering and packing. Math. Oper. Res., 34(2):270–286, 2009.
  • [10] G. Calinescu, C. Chekuri, M. Pál, and J. Vondrák. Maximizing a submodular set function subject to a matroid constraint (extended abstract). pages 182–196, 2007.
  • [11] N. Cesa-Bianchi and G. Lugosi. Prediction, learning, and games. Cambridge University Press, 2006.
  • [12] S. Chawla, J. D. Hartline, D. L. Malec, and B. Sivan. Multi-parameter mechanism design and sequential posted pricing. In STOC, pages 311–320, 2010.
  • [13] C. Chekuri, J. Vondrák, and R. Zenklusen. Submodular function maximization via the multilinear relaxation and contention resolution schemes. In STOC, pages 783–792, 2011.
  • [14] V. Chvátal. A greedy heuristic for the set-covering problem. Math. Oper. Res., 4(3):233–235, 1979.
  • [15] E. Cohen, G. Cormode, N. G. Duffield, and C. Lund. On the tradeoff between stability and fit. CoRR, abs/1302.2137, 2013.
  • [16] L. Epstein and A. Levin. Robust algorithms for preemptive scheduling. In ESA, volume 6942 of Lecture Notes in Comput. Sci., pages 567–578. Springer, Heidelberg, 2011.
  • [17] M. L. Fisher, G. L. Nemhauser, and L. A. Wolsey. An analysis of approximations for maximizing submodular set functions. II. Math. Prog. Stud., (8):73–87, 1978.
  • [18] A. Gu, A. Gupta, and A. Kumar. The power of deferral: maintaining a constant-competitive steiner tree online. In STOC, pages 525–534, 2013.
  • [19] A. Gupta and V. Nagarajan. Approximating sparse covering integer programs online. In ICALP (1), Jul 2012.
  • [20] V. Guruswami and S. Khanna. On the hardness of 4-coloring a 3-colorable graph. SIAM J. Discrete Math., 18(1):30–40 (electronic), 2004.
  • [21] M. Imase and B. M. Waxman. Dynamic Steiner tree problem. SIAM J. Discrete Math., 4(3):369–384, 1991.
  • [22] V. Kann. Maximum bounded 3-dimensional matching is max snp-complete. Inf. Process. Lett., 37(1):27–35, Jan. 1991.
  • [23] S. Korman. On the use of randomness in the online set cover problem. M.Sc. thesis, Weizmann Institute of Science, 2005.
  • [24] N. Megow, M. Skutella, J. Verschae, and A. Wiese. The power of recourse for online MST and TSP. In ICALP (1), pages 689–700, 2012.
  • [25] A. Meyerson. The parking permit problem. In FOCS, pages 274–284, 2005.
  • [26] C. Nagarajan and D. P. Williamson. Offline and online facility leasing. In IPCO, pages 303–315, 2008.
  • [27] A. Schrijver. Combinatorial Optimization. Springer, 2003.
  • [28] H. Shachnai, G. Tamir, and T. Tamir. A theory and algorithms for combinatorial reoptimization. In LATIN, pages 618–630, 2012.
  • [29] L. A. Wolsey. An analysis of the greedy algorithm for the submodular set covering problem. Combinatorica, 2(4):385–393, 1982.

Appendix A Lower Bounds: Hardness and Gap Results

a.1 Hardness for Time-Varying Matroids

An extension of MMM/MSM problems is to the case when the set of elements remain the same, but the matroids change over time. Again the goal in MMM is to maintain a matroid base at each time.

Theorem A.1

The MMM problem with different matroids is NP-hard to approximate better than a factor of , even for partition matroids, as long as .


The reduction is from 3D-Matching (3DM). An instance of 3DM has three sets of equal size , and a set of hyperedges . The goal is to choose a set of disjoint edges such that .

First, consider the instance of MMM with three timesteps . The universe elements correspond to the edges. For , create a partition with parts, with edges sharing a vertex in falling in the same part. The matroid is now to choose a set of elements with at most one element in each part. For , the partition now corresponds to edges that share a vertex in , and for , edges that share a vertex in . Set the movement weights for all edges.

If there exists a feasible solution to 3DM with edges, choosing the corresponding elements form a solution with total weight . If the largest matching is of size , then we must pay extra over these three timesteps. This gives a -vs- gap for three timesteps.

To get a result for timesteps, we give the same matroids repeatedly, giving matroids at all times . In the “yes” case we would buy the edges corresponding to the 3D matching and pay nothing more than the initial , whereas in the “no” case we would pay every three timesteps. Finally, the APX-hardness for 3DM [22] gives the claim. ∎

The time-varying MSM problem does admit an approximation, as the randomized rounding (or the greedy algorithm) shows. However, the equivalence of MMM and MSM does not go through when the matroids change over time.

The restriction that the matroids vary over time is essential for the NP-hardness, since if the partition matroid is the same for all times, the complexity of the problem drops radically.

Theorem A.2

The MMM problem with partition matroids can be solved in polynomial time.


The problem can be solved using min-cost flow. Indeed, consider the following reduction. Create a node for each element and timestep . Let the partition be . Then for each and each , add an arc , with cost . Add a cost of per unit flow through vertex . (We could simulate this using edge-costs if needed.) Finally, add vertices and source . For each , add arcs from to all vertices with costs . All these arcs have infinite capacity. Now add unit capacity edges from to each , and infinite capacity edges from all nodes to .

Since the flow polytope is integral for integral capacities, a flow of units will trace out paths from to , with the elements chosen at each time being independent in the partition matroid, and the cost being exactly the per-time costs and movement costs of the elements. Observe that we could even have time-varying movement costs. Whereas, for graphical matroids the problem is hard even when the movement costs for each element do not change over time, and even just lie in the set . ∎

Moreover, the restriction in Theorem A.1 that is also necessary, as the following result shows.

Theorem A.3

For the case of two rounds (i.e., ) the MSM problem can be solved in polynomial time, even when the two matroids in the two rounds are different.


The solution is simple, via matroid intersection. Suppose the matroids in the two timesteps are and . Create elements which corresponds to picking element and in the two time steps, with cost . Lift the matroids and to these tuples in the natural way, and look for a common basis. ∎

a.2 Lower Bound for Deterministic Online Algorithms

We note that deterministic online algorithms cannot get any non-trivial guarantee for the MMM problem, even in the simple case of a -uniform matroid. This is related to the lower bound for deterministic algorithms for paging. Formally, we have the 1-uniform matroid on elements, and . All acquisition costs are 1. In the first period, all holding costs are zero and the online algorithm picks an element, say . Since we are in the non-oblivious model,the algorithm knows and can in the second time step, set , while leaving the other ones at zero. Now the algorithm is forced to move to another edge, say , allowing the adversary to set and so on. At the end of rounds, the online algorithm is forced to incur a cost of 1 in each round, giving a total cost of . However, there is still an edge whose holding cost was zero throughout, so that the offline OPT is 1. Thus against a non-oblivious adversary, any online algorithm must incur a overhead.

a.3 An LP Integrality Gap

In this section, we show that if the aspect ratio of the movement costs is not bounded, the linear program has a gap, even when is exponentially larger than . We present an instance where and are about with , and the linear program has a gap of . This shows that the term in our rounding algorithm is unavoidable.

The instance is a graphical matroid, on a graph on , and . The edges for have acquisition cost and holding cost for all . The edges for have acquisition cost and have holding cost determined as follows: we find a bijection between the set and the set of partitions of with each of and having size (by choice of such a bijection exists, and can be found e.g. by arranging the ’s in lexicographical order.) . In time step , we set for , and for all