A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... ·...

17
A Distributed Solver for Massive Scale Resource Allocation Linear Programs MohammadHossein Bateni Google Inc. Dragos Florin Ciocan Massachusetts Institute of Technology Vivek Farias Massachusetts Institute of Technology Vahab Mirrokni Google Inc. 1. Introduction The “yield management” problem is a central optimization problem that must be solved by ad networks in the process of optimally matching “impressions” (sessions on web sites/ mobile apps, etc.) to advertisements. The problem is non-trivial since, in addition to many other business constraints, advertisers have finite budgets, the supply of impressions of a given type is limited, and finally, the economic value generated from a single impression can vary widely across ads and advertisers. The net economic value of this problem is large (on the order of tens of billions of dollars in a year). A “first best” approach to solving this problem in practice entails solving a certain linear program – the so-called “DLP”, and today forms the basis to solving yield management problems in several large industries (airlines, hospitality, etc.). This approach has not seen wide adoption in advertising applications which instead rely on certain “adaptive greedy” approaches to allocation in spite of a potentially large up-side to using the former approach. One of the primary reasons motivating this choice is efficient computation at scale. In particular, we do not have effective tools for the practical solution of the DLP at web-scale and in the sorts of distributed computational environments that are germane to those settings. This paper presents a candidate algorithm that is amenable to solving a large class of struc- tured linear programs that include the DLP in Map-Reducible environments, and at web-scale. In particular, we make the following contributions: 1. We develop an algorithm for solving structured LPs (such as the DLP) by solving a sequence of “projected” versions of the DLP, a general schema introduced in seminal work by Plotkins, Shmoys and Tardos two decades ago (Plotkin et al. [1995]). Here, we choose the projection carefully so that solving the projection relies on a fully combinatorial algorithm for the com- putation of a 2-D convex hull, which in turn relies on a sort. Put another way, the key large 1

Transcript of A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... ·...

Page 1: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

A Distributed Solver for Massive Scale Resource Allocation LinearPrograms

MohammadHossein BateniGoogle Inc.

Dragos Florin CiocanMassachusetts Institute of Technology

Vivek FariasMassachusetts Institute of Technology

Vahab MirrokniGoogle Inc.

1. IntroductionThe “yield management” problem is a central optimization problem that must be solved by adnetworks in the process of optimally matching “impressions” (sessions on web sites/ mobile apps,etc.) to advertisements. The problem is non-trivial since, in addition to many other businessconstraints, advertisers have finite budgets, the supply of impressions of a given type is limited,and finally, the economic value generated from a single impression can vary widely across ads andadvertisers. The net economic value of this problem is large (on the order of tens of billions ofdollars in a year).

A “first best” approach to solving this problem in practice entails solving a certain linearprogram – the so-called “DLP”, and today forms the basis to solving yield management problemsin several large industries (airlines, hospitality, etc.). This approach has not seen wide adoption inadvertising applications which instead rely on certain “adaptive greedy” approaches to allocationin spite of a potentially large up-side to using the former approach. One of the primary reasonsmotivating this choice is efficient computation at scale. In particular, we do not have effective toolsfor the practical solution of the DLP at web-scale and in the sorts of distributed computationalenvironments that are germane to those settings.

This paper presents a candidate algorithm that is amenable to solving a large class of struc-tured linear programs that include the DLP in Map-Reducible environments, and at web-scale. Inparticular, we make the following contributions:

1. We develop an algorithm for solving structured LPs (such as the DLP) by solving a sequenceof “projected” versions of the DLP, a general schema introduced in seminal work by Plotkins,Shmoys and Tardos two decades ago (Plotkin et al. [1995]). Here, we choose the projectioncarefully so that solving the projection relies on a fully combinatorial algorithm for the com-putation of a 2-D convex hull, which in turn relies on a sort. Put another way, the key large

1

Page 2: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

scale computational step in our scheme is a large scale sort; an operation that many mod-ern distributed computational frameworks, such as Map-Reduce handle well (see for instanceO’Malley [May 2008]).

2. We prove that the number of projections solved by our approach for an ε−optimal solutionscales like O

(ρ logAε2

), where A is the number of advertisers in the problem and ρ is a certain

sparsity parameter. Importantly, the number of rounds (or sorts) is independent of thenumber of impression types which can be very large – in the case of naive application of PST,the dependence would be O(log I + logA).

3. Most importantly, we implement our scheme in a large scale shared memory environmentwhere comparisons with commercial, non-distributed solvers are possible alongside compar-isons with state of the art distributed approaches tailored to solving packing programs. Herewe show that we outperform distributed approaches for packing programs by up to an orderof magnitude on typical instances. Surprisingly, we also outperform a state-of-the-art com-mercial solver that was optimized for network structured programs and made full use of allcores for linear algebraic operations; this commercial solver obviously cannot scale beyonda shared memory environment. While we are unable to describe it here, our solver has alsobeen implemented in a massive distributed environment at a preeminent online advertisingcompany.

