Better Algorithms for Better Computers - PowerPoint PPT Presentation

About This Presentation
Title:

Better Algorithms for Better Computers

Description:

bananas. Query for cereal. Move 'up' accessed items for FREE! ... bananas. Query for cereal. Which items should we move to incur a minimum total cost? ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 48
Provided by: Shuchi2
Learn more at: http://www.cs.cmu.edu
Category:

less

Transcript and Presenter's Notes

Title: Better Algorithms for Better Computers


1
Better Algorithms for Better Computers
  • Shuchi Chawla
  • 3/18/02

2
An Optimal Algorithm for List Update
  • Shuchi Chawla
  • 3/18/02

3
The List Update Problem
Query for cereal
  • Maintain an unordered linked list of items
  • Query for ith item takes i time

1
4
The List Update Problem
Query for cereal
  • Maintain an unordered linked list of items
  • Query for ith item takes (i-1) time
  • Goal Minimize time spent

2
5
The List Update Problem
Query for cereal
  • What can the algorithm do?
  • Change positions of items in between accesses

at some cost!
3
6
Moving items between accesses
Query for cereal
  • What can the algorithm do?
  • Change positions of items in between accesses

at some cost!
4
7
Moving items between accesses
Query for cereal
  • Move up accessed items for FREE!
  • Other movements allowed at cost 1 per operation
  • New Goal minimize total cost
  • What can the algorithm do?

5
8
Why are we studying this?
  • Lists are a widely used data structure
  • Algorithms for lists can be generalized to other
    problems such as Binary Search Trees, Paging

Eg. List Update Order elements by frequency or
occurrence, most frequent in front Search
Trees Make a Huffman code tree based on
frequency counts
6
9
Why are we studying this?
  • Lists are a widely used data structure
  • Algorithms for lists can be generalized to other
    problems such as Binary Search Trees, Paging
  • Goals
  • Develop algorithm for List Update
  • Extend algorithm to a general strategy that
    provably works for any online data structure

7
10
Outline of the talk..
  • Rules of the game
  • The algorithm
  • Extensions and Conclusions

8
11
Outline of the talk..
  • Rules of the game
  • Online algorithms the scenario
  • Examples of known list update algorithms
  • Formal definition of Competitive Ratio
  • Previously known results
  • The algorithm
  • Extensions and Conclusions

9
12
Online Algorithms..
  • Compared against the best offline algorithm
  • The input is specified in steps
  • At every step, algorithm makes a move
  • Move should be good even with respect to future
    input!

knows future input
  • Constrain the algorithm cannot change state of
    the system

Static Alg
10
13
Back to the Grocery List
Query for cereal
  • Which items should we move to incur a minimum
    total cost?
  • Suggestions?

Frequency Counts
Move To Front
11
14
Move To Front
d (3)
OPTs Total cost 6
MTFs Total cost 12
  • MTF is always at most twice worse than OPT
  • FC achieves the same

12
15
Framework for measuring Algs performance
  • We compare ratio of Algs cost to Opts cost
  • If On input sequence S, Opt incurs cost O
  • And On S, Alg incurs cost at most ?O
  • Algs Competitive Ratio is ?
  • Formal Definition Competitive Ratio
    maxinputs (our cost)/(cost of
    OPT)

13
16
Worst Case Analysis
  • Adversary is all powerful
  • Can figure out which input is worst for Alg
  • Our ratio holds for all input sequences
  • Adversary cannot force us to perform worse

14
17
Can we do better than twice Opt?
  • Adversary knows the state of the algorithm
  • She always picks the last element
  • Even best SOPT has cost less than n/2 more than
    half the time
  • No Algorithm can do better than twice the optimal

15
18
Performance of randomized algorithms
  • Deterministic Competitive Ratio
    maxinputs (our cost)/(cost of OPT)
  • Randomized Competitive Ratio
    maxinputs Erandom bits(our cost)/(cost
    of OPT)

Worst Case Expected Ratio
16
19
Expected Worst Case Ratio
  • For every input
  • good performance with high probability
  • Adversary cannot force Alg to perform badly with
    probability 1

17
20
Whats known so far
  • No deterministic algorithm can perform better
    than a competitive ratio of 2.
  • For randomized algorithms, the best known
    algorithm achieves a 1.6 competitive ratio.

18
21
Our result
  • Algorithm with (1?) competitive ratio
  • Give a general strategy that achieves (1?) ratio
    for any data structure

19
22
Outline of the talk..
  • Rules of the game
  • The algorithm
  • Extensions and Conclusions

20
23
Outline of the talk..
  • Rules of the game
  • The algorithm
  • Machine learning alg Experts advice
  • Apply Experts advice to list update
  • Neat idea List Factoring
  • Algorithm for a two-element list
  • Extend it to n-element list
  • Extensions and Conclusions

