Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Online algorithms Typically when we solve problems and design algorithms we assume that we know all the data a priori. However in many practical situations.

Similar presentations


Presentation on theme: "1 Online algorithms Typically when we solve problems and design algorithms we assume that we know all the data a priori. However in many practical situations."— Presentation transcript:

1

2 1 Online algorithms Typically when we solve problems and design algorithms we assume that we know all the data a priori. However in many practical situations this may not be true and rather than have the input in advance it may be presented to us as we proceed. Input is revealed to the algorithm incrementally Output is produced incrementally Some output must be produced before the entire input is known to the algorithm Decision making under partial information Unknown information: the future

3 2 Applications Resource Allocation Scheduling Memory Management Robot Motion Planning Exploring an unknown terrain Finding a destination Computational Finance

4 3 Methods of Analysis Definition An online algorithm A is R-competitive if for all input sequences I, A(I) ≤ROPT(I), where A(I) is the cost of the online strategy A for I and OPT(I) is the cost of the optimal offline algorithm for I. In many cases the definition of competitiveness is slightly relaxed by imposing that A(I) ≤ROPT(I)+c for some constant c independent of I.

5 4 Ski Rental Problem you are a skier and each day need to either rent skis for $1 or buy a pair of skis for $T which will last for the rest of the season. Unfortunately you do not know when the ski season will end. If you knew a priori the length of the season (this is the online case) say L then it is obvious that you should rent if L<T and buy if L≥T. On the other hand, an online strategy for this problem would first fix an integer k and then rent for k days and buy on day k+1 if it has the opportunity.

6 5 One strategy is to buy on the first day. This strategy is T-competitive and the worst input sequence is obtained when L=1. Another online strategy is to rent for the first T-1 days and then buy. If L<T the cost of the online and optimal offline strategy is the same. If L≥T the cost of the online strategy is 2T-1 and the cost of the optimal offline strategy is T. Hence this algorithm is (2-1/T)- competitive and it is fairly easy to show that it is the optimal online algorithm.

7 6 The Online Transportation Problem 5 miles 2 miles 3 miles 4 miles 2 miles

8 7 The Online Transportation Problem Given: a set of hospitals, each with a different sized ambulance fleet emergency sites that arise in unpredictable locations over time, each in immediate need of an ambulance Return: an assignment of ambulances to emergencies that minimizes the total distance traveled by all the ambulances

9 8 Why Greedy can be Bad Consider A, a large hospital with a dozen available ambulances, and B, a small hospital with only 2 ambulances. Imagine an emergency breaks out between A and B, but a bit closer to B. A B 10 miles 9 miles

10 9 Why Greedy can be Bad Since B is closer, we dispatch an ambulance from B. But what if two emergencies then break out on the other side of B from A? This solution costs 31 miles! A B 9 miles A 20 miles 2 miles

11 10 Why Greedy can be Bad If instead we chose hospital A for the first emergency, then used the ambulances at hospital B for the second and third......the distance traveled is much less! A B 2 miles A 10 miles 2 miles

12 11 Online Matching Problem Definition 9.14 Given an undirected graph G = (V, E), a matching is a subset of edges M E such that for all vertices v ∈ V, at most one edge of M is incident on v. We say that a vertex v ∈ V is matched by matching M if some edge in M is incident on v; otherwise, v is unmatched. A maximum matching is a matching of maximum cardinality. Definition 9.15 Perfect matching is one in which every vertex in V is matched Maximum weight matching:Matching in a weighted graph in which the sum of the weights of its edges is maximum.

13 12 Bipartite Graph Graph G = ( L  R, E) with L  R = , namely A graph is bipartite if its vertex set can be partitioned into two subsets L and R so that each edge has one endpoint in L and the other endpoint in R.

14 Intuition Let the left set of vertices be men Let the right set of vertices be women Suppose each edge represents a pair of man and woman who like each other Maximum matching tries to maximize the number of couples!

15 Online Bipartite matching problem A matchmaker and n boys are gathered in a room. n girls appear, one at a time. Each girl has a list of boys who are acceptable to her, which she reveals to the matchmaker as she appears. The matchmaker immediately matches the new girl to one of the boys on her list, if any of them are available. The goal is to maximize the number of matches. 14

16 Online bipartite matching V (boys) U (girls)

17 Online bipartite matching V (boys) U (girls)

18 Online bipartite matching V (boys) U (girls)

19 Online bipartite matching V (boys) U (girls)

20 Online bipartite matching V (boys) U (girls)

21 Online bipartite matching V (boys) U (girls)

22 Online bipartite matching V (boys) U (girls)

23 Adwords Problem Created by search engine companies Google Yahoo! MSN Multi-billion dollar market Totally revolutionized advertising, especially by small companies.

24 Monika Henzinger, 2004: Find an on-line algorithm that maximizes Google’s revenue.

25 The Adwords Problem: N advertisers; Daily Budgets B 1, B 2, …, B N Each advertiser provides bids for keywords he is interested in. Search Engine

26 The Adwords Problem: N advertisers; Daily Budgets B 1, B 2, …, B N Each advertiser provides bids for keywords he is interested in. Search Engine queries (online)

27 The Adwords Problem: N advertisers; Daily Budgets B 1, B 2, …, B N Each advertiser provides bids for keywords he is interested in. Search Engine Select one Ad Advertiser pays his bid queries (online)

28 The Adwords Problem: N advertisers; Daily Budgets B 1, B 2, …, B N Each advertiser provides bids for keywords he is interested in. Search Engine Select one Ad Advertiser pays his bid queries (online) Maximize total revenue Online competitive analysis - compare with best offline allocation

29 The Adwords Problem: N advertisers; Daily Budgets B 1, B 2, …, B N Each advertiser provides bids for keywords he is interested in. Search Engine Select one Ad Advertiser pays his bid queries (online) Maximize total revenue Example – Assign to highest bidder: only ½ the offline revenue

30 Example: $1$0.99 $1 $0 Book CD Bidder1Bidder 2 B1 = B2 = $100 Queries: 100 Books then 100 CDs Bidder 1 Bidder 2 Algorithm Greedy LOST Revenue 100$

31 Example: $1$0.99 $1 $0 Book CD Bidder1Bidder 2 B1 = B2 = $100 Queries: 100 Books then 100 CDs Bidder 1 Bidder 2 Optimal Allocation Revenue 199$

32 Generalizes online bipartite matching Each daily budget is $1, and each bid is $0/1.

33 32 Challenges Faced Intuition: A good algorithm must find a balance between distance of an emergency from the hospitals and the resources remaining at each hospital. Negative Results: Such balancing is not possible. The competitive ratio of every deterministic online algorithm is bad (linear in the number of hospitals). Random online algorithm.


Download ppt "1 Online algorithms Typically when we solve problems and design algorithms we assume that we know all the data a priori. However in many practical situations."

Similar presentations


Ads by Google