1.1. Literature ReviewOur work lies at the intersection of several streams of research dealing with (a) dynamic resourceallocation, (b) distributed algorithms for linear optimization .Dynamic Resource Allocation: While the model of dynamic resource allocation we considercovers most models relevant to modern yield management, we single out two specific problemsrelevant to online advertising: Display Ads Allocation (DA) and AdWords (AW) both of which areconcerned with the allocation of impressions to advertisers. Ciocan and Farias [2012] presents amodel predictive control approach to solve such problems that requires repeatedly solving a certainLP and presents constant factor relative performance guarantees assuming that impression arrivalsare governed by a general class of stochastic processes. A related class of stochastic models assumesthat the stream of impressions form an exchangeable sequence. In this setting, Agrawal et al. [2013],Devanur and Hayes [2009], Feldman et al. [2010], Molinaro and Ravi [2012], Vee et al. [2010], alldevelop near optimal (i.e. (1− ε)-approximation) algorithms that rely on ’learning’ demand from afew early samples, solving a ’sampled’ linear program and then deriving an allocation mechanismfrom the solution of this program. The class of linear programs we consider in this paper subsumesthe class of programs considered in this stream of literature. It is worth noting that when thebudget or capacity of advertisers is “large”, the adversarial online AW and DA problem admit a(1 − 1

e )-competitive algorithm by applying a primal-dual technique Feldman et al. [2009], Mehtaet al.. This primal-dual analysis again rests on analyzing the properties of a linear program of asimilar nature as in the literature above and yields the sort of adaptive greedy algorithms thatfind use today. However, this approach eschews the use of impression traffic statistics taking a“worst-case” approach instead.Distributable First Order Methods for Linear Programming. While designing a parallelalgorithm for solving general linear programs is a P-complete problem, various primal-dual typetechniques have been developed for packing and covering LPs. The multiplicative weights frame-work of Plotkin et al. [1995] is closest to the current work – our algorithm can be interpreted

2

Page 3: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

as a multiplicative update, customized to our special “resource allocation” LP structure. Otheralgorithms that share commonality with multiplicative weights have been studied in Garg andKönemann [2007], Luby and Nisan [1993]. State-less distributed algorithms have been developedfor these problems Awerbuch and Khandekar [2008] and have been recently generalized for solvingmixed packing-covering LPs Manshadi et al. [2013]. There has been relatively less focus devoted tounderstudying these algorithms from a distributed systems perspective – to the best of our knowl-edge, Manshadi et al. [2013] is the only existing attempt at building a MapReducible LP algorithm.From a theoretical perspective, this work differs from the previous in that we seek a solution thatis optimized for resource allocation LPs, which we define shortly, rather than a generic algorithmfor packing/covering.

2. Linear Programs for Yield ManagementThe linear program we study is associated with a bi-partite graph with I sources indexed by i andJ sinks indexed by j. The edge set of this graph has size E, and a generic edge is denoted by e. Weuse the notation i(e) for the source node for edge e and j(e) for its sink node. Given this graph,define the following primitives:Demand: We associate each source i with a deterministic inflow equal to Di.Resources and Resource consumption: We are given a set of A distinct resources indexedby a. The available capacity of these resources is given by a vector B ∈ RA+. We assume thatallocating a unit of impression (demand) type i to advertiser (product) j (i.e. making an allocationalong edge e , (i, j)) consumes ca,e units of resource a. We write a ∈ j′ if ca,e > 0 for some edge eincident on j′, (i.e. j(e) = j′).Prices/ Revenues: Allocating a unit of demand along edge e generates revenue pe. Denote byp ∈ RE+ the column vector whose eth component is pe.

The objective is to maximize total revenues from fractionally allocating demand from sourcesto sinks:

maxx≥0

∑e

pexe

s.t.∑e

ca,exe ≤ Ba ∀ a∑e:i(e)=i

xe ≤ Di ∀ i.

(1)

We refer to the first set of constraints (indexed by a) as the resource constraints, and the second set(indexed by i) as the source constraints. We also note that, while our algorithm solves the primalallocation problem, it is quite easy (via complementary slackness) to transform an optimal primalsolution to this LP into a dual solution and obtain bid prices.

In practice, Di is obviously not known and must be learned; the following recipe has beenproposed by a number of authors: estimate Di by observing the demand process for a short time;use the LP with the estimated Di. Re-estimate Di at reasonable intervals of time and re-solve theLP.

2.1. ApplicabilityWhile the family of general resource allocation problems described above is applicable to many set-tings, we focus modeling several large scale offline ad allocation problems of practical interest. In

3

Page 4: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

Section ??, we will show how the computational toolkit we build for the offline case yields powerfulalgorithms for the online setting as well.

Online Ad-Display. The source nodes correspond to arriving impression types,1 and the sinknodes correspond to advertisers. There is a one-to-one correspondence between sinks and resources,as each advertiser has its own budget Ba which specifies the maximum number of times their adcan be displayed. Advertiser a declares a bid bi,a for each impression type i and there is an edgebetween i and a iff bi,a > 0. Typically, the allocation mechanism is first price, so we set pe = bi(e),a(e)and ca,e = 1 if and only if pe > 0. The model described here is typically representative of displayadvertising systems.

