Finite-State Online Algorithms
and Their Automated
Competitive Analysis
Takashi Horiyama
Kazuo Iwama
Jun Kawahara
Graduate School of Informatics, Kyoto University, Japan
1
What is the Automated Analysis?
Analysis of algorithms
from the theoretical point of view, we need comprehensive
performance analysis
ordinary approach
reduce # of cases by professional sense
and techniques
our approach
Automated Analysis by a computer.
We construct a general framework for automated analysis.
Apply to …
Online Knapsack Problem
this method
the competitive ratio
1.301 tight
upper bound 1.334
(explained later)
2
Online Knapsack Problem (OKP)
•
•
•
•
•
The player has a bin (size: 1.0)
Input items: u1, u2,… (0 < ui <= 1.0)
The player does not know next item.
Action: puts it into the bin or discards it
Goal: to maximize the content of the bin
Ex.) 0.6, 0.7, 0.4 are given in this order.
0.4
0.7
0.6
Online
0.7
0.6
0.4
0.6
If he knows his future inputs…
3
Evaluation Measure
• The online algorithm is evaluated by the Competitive
Ratio (CR).
the benefit of Offline
CR = worst case of
the benefit of Online
Ex) 0.6, 0.7, 0.4 are given in this order.
0.4
0.7
Online
this benefit is 0.7
0.6
CR
1
If Offline choose… 0.7 =1.42
this benefit is 1
4
Relaxation of the Condition
• The optimal CR of the 1-bin Online Knapsack Problem
(OKP) is 1.618 [Iwama, Taketomi, 2002]
relaxation of the condition
• We introduce a buffer bin
which allows exchanging items between the two bins.
Revocable Online Knapsack Problem (ROKP)
0.2
benefit = main bin
0.4
0.3
0.5
0.3
0.4
0.2
0.5
0.4
0.3
main bin
buffer bin
5
Our Main Results
OKP
CR
upper bound 1.618
lower bound 1.618
ROKP
old
CR
new result
upper 1.334
upper 1.301
lower 1.281
lower 1.301
13 case analysis by hand
automated analysis
[ Iwama, Masanishi 2003 ]
6
Brief History of Our Project
old (by hand)
upper 1.334
automated analysis
1.334
By improving
the base algorithm
CR
1.301
lower 1.281
1.281
important hint
[ Iwama, Masanishi 2003 ]
7
Automated Proof by a Computer
• This is the theoretical and mathematical proof.
cf) a numerical simulation
0.0398 0.0319 0.9912 0.5764 0.7843 0.7490 0.5983 0.0432 0.2763
0.8468 0.9678 0.3982 0.6355 0.6631 0.6097 0.9667 0.3445 0.6335
…
0.6219 0.9784 0.9735 0.5505 0.1740 0.6999 0.8499 0.6960 0.6565
generate random values as item sizes, and calculate the CR
• two major difficulties
– Each input item takes a real value between 0 and 1.
– The number of states must be finite (# of items in the bin also).
8
Past Results Using a Computer
• The four color problem [Appel and Haken, 1977]
• Kepler conjecture [Hales 1997]
• A 7/8-approximation algorithm for MAX 3SAT
[Zwick, 2002]
A computer is used to enumerate the finite pattern in above problems.
our method
We deal with infinite items directly.
(representing finite states)
9
Proof of the lower bound (1.301)
Theorem 1
Let X be any online algorithm for ROKP.
Then CR(X) > 1/t – ε = 1.301.
(t: a real root of 4x3 + 5x2 – x – 4 = 0)
Proof:
The adversary inputs 0.608, 0.409, 0.769.
The player X discards…
(Case 1) 0.680 item.
(Case 2) 0.409 item.
(Case 3) 0.769 item.
0.680
0.409
0.769
10
Proof of the lower bound (1.301)
input 0.320
CR=
1.301
(Case 1) discards 0.680.
The Adversary inputs 0.320 (and stops).
0.680 + 0.320
input
0.680, 0.409,
0.769
CR =
= 1.301
0.769
adversary
(Offline)
player X
(Online)
0.680
0.409
0.769
0.320
0.680
0.409
0.769
0.320
0.680
0.320
0.769
11
Proof of the lower bound (1.301)
input 0.320
CR=
1.301
input
0.680, 0.409,
0.769
input 0.591
CR=
1.301
(Case 1) discards 0.680.
The Adversary inputs 0.320.
0.680 + 0.320
CR =
= 1.301
0.769
(Case 2) discards 0.409.
The Adversary inputs 0.591.
input
0.592
0.409 + 0.591
CR =
= 1.301
0.769
(Case 3) discards 0.769.
The next input is 0.592.
12
Adversary’s Strategy
for the lower bound (1.301)
input 0.320
input 0.320
input
0.680, 0.409,
0.769
CR=
1.301
input 0.320
input 0.591
CR=
1.301
CR=
1.301
input
0.592
input 0.591
CR=
1.301
CR=
1.401
input 0.680
CR=
1.471
CR=
1.301
input
CR=
1.304
0.320,
0.359
13
Outline of the Proof
ROKP
now proving
upper 1.301
CR
lower 1.301
already proved
Design an online algorithm A.
Theorem2 The online algorithm A achieves the CR 1.301.
The process of the proof
1. Enumerate all states
2. Prove CR < 1.301 for each state
prove by using a computer
14
Designing Online Algorithm A
the classification on the sizes of the items
XS
0
SS
1-t
0.23
MM
MS
ML
1-t2 2-2t
LL
t2
0.41 0.46 2t-1 0.59
0.54
When the item u is given...
・ If room exists for the current item, hold u.
・ If the main bin has benefit >= t,
then discard all the other items.
・ Otherwise discard some item(s).
XL
t
1
0.77 t =1 / 1.301
= 0.77
ALG decides discarding
item(s) into bins.
15
How to Discard items
• If there are two or more items in the same class,
the player discards one of them.
ex) LL, LL, MM --> discard LL
• If there are two items in SS and an item in LL,
SS + SS < LL --> discard LL.
SS + SS >= LL for all combinations --> discard SS.
• Otherwise (exception),
– MS, ML, LL --> discard ML.
– MM, ML, LL --> discard ML.
16
Proof of the upper bound
1. Enumerate all states (making state diagram).
2. Prove CR < 1.301 for each state.
State0
CR <1.301
…
State1
State2
SS
CR <1.301
SS
MS
…
State3
LL
CR <1.301
CR <1.301
State4
SS
SS
…
CR <1.301
17
1. Enumerate all states.
empty
SS
ML
MS
SS
SS, SS
MS
SS, MS
MM
ML
MM
ML
SS, MM
LL
MM
MS
SS
LL
LL
END
STATE
SS, LL
?
t ≦ SS + ML ≦ 1
18
Can SS and LL be held in the same bin?
• case by case.
LL
SS
0.6
0.3
can hold the two
SS + LL <= 1
SS : 0.23 ~ 0.41
LL : 0.59 ~ 0.77
LL
0.7
SS
0.4
cannot
SS + LL > 1
other case division
SS + MS < t
SS + MS >= t
19
Can SS and LL be held in the same bin?
necessary to memorize
as ‘condition’
Statej
Statei
SS1
LL1
SS1
END_STATE
SS1 + LL1 ≦ 1
Statek
SS1
LL1
SS1 + LL1 > 1
20
If items are discarded,…
empty
LL
LL
SS
…
…
SS, LL
…
LL
…
necessary to memorize as ‘history’
ALG selects discarding
item(s) among
SS, LL, LL.
SS, LL LL
H
21
Why states are finite?
• state: current items, history, and condition
• “Current items” are finite clearly (XS can be ignored).
• “History” is finite. Because we need not memorize more number.
For example, the player can put at most two items in MS into one bin.
We memorize “MS+H2” which means “MS × two or more”.
XS
0
SS
1-t
0.23
MM
MS
ML
1-t2 2-2t
LL
t2
0.41 0.46 2t-1 0.59
0.54
XL
t
1
0.77 t =1 / 1.301
= 0.77
22
Why states are finite?
•
•
•
•
state: current items, history, and condition
“Current items” are finite clearly.
“History” is finite. Because we need not to memorize more number.
“Condition” is also finite. Because the form of the inequality is
given below.
○+○≦ 1
○+○< t
○+○> 1
○+○≧ t
XS
0
SS
1-t
0.23
○≦○
MM
MS
ML
1-t2 2-2t
LL
t2
0.41 0.46 2t-1 0.59
0.54
XL
t
1
0.77 t =1 / 1.301
= 0.77
23
Generated the State Diagram
• generated by the Java Program
• our state diagram has 276 states.
24
Outline of the Proof
ROKP
now proving
upper 1.301
CR
lower 1.301
already proved
Design online algorithm A.
Theorem2 The online algorithm A achieves the CR 1.301.
The process of the proof
1. Enumerate all states
2. Prove CR < 1.301 for each state
prove by using a computer
25
the proof of CR<1.301 (1)
for checking CR < α
(α = 1.301)
set up to inequalities
the best possible sum of
the items in the history
CR =
the benefit of Offline
the benefit of Online
the best possible sum of
the items in the bin
26
the proof of CR<1.301 (2)
∀ the combination G in the history,
∃ the combination A in the bin, and
The summation of items in G
<α
The summation of items in A
is satisfied.
converse of the
∀ the combination G in the history,
∀ the combination A in the bin, and
(sum of items in G) ≧ α× (sum of items in A)
is satisfied.
is never
satisfied
27
the proof of CR<1.301 (3)
Ex) state: current SS1, SS2, LL1, history SSH1,
condition SS1 + LL1 > 1, SSH1 + LL1 > 1,…
We suppose G = {SS2,SSH1} as the comb. in history.
possible comb. of Online
is
We prove
this for all comb. in history.
{SS1},{SS2},{SS1,SS2},{LL1} .
SS2
SS2
SS2
SS2
+
+
+
+
SSH1
SSH1
SSH1
SSH1
≧
≧
≧
≧
α
α
α
α
×
×
×
×
(SS1)
(SS2)
(SS1 + SS2)
(LL1)
inequalities of the condition
SS1 + LL1 > 1
SSH1 + LL1 > 1
…
further, the range of class
1-t < SS1 ≦ 1-t2
1-t < SS2 ≦ 1-t2
1-t < SSH1 ≦ 1-t2
t2 < LL1 ≦ t
Our purpose is to prove these
inequalities are never satisfied.
28
t = -5/12 + 1/12(649 - 6Sqrt[10293])^(1/3) + 1/12(649 + 6Sqrt[10293])^(1/3)
α=1/t
Developer`InequalityInstance[
{a (SS1) <= SS2 + Ll1 ,a (SS2) <= SS2 + Ll1 ,a (SS1 + SS2) <= SS2 +
Ll1 ,a (Ll1) <= SS2 + Ll1 ,
SS1 + SS2<t , SS1 + SS3<t , SS2 + SS3<t , SS1 + SS2 + SS3>1 , SS1 +
Ll1>1 , SS1 + Ll2>1 , SS2 + Ll1>1 , SS2 + Ll2>1 , SS3 + Ll1>1 , SS3 +
Ll2>1 , Ll1<t , Ll2<t , SS1 + SS2 < Ll1 , SS1 + SS2> Ll2 ,
…continue
-t + 1 < SS1 <= -t^2 + 1 ,
-t + 1 < SS2 <= -t^2 + 1 ,
-t + 1 < SS3 <= -t^2 + 1 ,
t^2 < Ll1 <= t, t^2 < Ll2 <= t
},
{SS1 , SS2 , SS3 , Ll1 , Ll2}
]
We check the existence of the
solutions of the inequalities by
Mathematica.
There are 1715 cases.
29
Results and Conclusion
• Generate state diagram: at less than 10 seconds by
Athlon XP 2600.
• Our state diagram has 276 states.
• checking CR < 1.301: 1715 sets of inequalities.
solved by Mathematica at 30 minutes.
• We prove CR < 1.301 for all states.
• Are there any application which can use this method?
30
© Copyright 2026 Paperzz