21
24
Predicting from Experts advice
  • Predicting the stock market
  • Who should we believe?
  • Goal Perform as well as the best expert

22
25
Predicting from Experts advice
  • Initialize all weights to 1
  • Decrease weights on a mistake
  • Take a weighted vote for prediction

Can also choose an expert probabilistically using
weights as probability distribution
  • mistakes lt (1?) mexpert O(log N)

23
26
  • Experts advice algorithm achieves a (1?) ratio
    wrt best expert
  • Thats what we want for lists! thinking of
    static lists as our experts

24
27
Applying Experts to lists?
  • Goal (1?) wrt best static list
  • Experts analysis already does that!
  • Use all static lists as experts!
  • Assign weights according to costs incurred by
    experts
  • After every access, pick next static list using
    the right probability
  • Perform transpositions moving from one list to
    another

25
28
Applying Experts to lists?
  • Use all static lists as experts!
  • Can anyone see a problem with that?
  • Too many lists! exponential in number - n!
  • Requires exponential running time per query to
    update the weight of every static list

26
29
Experts for List Update
  • Weight for every static list too much
    computation
  • The BIG idea
  • Assign weights to every item in list and still
    make an experts style analysis work!

27
30
Candidate algorithm
  • Initialize wi for item i
  • If ith element accessed, update wi
  • Order elements using some rule based on wi
  • Need to analyze probability of getting a
    particular static list

28
31
Reality check
  • still awake?

29
32
Outline of the talk..
  • Rules of the game
  • The algorithm
  • Machine learning alg Experts advice
  • Apply Experts advice to list update
  • Neat idea List Factoring
  • Algorithm for a two-element list
  • Extend it to n-element list
  • Extensions and Conclusions

30
33
Idea 2 List FactoringBorodin ElYaniv
  • Under certain conditions
  • Ratio for two-element list holds for general list
  • ?Only need to analyze two-element list
  • Condition
  • The relative order of x and y in the list does
    not depend upon accesses to others

31
34
List Factoring Move To Front
32
35
List Factoring Move To Front
9
9 and 4 retain the same order LFL applies Can
analyze performance over second list
33
36
Algorithm for two element list
  • List (x,y)
  • Experts (x,y) and (y,x)
  • weights wx, wy

    correspond to the respective experts!
  • Algorithm
  • Initialize wx, wy to rx ry ?R 1..1/?
  • If x accessed, wx lt- wx1 else wy lt- wy1
  • Always keep the element with higher weight in
    front

34
37
  • Have algorithm with (1?) ratio for
    2- element list
  • Need Algorithm for n-element list
  • - satisfying LFL

35
38
Efficient Experts algorithm for List Update
  • Select ri ?R 1..1/? for element i
  • Initialize wi lt- ri
  • If ith element accessed, wi lt- wi1
  • Order elements in decreasing order of weight

Points to note Random initialization ?
probabilistic picking of expert Enables us to
satisfy LFL by using a deterministic rule for
ordering
36
39
Efficient Experts algorithm for List Update
? 0.1
37
40
Efficient Experts algorithm for List Update
? 0.1
d(0)
c(2)
38
41
Efficient Experts algorithm for List Update
  • (1?) static competitive for any ? gt 0
  • nearly optimal
  • Kalai Vempala02 give a similar result for trees

39
42
Outline of the talk..
  • Rules of the game
  • The algorithm
  • Extensions and Conclusions

40
43
Outline of the talk..
  • Rules of the game
  • The algorithm
  • Extensions and Conclusions
  • Comparing our alg with dynamic algorithms
  • Combining good static and dynamic algorithms
  • Lessons to be learnt

41
44
Extensions
  • Allowing Opt to move items between accesses

Dynamic (as opposed to static)
  • Comparing against Dynamic algorithms
  • Our alg could be far worse than Dynamic Opt
  • Previously known algorithms perform as well as a
    ratio of 1.6

42
45
Combining Static Dynamic optimality
  • A has constant static ratio, B has constant
    dynamic ratio
  • Combine the two to get the best of both
  • Apply Experts again
  • Technical difficulties
  • Cannot estimate weights running both
    simultaneously defeats our purpose
  • Experts maintain state - Huge cost of switching

43
46
Conclusions
  • First ever application of Experts advice to
    online data structures
  • Achieve a static ratio of (1?)
  • Settles the list update problem no better can
    be done
  • Application to other online problems
  • Naïve application is quite computationally
    intensive problem structure should be exploited
  • Constant dynamic ratio for trees still open!

44
47
Questions?
45
Write a Comment
User Comments (0)
About PowerShow.com