Generalized Second Price AdWords. This structure models sponsored search ad systems anddiffers from Ad-Display in several key features:

1. Mutiple slots: per impression, there are k ≥ 1 slots to be assigned to advertisers. Each slothas a non-increasing quality factor θl, with θ1 = 1; this reflects the fact that the ad shownin the top-most slot is more likely to be clicked on than the same ad placed in a lower slot.Advertiser a declares a bid bi,a for the top slot for impression i, and its bids for the lowerslots are scaled down by the quality factor.

2. Budget: in this version of the problem, budgets are specified in dollar terms rather thanimpression counts.

3. Generalized Second Price (GSP) allocation mechanism: upon the arrival of an impression oftype i, the ad network selects a set of k+1 advertisers; the advertisers are sorted in decreasingorder of their bids and assigned slots beginning from the top-most downwards. The amountthe advertiser in the l-th slot is charged is equal to the bid of the advertiser in the (l+ 1)-thslot; the (k + 1)-th advertiser does not receive a slot and is selected simply to determine theamount the k-th advertiser pays.

The mapping to our resource allocation graph is as follows: while the source nodes still corre-spond to impressions, the sink nodes now correspond to (k+ 1)-tuples of advertisers which we callslates; the number of slates is

( Ak+1), where A is the number of advertisers. For an edge e = (i, j)

with j = {a1, . . . , ak+1} and, wlog, bi,a ≥ bi,a′ for a ≥ a′ ∈ j, we set pe =∑kl=1 θlbi(e),al+1 and

ca,e = θlbi(e),al+1 if and only if a = al.Practical Scale For LP: In online ad related applications, the size of the bipartite graph is upto 1 billion impressions and 1 million advertisers, with 100 billion edges between them – in termsof data sizes, representing such a graph sparsely requires on the order of 100Gb. Lastly, we notethat in both applications, it is quite natural to think of the number of an impression as scalingexponentially in some feature dimension d; for example, a given impression may be specified byhundreds of features describing the user’s demographic information, browsing history and otherparameters.

1An impression can be thought of as a unit of web-traffic satisfying certain pre-assigned criteria, such as saygender, age, website etc.

4

Page 5: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

3. Map-Reducing The Yield Management LP.The yield management linear program (1) consists of A resource specific constraints and I sourcetype constraints. Our overall approach solves a sequence of relaxations to this problem by ’av-eraging’ the resource constraints. The solution to each such relaxation will be computed using a(distributed) algorithm that exploits strengths of the Map-Reduce paradigm with the key step thatuses ’all’ the data being a single (large) sort. In greater detail, the following is a schematic view ofthe algorithm:

1. Begin with the uniform measure w0 on all resources.

2. At the t-th stage construct a linear program, form Relax(wt) that relaxes (1) by replacingthe A resource constraints ∑

e

ca,eze ≤ Ba ∀ a

with a single ’averaged’ constraint∑a

wta∑e

ca,eze ≤∑a

wtaBa

using the measure wt.

3. Solve Relax(wt) using a fully combinatorial distributed algorithm that exploits map-reduce;described in detail in Section 3.1.

4. Use the solution of the relaxation to compute wt+1 (discussed in Section 3.2); go to step 2.In the following two sections, we answer (i) how one can solve Relax(wt) and (ii) how many

relaxations are necessary to guarantee convergence to an optimal solution of (1).

3.1. Solving Relax(w).Our goal here is to solve the relaxed program Relax(w) that forms the crux of each iteration of ourscheme. We first write this relaxation as

maxz≥0

∑e

peze

s.t.∑e

ceze ≤ B∑e:i(e)=i

ze ≤ 1 ∀ i,

(2)

where ce ,∑awaca,e and B ,

∑awaBa. Let us begin by observing that we can partition all the

decision variables ze of (2) by source node (i.e. impression type) i, suggesting I source type specificsubproblems whose primal and, respectively, dual are:

f i(Bi) = maxz≥0

∑e:i(e)=i

peze

s.t.∑

e:i(e)=iceze ≤ Bi

∑e:i(e)=i

ze ≤ 1

minu,v≥0

uBi + v

s.t. uce + v ≥ pe ∀e s.t. i(e) = i

5

Page 6: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

max pT1 z1 + . . .+ pTi zi + . . .+ pTnzn

s.t. cT1 z1 + . . .+ cTi zi + . . .+ cTnzn ≤ B̃

1T z1 ≤ 11T zi ≤ 1

1Txn ≤ 1

subproblem 1

B1?

subproblem i

Bi?

subproblem n

Bn?

Figure 1: Subproblem structure for an Ad-Display type allocation LP.

Figure 1 illustrates the nature of this decomposition pictorially. The objective value Relax(w) isthen equivalent to that of the following program:

maxB≥0

∑i

f i(Bi)

s.t.∑i

Bi ≤ B̃,(3)

This equivalent program is now easily seen to be a non-linear knapsack problem that we solveas follows:

1. Compute a representation of f i independently for each impression type i: We can show thatf i is concave and admits the following representation:

