3 - Computational Complexity
3 - Computational Complexity
Heuristic Algorithms
Giovanni Righini
University of Milan
Department of Computer Science (Crema)
Definitions: problems and instances
A problem is a general question expressed in mathematical terms.
Usually the same question can be expressed on many examples:
they are instances of the problem.
For instance:
• Problem: “Is n prime?”
• Instance: “Is 7 prime?”
A:I→S
T (n) ∈ Θ (f (n))
means that
n n
0
T (n) ∈ O (f (n))
means that
n0
n n
0
T (n) ∈ Ω (f (n))
means that
di c c f(n)
enumeration algorithm
• considers each subset S ⊆ E,
• evaluates whether it is feasible (x ∈ X ) in α (n) time,
• evaluates the objective function f (x ) in β (n) time,
• records the best value found.
Assuming 1 operation/µsec
n n2 op. 2n op.
1 1µ sec 2µ sec
10 0.1 msec 1 msec
20 0.4 msec 1 sec
30 0.9 msec 17.9 min
40 1.6 msec 12.7 days
50 2.5 msec 35.7 years
60 3.6 msec 366 centuries
Problem transformations and reductions
f ∗ = min f = ?
x∈X
∃x ∈ X : f (x ) ≤ k ?
T (n) = E [T (I) |I ∈ In ]
Pr [(i, j) ∈ E] = p (i ∈ V , j ∈ V \ {i})
Graphs with the same given number of edges m have the same
n(n−1)/2−m
probability pm : (1 − p) (different for each m) If p = 0.5
it coincides with the model where all graphs have the same
probability.
2. Erdős-Rényi model: G (n, m): given the number o edges m, m
unordered vertex pairs are randomly selected with uniform
probability distribution and an edge is generated for each of
them.
2m
The two models tend to be similar for p = .
n (n − 1)
Phase transitions
In some cases the changes occur suddenly, for some critical values of
the parameters, reminding the phase transitions in physical systems.
Two things we can do
The design and analysis of heuristic algorithms proceeds in two
directions:
• proving theoretical properties on the algorithms, such as:
• worst-case time complexity (usually polynomial);
• average-case time complexity or parameterized time complexity;
• approximation guarantees;
• evaluating the practical usefulness of the algorithms:
• computing time;
• approximation;
• robustness to instances and to parameters (phase transitions).