day6_-_upt-cours-complexity
day6_-_upt-cours-complexity
Introduction to computational
complexity theory
Complexity (computability) theory deals with two aspects:
Algorithm’s complexity.
Problem’s complexity.
References
S. Cook, « The complexity of Theorem Proving Procedures »,
1971.
Garey and Johnson, « Computers and Intractability, A guide to
the theory of NP-completeness », 1979.
J. Carlier et Ph. Chrétienne « Problèmes d’ordonnancements :
algorithmes et complexité », 1988.
Basic Notions
• Some problem is a “question” characterized by parameters
and needs an answer.
– Parameters description;
– Properties that a solutions must satisfy;
– An instance is obtained when the parameters are fixed to some
values.
Definition:
Let be n>0 andT(n) the running time of an algorithm expressed in terms
of the size data n, T(n) is of O(f(n)) iff n0 and some constant c such
that:
n n0, we have T(n) c f(n).
If f(n) is a polynomial then the algorithm is of polynomial complexity.
n2 0.0001 sec 0.0004 sec 0.0009 sec 0.0016 sec 0.0025 sec
n3 0.001 sec 0.008 sec 0.027 sec 0.064 sec 0.125 sec
n N1 100 N1 1000 N1
n2 N2 10 N2 31.6 N2
n3 N3 4.64 N3 10N3
2n N4 N4 +6.64 N4 + 9.97
3n N5 N5 + 4.19 N5 + 6.29
X = Vertices (= Cities)
E = Edges (pair of cities)
v = Distances between cities
• Exact methods
– Dynamic programming
– Tree methods
• Heuristic methods
Pseudo-polynomial algorithms (I)
• Dynamic programming
1) Determine the optimal investment policy for the three regions using a "dynamic
programming" method. The idea is to associate a graph with levels to the data. Level 0
contains only the vertex (0,0), (because no money has been invested yet). Level 1 contains
the vertices (1,0) (1,1) (1,2) (1,3) (1,4), which correspond to the cumulated amounts
invested in region 1. Level i contains the vertices (i, 0), (i, 1), (i, 2), (i, 3), (i, 4), (i, 5), (i, 6),
which correspond to the sums invested in the regions 1 .. i (i = 2, 3). The arcs are placed
between the levels i and i +1, valuated by the sums invested in the region i +1. The last
vertex is (3,6). The goal is to seek a maximum value path in this graph.
2) The general case. More generally, we have B million to invest in n regions. We shall set
fi(y), the optimal profit for a cumulative investment of a sum y in the regions 1, 2, .., i. We
have f0(0) = 0. Determine a recurrence formula connecting fi to fi-1 for i from 1 to n.
3) What is the complexity of the dynamic programming method in function of n and B, and
complexity of enumerating all possible solutions.
Tree methods
Tree methods: a family of algorithms that implicitly list all the solutions to a
problem.
Gauss's ladies' tree
1 2 3 4 l'autre partie de
5 6 7 8 l'arbore scence e st
obtenue par symétrie
9 10 11 12
13 14 15 16
S1
implication
implication
26
Tree methods
Tree methods use separation and evaluation algorithms built on the following elements:
- Separation consists of breaking down (recursively) the universe of solutions into
several generally disjointed subsets whose union covers all possible solutions.
- evaluation consists of associating a B-marker with the problem studied that is
calculated for each branch explored. A lower terminal (respectively an upper terminal)
is referred to in the case of a minimisation (in the case of maximization, respectively).
This terminal allows us to estimate the performance of the sector evaluated at best.
- exploration consists of determining the order of visit of the different branches by
choosing to explore the most promising branches. During the exploration we can
distinguish the following cases: a summit not to be explored, a summit to separate, a
terminal summit.
Tree method – an exercice
Five people, with different nationalities, live in the first five houses of a street, all on the same side
of the street (numbered from 1 to 5).
These people have each a different job as well as a favourite drink and animal (each different for
each person).The five houses are each of a different colour.