f i(B) =

u1B + v1, if B ∈ [0, Bi1)

. . .

ujB + vj , if B ∈ [Bij−1, B

ij)

. . .

ulB + vl, if B ∈ [Bil−1,∞).

The number of pieces is l ≤ d+1 where d is the number of non-zero coefficients in the constraint∑e:i(e)=i ceze ≤ Bi. Moreover, this representation can be computed in O(d log d) time. Denote

the k-th ’segment’ of this representation by the tuple (uk, vk,∆k) where ∆k = Bik − Bi

k−1 isthe length of the segment with the convention that Bi

0 = 0 and Bil = ∞. Define uk as the

slope of segment k.

2. Sort segments across all f i by slope (the key step that cannot be solved independently acrossall impression types): Construct an ordered list L consisting only of segments with positiveslope, with the property that segment slope is non-increasing in the order of the list. Thisstep requires E logE operations.

3. Build a solution: We must now allocate the budget B̃ in (4) across impression types. We dothis as follows: Consider segments in the list L in order. For segment (uk, vk,∆k) allocate

6

Page 7: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

the smaller of the remaining budget and ∆k to that segment and decrement the remainingbudget.

4. Construct primal solution: Given the optimal individual budget allocation to each subprob-lem, the primal solution to each subproblem can be computed using complementary slackness.

Before giving proofs for the validity of the algorithm’s steps, we note that:

1. The key computational step in the procedure above is the sort entailed in constructing thelist L; the remaining procedures are easily solved as (easy) independent sub problems. Inparticular, our overall algorithm will spend the bulk of its runtime in this step so that suchan algorithm will benefit tremendously from a system that is optimized to sort very large setsof numbers.

2. The relaxation provides an upper bound on the true optimum and, consequently, a certificatefor the optimality gap.

Lemma 1. The optimal value of the i-th subproblem with respect to its assigned budget Bi is apiecewise linear function of the form

f i(B) =

u1B + v1, if B ∈ [0, Bi1)

. . .

ukB + vk, if B ∈ [Bik−1, B

ik)

. . .

ulB + vl, if B ∈ [Bil−1,∞).

Additionally, l ≤ d + 1 where where d = |{e : i(e) = i}|, and the coefficients specifying f i can becomputed in O(d log d) time.

Proof. Consider the feasible region of the dual as illustrated in Figure ??. Although there are(d+ 2)2 possible intersections between the inequalities defining this feasible region, each constraintcannot create two intersections points with other constraints that lie on the envelope of the feasibleregion. Hence, the feasible region has at most d+1 extreme points (u1, v1), . . . , (ul, vl) with l ≤ d+1,and since the feasible region is convex, it must also be that vk ≤ vk+1 and uk ≥ uk+1.

It remains to prove that f i indeed has the threshold structure from the lemma’s statement.Clearly, for the (k + 1)-th extreme point to achieve at least the objective value than the k-th, itmust be that:

Bi >vk+1 − viuk − uk+1

and a direct inductive argument yields that extreme point (uk, vk) is optimal for Bi in the range

[Bik−1, B

ik) =

[vk − vk−1uk−1 − uk

,vk+1 − vkuk − uk+1

).

Moreover, it is a well known fact in computational geometry that finding the active constraints thatdefine the envelope can be reduced to finding the convex hull of at most d+ 1 points in the plane(Har-Peled [2011]). Hence, the constraints that determine the upper envelope can be computed inO(d log d) time. �

7

Page 8: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

Figure 2: Feasible regions and objective value parametrization of the i-th subproblem.

u0

v

Feasible region

Bi0 Bi1 Bi

2 Bi3

f i(Bi)

Objective functionparametrization

Having parametrized the subproblems, we now compute the optimal partitioning of B, i.e. find:

(B1, . . . , BI) ∈ argmax∑i

f i(Bi)

subject to∑i

Bi ≤ B,

Bi ≥ 0 ∀ i,

(4)

where f i is the parametrization of the objective of the i-th subproblem (as in Lemma 1). Fortu-nately, it turns out that the optimal solution to this problem has a similar structure to the solutionto a simple fractional knapsack program. In particular, the following algorithm computes the op-timal budget partition (B1, . . . , BI) by simply allocating the total budget B in order of highestmarginal return:

initialize L = ∅ and Bi = 0,∀iinitialize unallocated budget r = B;for i = 1, . . . , I do

calculate parameters of subproblem i’s segments{

(uki , vki ,∆ki )}

of f i;add all slopes uki > 0 of f i to the list L;

end for

sort L in decreasing order;while r > 0 do

pick next uki ∈ L and increase Bi by min{r,∆ki };

end while

8

Page 9: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

Informally, the algorithm initializes (B1, . . . , Bn) to 0 and increases the resource allocation Bi

to the subproblem i with the highest possible marginal return, given by uij , to the point that eitherB is exhausted or it not possible to increase budgets with positive marginal returns. Hence, thecomputational primitive that we require is the ability to sort all slopes (i.e. marginal returns) indecreasing. The theorem below shows that such a procedure indeed computes an optimal allocationof B.

