Lecture8_Approximation-Algorithms (1)
Lecture8_Approximation-Algorithms (1)
FACULTY OF ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
ZPP algorithms are also Las Vegas algorithms that do not make false statements, but that can
also stop without making a decision - with the output "?" ("No idea").
A simple example:
The language 𝐿 ⊆ Σ ∗ belongs to the class BPP if and only if there exists a polynomial,
1
randomized algorithm 𝐴 and an 𝜖, 0 < 𝜖 < 2, with
1
(1) for all 𝑤 ∉ 𝐿: Prob [𝐴(𝑤) = 0] ≥ 2 + 𝜖,
1
(2) for all 𝑤 ∈ 𝐿 : Prob [𝐴(𝑤) = 1] ≥ 2 + 𝜖,
(3) for all 𝑤 ∈ Σ ∗ : time 𝐴 (𝑤) = O( poly (|𝑤|)).
Approximation Algorithms
1) 𝐴𝑃 : Problem instances
𝑉 = {1,2,3, … , 𝑛}, 𝑛 ≥ 0
𝐸 ⊆ 𝑉 𝑥 𝑉 {𝑥, 𝑦} ∈ 𝐸, 𝑥 → 𝑦
3) 𝑚𝑃𝑎 : 𝑆𝑃 (𝑎) → ℕ0
Example: 𝑃: The graph coloring problem with the constraint that no adjacent nodes have the
same color. Determine the minimum number of colors!
1) 𝐴𝑃 is the set of all undirected graphs 𝐺 = (𝑉, 𝐸) as well 𝑙(𝐺) = |𝑉|.
2) 𝑆𝑃 (𝐺) is the set of all valid coloring solutions 𝑓 of 𝐺.
3) 𝑚𝑃𝐺 (𝑓) is the number of colors that 𝑓 assigns to the nodes.
4) It is a minimization problem.
Quality criteria:
Let 𝐴(𝑎) be the value of the solution that Algorithm 𝐴 delivers for problem instance a.
Furthermore, let 𝑂𝑃𝑇(𝑎) be the value of the optimal solution 𝑠 ∈ 𝑆𝑃 (𝑎).
|𝑂𝑃𝑇(𝑎)−𝐴(𝑎)|
≤ 𝜀, 𝜀 ≥ 0
𝑂𝑃𝑇(𝑎)
(1) Fully approximable, i.e. there is a polynomial ε-approximation for 𝑃 for all ε > 0
(2) Partially approximable, i.e. polynomial ε-approximation is only possible for particular
𝜀-values
(3) Not approximable, i.e. no polynomial ε-approximation is possible => ∄ε
𝑈 ⊆ 𝑉, 𝐸𝑈 ⊆ 𝐸
V1 V2
V1
V2
Example of a complete bipartite graph with 𝑛 = 5 and 𝑚 = 3
Graph Coloring
𝐺 = (𝑉, 𝐸) is k-colorable iff there is a mapping 𝑐: 𝑉 → {1, … , 𝑘} with (𝑖, 𝑗) ∈ 𝐸 and 𝑐(𝑖) ≠
𝑐(𝑗)
(𝐺) = 𝑚𝑖𝑛{𝑘 | 𝐺 𝑖𝑠 𝑘 − 𝑐𝑜𝑙𝑜𝑢𝑟𝑎𝑏𝑙𝑒}
(𝐺) is the chromatic number of 𝐺
𝑛
≤ (𝐺) ≤ 𝑛 − 𝛼(𝐺) + 1
𝛼(𝐺)
2𝑛
≤ (𝐾𝑛,𝑛 ) ≤ 2𝑛 − 𝛼(𝐾𝑛,𝑛 ) + 1
𝛼(𝐾𝑛,𝑛 )
2𝑛
≤ 2 ≤ 2𝑛 − 𝑛 + 1
𝑛
2≤2≤𝑛+1
𝐾𝑛∗
𝛼(𝐾𝑛∗ ) = 𝑛
(𝐾𝑛∗ ) = 𝑛
2𝑛
≤ n ≤ 2𝑛 − 𝑛 + 1
𝑛
2≤𝑛 ≤𝑛+1
Assuming the reverse of the theorem, i.e. 𝐏 ≠ 𝐍𝐏, it follows that there can be no
polynomial algorithm for approximating (𝐺).
Instead of approximation algorithms, we must use heuristics and analyze them in terms of
their goodness.
➔ 2 well-known classical heuristic algorithms: Greedy and Johnson Coloring Algorithms
algorithm greedyC o l o r i n g ;
input G = (V, E) : Graph; //V = {1, 2, . . . , n}
output f : [1 . . . max] of int;
color : int;
var counter, color, i, j : int;
f := 0; color := 0; counter := 0;
E D
F G
A
I
H
repeat
U := W ;
color := color + 1;
while U ≠ ∅ do
Determine node u in GIS with minimal grade;
f [u] := color;
U := U − {u} − NU (u); // NU (u): Neighbors of u
W := W − {u};
endwhile
until W = ∅;
return f ;
return color;
endalgorithm johnsonC o l o r i n g .
B C
E D
F G
A
I
H