Evaluation of Algorithms for the List Update Problem
description
Transcript of Evaluation of Algorithms for the List Update Problem
Evaluation of Algorithms Evaluation of Algorithms for the List Update for the List Update
Problem Problem
Suporn PongnumkulR. Ravi
Kedar Dhamdhere
OverviewOverview
• List Update Problem• Competitive Analysis• Average Case Analysis• Our Hybrid Model• Setup of our experiment• Results from our experiment• Conjecture
List Update ProblemList Update Problem• Self-organizing sequential search
• Unsorted list
• Received a sequence of requests
• Cost of accessing the ith element of the list is i.
y w z x v uL:
y w z x v uL:
List Update ExampleList Update Example
Action Cost Total Cost
y w z x v uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x
y w z x v uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
y w z x v uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
Access v
y w z x v uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
Access v 5 9
y w z x v uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
Access v 5 9
Move v forward to before w
y v w z x uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
Access v 5 9
Move v forward to before w 0 9
y v w z x uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
Access v 5 9
Move v forward to before w 0 9
Access y
y v w z x uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
Access v 5 9
Move v forward to before w 0 9
Access y 1 10
y v w z x uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
Access v 5 9
Move v forward to before w 0 9
Access y 1 10
Access v
y v w z x uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
Access v 5 9
Move v forward to before w 0 9
Access y 1 10
Access v 2 12
y v z w x uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
Access v 5 9
Move v forward to before w 0 9
Access y 1 10
Access v 2 12
Transpose w and z
y v w z x uL:
List Update ExampleList Update Example
Action Cost Total Cost
Access x 4 4
Access v 5 9
Move v forward to before w 0 9
Access y 1 10
Access v 2 12
Transpose w and z 1 13
Competitive AnalysisCompetitive Analysis
• Definition: An analysis in which the performance of an online algorithm is compared to the best that could have been achieved if all the inputs had been known in advance.
Competitive RatioCompetitive Ratio
A:Our online algorithm
CA()
OPT:Optimal Offline
algorithm
COPT()
A is c-competitive if aCA() ≤ c COPT() + a
for all request sequences
Move-to-Front (MTF)Move-to-Front (MTF)
• When an element is accessed, move it to the front of the list.
• Theorem: [Sleator, Tarjan, 1985] MTF has competitive ratio 2 against optimal offline algorithm.
Average Case AnalysisAverage Case Analysis• Assume each request comes from a
fixed probability distribution, independent of previous requests. Suppose the ith item has probability pi. Design algorithms to minimize the expected cost.
• Optimal strategy is to keep the list sorted in non-increasing order of pi.
STAT = Static ListSTAT = Static List• List is sorted in non-increasing order
of the probabilities
• Never moves anything
• Good for when we have a good estimate of the probability distribution.
Need a new model?Need a new model?• Most real-world settings don't behave
either like a discrete distribution, or like a worst-case one.
• Can we design an algorithm that does well in both typical and worst-case?
• How could we analyze such algorithms?
Hybrid ModelHybrid Model• Assume a fixed probability distribution,
• For each request, with probability , let the adversary change the request.
• Average Case Analysis
• Competitive Analysis
• Known probability distribution with uncertainty.
),...,,( 21 npppp
01
10
Hybrid Algorithm?Hybrid Algorithm?• Parameterized by
• Matches best average case performance when is low, and matches best competitive ratio when is high.
Move-From-Back-EpsilonMove-From-Back-Epsilon• List initially sorted in non-increasing
order of probabilities.
• When an element x is accessed, promote it past others that have probability up to px + .
y w z x v uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
v y z yProb py = 0.5 pw = 0.2 pz = 0.15 px = 0.1 pv = 0.03 pu = 0.02
y w z x v uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
x v y vProb py = 0.5 pw = 0.2 pz = 0.15 px = 0.1 pv = 0.03 pu = 0.02
y w z x v uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w)
x v y vProb py = 0.5 pw = 0.2 pz = 0.15 px = 0.1 pv = 0.03 pu = 0.02
y x w z v uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w) 4 4
x v y vProb py = 0.5 px = 0.1 pw = 0.2 pz = 0.15 pv = 0.03 pu = 0.02
y x w z v uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w) 4 4
x v y vProb py = 0.5 px = 0.1 pw = 0.2 pz = 0.15 pv = 0.03 pu = 0.02
y x w z v uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w) 4 4
Access v (and move to before x)
x v y vProb py = 0.5 px = 0.1 pw = 0.2 pz = 0.15 pv = 0.03 pu = 0.02
y v x w z uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w) 4 4
Access v (and move to before x) 5 9
x v y vProb py = 0.5 pv = 0.03 px = 0.1 pw = 0.2 pz = 0.15 pu = 0.02
y v x w z uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w) 4 4
Access v (and move to before x) 5 9
x v y vProb py = 0.5 pv = 0.03 px = 0.1 pw = 0.2 pz = 0.15 pu = 0.02
y v x w z uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w) 4 4
Access v (and move to before x) 5 9
Access y
x v y vProb py = 0.5 pv = 0.03 px = 0.1 pw = 0.2 pz = 0.15 pu = 0.02
y v x w z uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w) 4 4
Access v (and move to before x) 5 9
Access y 1 10
x v y vProb py = 0.5 pv = 0.03 px = 0.1 pw = 0.2 pz = 0.15 pu = 0.02
y v x w z uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w) 4 4
Access v (and move to before x) 5 9
Access y 1 10
x v y vProb py = 0.5 pv = 0.03 px = 0.1 pw = 0.2 pz = 0.15 pu = 0.02
y v x w z uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w) 4 4
Access v (and move to before x) 5 9
Access y 1 10
Access v
x v y vProb py = 0.5 pv = 0.03 px = 0.1 pw = 0.2 pz = 0.15 pu = 0.02
y v x w z uL:
MFBE Example (MFBE Example ( = 0.2) = 0.2)
Request Cost Total Cost
Access x (and move to before w) 4 4
Access v (and move to before x) 5 9
Access y 1 10
Access v 2 12
x v y vProb py = 0.5 pv = 0.03 px = 0.1 pw = 0.2 pz = 0.15 pu = 0.02
Difficulties in ProofsDifficulties in Proofs
• It’s not easy to understand the behavior of OPT.– OPT can be computed by Dynamic
programming • Trivial way = O((n!)2m)• Improvement = O((2n)(n!)m)
[Reingold, Westbrook, 1996]
Our ExperimentOur Experiment• Motivation: To see the behavior of
algorithms in our hybrid model.
• Measurement: We measure the performance of an online algorithm by the average competitive ratio.
Our ExperimentOur Experiment• Variables in our experiment
– Type of List Update Algorithm (MTF, STAT, MFBE)
– Type of Probability Distribution– Type of Adversary
– Epsilon:
Our ExperimentOur Experiment• We generate a request sequence of
length 100, with a chosen probability distribution.
• Then, with probability let the adversary change the request sequence.
Our ExperimentOur Experiment• Record the cost incurred by the online
algorithm = CostA()
• Use Dynamic Programming to find optimum cost of that request sequence = CostOPT().
• Competitive Ratio = CostA()/CostOPT()
• Repeat this 100 times to find the average competitive ratio.
DistributionDistribution• Geometric Distribution:
– P[i] / 1/2i
• Uniform Distribution:– P[i] = 1/n, n = length of the list
• Zipfian Distribution (Zipf(2)):– P[i] / 1/i2
Cruel AdversaryCruel Adversary
• This is an adaptive adversary
• Looks at the current list and request for the last item in the list.
y w z x v uL:
Cruel Adversary, Geometric Cruel Adversary, Geometric Distribution, n=6Distribution, n=6
Average Competitive Ratio
1
1.5
2
2.5
3
3.5
4
4.5
5
5.5
6
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Epsilon
Ave
rage
Com
petit
ive
Rat
io
STAT
MFBE
MTF
Cruel Adversary, Geometric Cruel Adversary, Geometric Distribution, n=6Distribution, n=6
Average Competitive Ratio
1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Epsilon
Ave
rage
Com
petit
ive
Rat
io
STAT
MFBE
MTF
Reversed Geometric Reversed Geometric AdversaryAdversary
• This adversary chooses elements randomly, according to the geometric distribution on the reversed STAT order.
• This adversary requests small probability items more frequently.
• Oblivious Adversary = doesn’t look at the current list
Reversed Geometric Adversary, Reversed Geometric Adversary, Geometric Distribution, n=6Geometric Distribution, n=6
Average Competitive Ratio
1
1.1
1.2
1.3
1.4
1.5
1.6
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Epsilon
Ave
rage
Com
petit
ive
Rat
io
STAT
MFBE
MTF
Uniform AdversaryUniform Adversary• This adversary requests elements
from the list uniformly at random.
• Oblivious Adversary
• With this adversary, the sorted order of elements in the combined probability distribution doesn’t change.
Uniform Adversary, Zipfian2 Uniform Adversary, Zipfian2 Distribution, n=6Distribution, n=6
Average Competitive Ratio
1
1.05
1.1
1.15
1.2
1.25
1.3
1.35
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Epsilon
Ave
rage
Com
petit
ive
Rat
io
STAT
MFBE
MTF
ObservationObservation
• The performance of any algorithm in this hybrid model depends heavily on the type of adversary.
• Yet MFBE seems better than the worse of STAT and MTF.
ConjectureConjecture
• The average competitive ratio of MFBE is dominated by the maximum of the average competitive ratios of STAT and MTF.
ConjectureConjecture• Request sequence is generated by p• Adversarial settings:
• = k/m• 8 adversarial settings,
Ep(Cost(MFB)) · max Ep (Cost(MTF))
Ep (Cost(STAT))
)(),1(),....,5(),4(),3(),2(),1(: mm )(),....,3(),2(),1( k
{
Questions?Questions?
Thank youThank you !!! !!!