Theorem 1. An optimal resource partition (B1, . . . , BI) that minimizes (4) is found in O(E logE)time by the above algorithm.

Proof. We show by contradiction that the optimal solution has the structure output by our algo-rithm. Let us account for the optimal resource allocation (B1, . . . , BI) in a more detailed way:in particular, let δki be the resource amount that is allocated in this optimal solution to the k-th segment of subproblem i; by definition

∑k δ

ki = Bi. There exists an optimal solution with

all Bi ≤∑

∆ki , since increasing budget past that point does not change the objective value of

subproblem i.Our algorithm produces an allocation with the following property

(5) for any indices i1, i2, k1, k2 with uk1i1> uk2

i2, δk2

i2> 0 iff δk1

i1= ∆k1

i1

Let us assume for a contradiction that the optimal resource allocation vector does not have thisproperty. Then, there must exist indices i1, i2, k1, k2 with uk1

i1> uk2

i2and ν > 0 such that δk1

i1≤

∆k1i1−ν and δk2

i2> ν (this corresponds to a scenario where the algorithm has allocated some amount

ν to a segment with a lower slope instead of one with a higher one). Then, one can decrease δk2i2

byν and increase δk1

i1by the same amount; this will preserve the overall allocation level

∑iB

i, whileit will increase the objective value by ν(ui1j1 −u

i2j2

) ≥ 0, leading to a solution that strictly dominatesthe one we had started with. Therefore any optimal budget allocation must have property (5). Itcan be easily verified that any allocation satisfying this property yields the same objective value,thus proving that the algorithm terminates with an optimal objective.

Since the algorithm needs to sort at most as many ratios as there are edges in the graph, thecomplexity is O(E logE). �

So far, we have built a vector of allocations of B to each subproblem that achieves the optimum.What is left to do is find a primal assignment that corresponds that this optimum value. Thefollowing lemma provides this by proving that it is easy to convert optimal dual solutions tooptimal primal solutions. It relies on a standard complementary slackness-based argument.

Lemma 2. Given a level of resource allocation Bi and an optimal dual solution (u, v), the optimal(primal) solution to the i-th subproblem can be found in O(d) time.

Proof. Let us begin by writing down the complementary slackness conditions for the optimal u, v, z:

u

∑e:i(e)=i

ceze −Bi

= 0

v

∑e:i(e)=i

ze − 1

= 0

ze (uce + v − pe) = 0, ∀e subject to i(e) = i.

There are three cases:

9

Page 10: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

1. u = 0, v > 0. Then,∑e:i(e)=i ze = 1 and the optimal primal is found by allocating fully to

the edge e with maximum price pe. This follows from the feasibility condition uce + v ≥pe,∀e subject to i(e) = i, so only the ze with maximal price can be positive. Note that we areassuming here there is a single item with maximal price - this can achieved without loss ofgenerality by an arbitrarily small random perturbation of the price vector.

2. v = 0, u ≥ 0. Similarly to the first case, it follows from the complementary slackness condi-tions that it is optimal to fully allocate along the edge e with the maximal ratio pe/ce.

3. u > 0, v > 0. Thus implies that∑e:i(e)=i ze = 1 and

∑e:i(e)=i ceze = Bi. By construction

of the envelope, we cannot have more than two tight constraints v + uce − pe = 0, so bythe last complementary slackness condition only two ze’s can be positive. Therefore, we cancompletely identify the primal solution.

In either case, the solution can be determined using no more than O(d) calculations.�

3.2. Updating Weights.So far we have shown how given a set of weights w one can solve Relax(w) efficiently. In thissection, we make use of the multiplicative weights machinery due to the Plotkin, Shmoys andTardos (Plotkin et al. [1995]) to yield an algorithm that will convergence to an optimal solutionin an appropriate sense by solving a sequence of such relaxation linked together by multiplicativeupdates of the weight vector w.

Given an initial set of weights wt, and a solution to the program Relax(wt) (obtained via theprocedure above), we proceed to generate an updated set of weights wt+1 as follows. Now a solutionto Relax(wt) may well violate some (if not most) of the resource constraints in the LP we are tryingto solve, (1). We first compute the extent by which each of these constraints is violated as definedby

va(z) =∑e

ca,eze −Ba.

Before we update weights we define an error parameter ε and a parameter ρ typically called theLP width which equals maxa maxz |va(z)|. Now we update weights according to

wt+1a = wta

(1− εva(z)

ρ

).

Finally, we normalize wt+1 so that the entire weight vector sums to unity.We are left with showing that the algorithm does not need to perform too many weight up-

dates before converging to a good solution. As hinted before, we appeal to the multiplicativeweights (MW) framework for solving packing/covering LPs due to Plotkin et al. [1995] and Aroraet al. [2005]. We note however that the framework gives us algorithmic freedom in terms of whatrelaxation to choose for (1). In particular, a first attempt at choosing a relaxation for which themultiplicative weights algorithm could be applied would relax all constraints of the LP; in this case,Relax(w) would become a fractional knapsack which, as mentioned in the previous section, admitsa solution that is both very efficient and amenable to being Map Reduced. Such a straightforwardknapsack relaxation fails to take advantage of the special structure of our problem, and leads toboth a higher number of iterations in theory (depending on log(IA) instead of logA) as well as

