Title: Better Algorithms for Better Computers
1Better Algorithms for Better Computers
2An Optimal Algorithm for List Update
3The List Update Problem
Query for cereal
- Maintain an unordered linked list of items
- Query for ith item takes i time
1
4The List Update Problem
Query for cereal
- Maintain an unordered linked list of items
- Query for ith item takes (i-1) time
2
5The List Update Problem
Query for cereal
- What can the algorithm do?
- Change positions of items in between accesses
at some cost!
3
6Moving items between accesses
Query for cereal
- What can the algorithm do?
- Change positions of items in between accesses
at some cost!
4
7Moving 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
8Why 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
9Why 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
10Outline of the talk..
- Rules of the game
- The algorithm
- Extensions and Conclusions
8
11Outline 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
12Online 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
13Back 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
14Move 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
15Framework 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
16Worst 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
17Can 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
18Performance 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
19Expected Worst Case Ratio
- For every input
- good performance with high probability
- Adversary cannot force Alg to perform badly with
probability 1
17
20Whats 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
21Our result
- Algorithm with (1?) competitive ratio
- Give a general strategy that achieves (1?) ratio
for any data structure
19
22Outline of the talk..
- Rules of the game
- The algorithm
- Extensions and Conclusions
20
23Outline 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
24Predicting from Experts advice
- Predicting the stock market
- Who should we believe?
- Goal Perform as well as the best expert
22
25Predicting 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
27Applying 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
28Applying 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
29Experts 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
30Candidate 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
31Reality check
29
32Outline 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
33Idea 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
34List Factoring Move To Front
32
35List Factoring Move To Front
9
9 and 4 retain the same order LFL applies Can
analyze performance over second list
33
36Algorithm 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
38Efficient 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
39Efficient Experts algorithm for List Update
? 0.1
37
40Efficient Experts algorithm for List Update
? 0.1
d(0)
c(2)
38
41Efficient Experts algorithm for List Update
- (1?) static competitive for any ? gt 0
- nearly optimal
- Kalai Vempala02 give a similar result for trees
39
42Outline of the talk..
- Rules of the game
- The algorithm
- Extensions and Conclusions
40
43Outline 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
44Extensions
- 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
45Combining 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
46Conclusions
- 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
47Questions?
45