10

Page 11: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

worse practical performance. In fact, it is our intuition that the encouraging practical performancewhich we will highlight in our experiments section is due to this particular choice of relaxationrather than due to the choice of weight update method.

The following theorem bounds the number of weight updates, and is a application of of themachinery from Arora et al. [2005]:

Theorem 2. Let δ > 0 be an error parameter and ε = min{δ

4ρ ,12

}. For T ≥ 16ρ logA

δ2 , consider thesequence z1, . . . , zT of solutions obtained thorough performing T multiplicative weight updates withupdate step size ε. Let z be the average solution, z =

∑Tt=1 z

t. Then x satisfies:

1. z ∈ χ and z is δ-feasible for all resource constraints,∑e ca,eze ≤ Ba + δ, ∀ a.

2. The objective value of z at least equal to the optimal objective of (1).

Proof. The first part follows directly from applying Corollary 4 from Arora et al. [2005]. The secondpart follows from the fact that the objective value of each relaxation is greater by construction thanthe optimal objective of (1). �

Before proceeding, we note that this approach is completely symmetrical: instead of relaxingall resource constraints while keeping the source constraints explicit, it is equally possible to relaxthe source constraints instead, and obtain a “mirrored” relaxation

maxz≥0

∑e

peze

s.t.∑e

ca,eze ≤ Ba ∀ a∑e

wa(e)ze ≤∑a

wa.

A mirrored argument could show what the complexity of solving this relaxation also reduced to anon-linear knapsack problem which mirrors the O(E logE) one from the previous section. While inthis case, the theoretical number of iterations increases from logA to log I, using this relaxation isworthwhile in practice. In fact, in our experiments described in Section 3.4, we test both approachesand find that choosing between these two relaxations carefully can have significant impact onperformance. In addition, as a direction of future research, we think that the idea of using bothrelaxations in parallel could lead to an algorithm with improved performance over the one consideredhere.

3.3. Distributed Implementation of the Algorithm.While a comprehensive systems design document is beyond the scope of this paper, we outline howthe inner algorithm is expressible in the MapReduce framework. One solve of Relax(w) is carriedin two Map-Reduce steps, with the main challenge being performing the large and computing avalue to the non-linear knapsack (4). The pseudocode is given below:

MapReduce round 1Mapper i

Input: subproblem i data

11

Page 12: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

Calculate the set of slopes and budget cutoffs of f i,Li = {(i, j, uki ,∆k

i ), for all j ∈ [|{e : i(e) = i}|+ 1]}Emit (key, value) = (i, j, uki ,∆k

i )Partitioner

Sample num_reducers keys from ∪iLiAssign uki to Reducer j iff key[j − 1] ≤ uji < key[j]

Reducer jBj = 0for all uki received do

Bj ← Bj + ∆ki

Lj = Lj ∪ {(i, j, uki ,∆ki )}

end forEmit (j, Bj , Lj)

Synchronization roundCompute threshold j∗ at which

∑1≤j≤j∗ Bj ≥ B

Output (j∗, B −∑

1≤j≤j∗−1Bj)MapReduce round 2

Mapper kInput: j∗, B −

∑1≤j≤j∗−1Bj , Lj

if j 6= j∗ thenAllocate ∆k

i of B along all slopes uki in Ljelse

Allocate B in increasing slope order up to level B −∑

1≤j≤j∗−1Bjend iffor all slopes in Lj do

Emit (key, value) = (i, (uki , i, k, resource_allocation))end for

Reducer iAggregate optimal resource allocation Bi for subproblem iCompute and output primal solution of subproblem i

In the first Map Reduce step, the segments describing each subproblem are computed and sorted.Note that, as in the implementation of TeraSort from O’Malley [May 2008], we use a customizedpartitioner with randomized pivots for the aggregate list of segment slopes output by the mappers;this ensures that the list of slopes is globally sorted, and that the load on each reducer is balanced.The aggregate list of sorted segment slopes is then partitioned and sent to reducers, each of whichthen calculates how much budget would be used if each segment were to receive an allocation.

Since the slopes were partitioned to the reducers after being sorted, it is now straightforwardfor a synchronization round to go through the reducers and figure out the reducer index j∗ pastwhich the aggregate allocation exceeds B. Finally, in the second Map Reduce, the optimal re-source allocations to each segment can be computed given j∗ and, consequently, the optimal primalassignment.

3.4. Experimental Performance.We implemented a shared memory parallel version of our algorithm using C++ and OpenMP.The code can be found at: https://sites.google.com/site/nips2014mrlp/. We run our ex-

12

Page 13: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

periments on a machine with dual 2.93GHz Intel Xeon 6-core processors and 128Gb of memory.While our algorithm is ultimately designed to port to the non-shared memory model, the purposeof this shared memory implementation is to allow benchmarking versus: (i) state-of-the-art sharedmemory implementations of simplex: the benchmark we use is CPLEX 12.5 (using primal simplex)and (ii) first-order methods that are also amenable to distributed implementations: we pick theprimal/ dual method (“AW P/D”) of Awerbuch and Khandekar [2008], Manshadi et al. [2013] asa benchmark and note that this method also employs multiplicative updates for the dual variables.

We test our implementation on a family of synthetic instances of Ad-Display and AdWordsproblems. Each instance has 1mm impressions and 1mm advertisers. We generate the matrix of bidsfrom advertisers to impressions in the following way: for each advertiser, we choose 100 impressionsuniformly at random for which we assign an edge (i.e., a non-zero bid.) At this sparsity, storing thebid matrix (represented as a list) in memory requires 3Gb. We generate the bid values according toa factor model that is designed to simulate “hot”/“cold” advertisers and impressions. In particular,for each impression i, we generate a 5-dimensional feature vector φi with each component drawni.i.d. from a log-normal distribution. We also generate a similar feature vector θa for each advertiser.We then set bi,a =< φi, θa > for each impression to advertiser edge.

We choose advertiser budgets in order to simulate several load factor scenarios. Depending onthe instance type, we define its load factor in alternate ways:

LF =

aBa

I if instance is Ad-Display∑aBa

IE[bi,a] if instance is AdWords

We set the budgets Ba uniformly to achieve load factors taking values in {0.5, 0.75, 1, 1.5, 2}. Weheuristically initialize the multiplicative weight of advertiser a to be proportional to the averagebid going into a (wa ∝

∑i bi,a/100.) For both sets of experiments, we set ε = 0.5. Also, we set

a burn-in period for which still do the regular multiplicative updates but which we do not countinto the calculation of the primal solution; we use a burn-in of either 25 or 50 iterations and reportwhichever run results in fewer iterations. As noted before, our algorithm works analogously if werelax the source (impression) constraints rather than the resource (advertiser) ones; in the resultsbelow, we report performance of the best.

Table 1 reports the number of iterations required for our algorithm to reach 95% optimalityand Figure 3 shows the speed of convergence for a particular Ad-Display instance where we set theload factor to 1. We note that the algorithm is fast at reaching 95% optimal solutions, requiringfewer than 100 iterations. Since in many distributed frameworks such as MapReduce, the setuptime to run one round is quite high, an algorithm which requires a small number of rounds ishighly desirable. The slow convergence beyond the 95% point can be improved by lowering ε atthe expense of slower initial progress.

Table 2 compares the wall clock times required by our algorithm versus CPLEX and an imple-mentation of AW P/D 2; we measure the time required to reach 95% the optimal values for out setof Ad-Display and, respectively, AdWords experiments:

1. Comparison with CPLEX: Our algorithm is consistently as fast, if not better, than CPLEX.This is quite surprising, since CPLEX is optimized for speed in multicore shared memoryenvironments.

2We also use the primal initialization and dynamic stepsizes employed in Manshadi et al. [2013]

13

Page 14: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

Table 1: Iteration count to 95% optimality.XXXXXXXXXXXInstance Type

LF 0.5 0.75 1 1.5 2

Ad-Display 52 48 59 55 73AdWords 34 46 56 59 62

Figure 3: Progress per iteration for our algorithm for an Ad-Display instance with LF= 1.

0 20 40 60 80 100

0.75

0.80

0.85

0.90

0.95

1.00

number of iterations

appr

oxim

atio

n ra

tio

2. Comparison with AW P/D: On Ad-Display instances, AW P/D has a running time of almost afactor of magnitude larger and, in fact, the best approximation we could achieve with AW P/Dwas only around 90% for some of our problems. Moreover, we observe that it requires a muchlarger number of iterations compared to our approach. We interpret this as an indication thatthe buy in our algorithm does not necessarily come from the use of a multiplicative updaterule, but rather from that fact that we solve a particularly tight relaxation of the originalfeasible space. On our AdWords instances, AW P/D is competitive with our scheme andCPLEX; this is consistent with our intuition that AdWords type instances should be easierto approximate due to the one to one correspondence between the objective value and theadvertiser budget constraints.

4. Conclusions and Future DirectionsThe present paper attempts to make a first step towards building a distributed solver for allocationlinear programs. The multiplicative weights algorithm we employ naturally takes advantage of the

14

Page 15: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

Table 2: 95% optimality wall clock times (in minutes) for Ad-Display.

Ad DisplayPPPPPPPPPAlgo

LF 0.5 0.75 1 1.5 2

MW 10.76 10.58 13.75 11.73 14.73CPLEX 14.86 15 15.3 16.45 14.91AW P/D Algo 86.66 110.2 132.2 >200 >200

Table 3: 95% optimality wall clock times (in minutes) for AdWords.

AdWordsPPPPPPPPPAlgo

LF 0.5 0.75 1 1.5 2

MW 7.03 9.51 13.06 11.38 11.72CPLEX 15.23 15 15.3 15.71 14.91AW P/D Algo 8.8 12.3 20.1 78.1 180.6

15

Page 16: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

computational primitives that existing distributed computing frameworks are optimized to solveand has attractive theoretical guarantees. Quite surprisingly, our practical experiments indicate italso competitive or better in terms speed versus existing shared memory solvers. There are severaldirections that we find interesting:

(i) Fully distributed implementation: While our current shared memory interpretation is usefulfor benchmarking, our ultimate goal is to solve terabyte sized LPs, which can only be achievedwith a fully distributed version of our code.

(ii) Alternating relaxations: Our algorithm works symmetrically for the cases where we relaxresource or source constraints. It would be interesting to see if an algorithm which alternatesbetween solving a resource constraints relaxation and a source constraints one could yieldbetter convergence.

(iii) Warm start guarantees: As suggested in the second part of the paper, the setting that is mostinteresting to us is one where the LP is resolved over the length of an ad campaign. Accessto warm starts could potentially strengthen the convergence guarantees for our algorithm.

(iv) Dimension reduction for GSP AdWords: It would be interested to see if it is possible to reducethe number of slates that must be considered and obtain better scaling with k.

ReferencesShipra Agrawal, Zizhuo Wang, and Yinyu Ye. A dynamic near-optimal algorithm for online linear

programming, 2013.

Sanjeev Arora, Elad Hazan, and Satyen Kale. The multiplicative weights update method: a metaalgorithm and applications. Technical report, 2005.

Baruch Awerbuch and Rohit Khandekar. Stateless distributed gradient descent for positive linearprograms. In STOC, pages 691–700, 2008.

D.F. Ciocan and Vivek Farias. Model predictive control for dynamic resource allocation. mathe-matics of operations research. Mathematics of Operations Research, 37(3):501–525, 2012.

Nikhil R. Devanur and Thomas P. Hayes. The adwords problem: online keyword matching withbudgeted bidders under random permutations. In Proceedings of the 10th ACM conference onElectronic commerce, EC ’09, pages 71–78, New York, NY, USA, 2009. ACM. ISBN 978-1-60558-458-4. doi: 10.1145/1566374.1566384. URL http://doi.acm.org/10.1145/1566374.1566384.

Jon Feldman, Nitish Korula, Vahab Mirrokni, S. Muthukrishnan, and Martin Pal. Online adassignment with free disposal. In Stefano Leonardi, editor, Internet and Network Economics,volume 5929 of Lecture Notes in Computer Science, pages 374–385. Springer Berlin Heidelberg,2009. ISBN 978-3-642-10840-2. doi: 10.1007/978-3-642-10841-9_34. URL http://dx.doi.org/10.1007/978-3-642-10841-9_34.

Jon Feldman, Monika Henzinger, Nitish Korula, Vahab S. Mirrokni, and Cliff Stein. Online stochas-tic packing applied to display ad allocation. In Proceedings of the 18th annual European confer-ence on Algorithms: Part I, ESA’10, pages 182–194, Berlin, Heidelberg, 2010. Springer-Verlag.ISBN 3-642-15774-2, 978-3-642-15774-5. URL http://dl.acm.org/citation.cfm?id=1888935.1888957.

16

Page 17: A Distributed Solver for Massive Scale Resource Allocation ... › c54c › c27a466441b... · advertising applications which instead rely on certain “adaptive greedy” approaches

Naveen Garg and Jochen Könemann. Faster and simpler algorithms for multicommodity flow andother fractional packing problems. SIAM J. Comput., 37(2):630–652, May 2007. ISSN 0097-5397.doi: 10.1137/S0097539704446232. URL http://dx.doi.org/10.1137/S0097539704446232.

Sariel Har-Peled. Geometric Approximation Algorithms. American Mathematical Society, Boston,MA, USA, 2011. ISBN 0821849115, 9780821849118.

Michael Luby and Noam Nisan. A parallel approximation algorithm for positive linear program-ming. pages 448–457, 1993.

Faraz Makari Manshadi, Baruch Awerbuch, Rainer Gemula, Rohit Khandekar, Julián Mestre, andMauro Sozio. A distributed algorithm for large-scale generalized matching. PVLDB, 6(9):613–624,2013.

A. Mehta, A. Saberi, U Vazirani, and V. Vazirani. Adwords and generalized on-line matching. InFOCS �05: Proceedings of the 46th Annual IEEE Symposium on Foundations of ComputerScience.

Marco Molinaro and R. Ravi. Geometry of online packing linear programs. In Artur Czumaj,Kurt Mehlhorn, Andrew M. Pitts, and Roger Wattenhofer, editors, ICALP (1), volume 7391of Lecture Notes in Computer Science, pages 701–713. Springer, 2012. ISBN 978-3-642-31593-0.URL http://dblp.uni-trier.de/db/conf/icalp/icalp2012-1.html#MolinaroR12.

Owen O’Malley. Terabyte sort on apache hadoop, May 2008.

Serge A. Plotkin, David B. Shmoys, and Eva Tardos. Fast approximation algorithms for fractionalpacking and covering problems, 1995.

Erik Vee, Sergei Vassilvitskii, and Jayavel Shanmugasundaram. Optimal online assignment withforecasts. In ACM EC, 2010.

17