Computational problems Π are relations Π ⊆ X × Y between a set X of valid inputs, and a set Y of valid outputs.
(x, y) ∈ Π means: y is a solution of x w.r.t. Π.
Algorithms A are instructions for a device to execute a well defined sequence of computational steps in dependence of the stored input data x (one elementary operation per step)
This sequence is called computation of A on x and can be finite or infinite.
time consumption timeA(x) = the sum of the time costs of the computational steps of the computation
The execution of one elementary operation costs one time unit => make time platform independent
space consumption spaceA(x) = the number of storage units used during
the computation of A on
Worst Case Running Time
Best Case RT
Average Case RT
Design -> Proof of Correctness -> Analysis of the Running Time
neglect multiplicative constants and additive low order terms
A problem Π is considered to be efficiently solvable, if there is a polynomial time
algorithm A for Π.
Exponential time is not efficient in practice.
PTIME denotes the set of all problems, which have a polynomial time algorithm in some reasonable model of computation (i.e., in all reasonable models of computation)
Shortest Paths: A path p from a node u to a node v is called shortest path from u
to v if for all paths p0 from u to v it holds w(p0 ) ≥ w§.
Distance δG(u, v) from node u to node v
Initialize(G, s):
For all v ∈ V
do v.d ← ∞ // set a path from s to v is infinite
v.π ← NIL
s.d ← 0 // set the distance of s to s is 0
Running time O(|V|).
Relax(u, v, w):
If v.d > u.d + w(u, v)
// Relax edge (u, v)
then v.d ← u.d + w(u, v)
v.π ← u // set new previous sector( s->u->v)
Running time O(1)
Vπ = {v ∈ V, v.d < ∞}
Eπ = {(v.π, v), v.π /=(not equals to) NIL}
Suppose that no negative cycle is reachable from s.
Then Gπ is always a tree with root s, and
For each v ∈ Vπ it holds that v.d = δGπ (s, v) ≥ δG(s, v).
I.e., v.d denotes the length of the path from s to v in the tree Gπ.
(Proof: Gπ is a disjoint union of one tree with root s and some cycles -> Gπ is acyclic
Any cycle K = (v1, · · · , vk, v1) in Gπ which is reachable from s in G has negative weight)
BellmanFord(G, w, s):
Initialize(G, s)
For i ← 1 to |V| − 1
do for all (u, v) ∈ E
do Relax(u, v, w)
For all (u, v) ∈ E
do if v.d > u.d + w(u, v)
then return false, STOP
return true
Running time O(|V||E|)
BellmanFord(G, w, s) outputs true if and only if no negative cycle is reachable from s. In this case, the output Gπ is a shortest path tree with root s which contains all nodes v which are reachable from s.
(Proof: induction over i that for all i, 1 ≤ i ≤ k, it holds (vi).d = δG(s, vi) after round i.
Case i = 1, …
Case i > 1,…)
Suppose there is a function f : V −→ R ∪ {∞} fulfilling f(v) ≤ f(u) + w(u, v) for all edges (u, v) ∈ E, where f(v) /= ∞ for all nodes v reachable from s. Then all cycles K = (v1, · · · , vk , v1) which are reachable from s have non negative weight.
(Proof)
linear function: f(λ · x) = λ · f(x) and f(x + y) = f(x) + f(y).
linear halfspace/ linear restriction
hyperplane
linear polyhedron: A subset Π of IR^n, formed by the intersection of a finite number of linear halfspaces,
Linear Program (or a Linear Programming Instance, for short, LP-instance):
I = (n, c, Π) is defined by
To solve the LP-instance I = (n, c, Π) = determine some optimum x_opt ∈ Π
such that c(x_opt) = min{c(x); x ∈ Π}.
An Integer Linear Program is defined by an LP-Instance I = (n, c, Π) and the additional
restriction that solutions have to have integral components.
For x, y ∈ IR^n, let Line(x, y) = {x + λ(y − x), λ ∈ [0, 1]} be the line connecting x and y
A subset X ⊆ IR^n is called convex, if for all x, y ∈ X it holds that Line(x, y) ⊆ X.
when x ∈ X a point in X
Euclidean distance
Each linear polyhedron Π is convex
global minimum & global maximum
local minimum & local maximum
Let X ⊆ IR^n be a convex set and let c be a linear target function.
(1) Each local optimum of c on X is a global optimum of c on X.
(2) If X has a global optimum w.r.t c then it is also taken in an extremal point of X.
(Proof 1&2)
linear restrictions
A subset of restrictions {Ri, i ∈ S}, S ⊆ {1, · · ·, m}, is called to be linearly independent, if the set of the corresponding rows {(ai,1, · · ·, ai,n); i ∈ S} of A is linearly independent,
i.e., they form an |S| × n-submatrix of A with rank |S|.
A point x ∈ Π is an extremal point of the linear polyhedron if and only if x satisfies a subset S of |S| = n linearly independent restrictions with equality
An LP-instance in normal form I = (n, m, c, z, A, b) has the form
max{c(x) − z; A ◦ x ≤ b, x ≥ 0 }
The underlying linear polyhedron is X(I) = {x; A ◦ x ≤ b, x ≥ 0 }.
以下为个人理解,不对的麻烦大佬们指教!
slacking extensions中各项代表什么?
前n项是点坐标,后m项是将点分别带入m个约束方程再转化得到的项
为什么slacking extensions中各项不能为负值?
首先前n项d(d1, …, dn)应该满足xi ≥ 0的约束条件,其次后m项是由约束方程转化而来,为保证A ◦ x ≤ b即b - A ◦ x ≥ 0。因此slacking extensions中所有项必须都大于等于0。
为什么在slacking extensions中有n个项为0时,d为极值点?
若一个点为极值点,则该点是n条约束方程的交点,即该点必须满足至少n个约束方程,当slacking extensions中某项为0时,即代表该点满足约束方程(前n项为0意味着点在坐标轴上,即满足xi=0,后n项为0意味着点在约束方程线上,即满足b - A ◦ x = 0)
Let d = (d1, · · · , dn+m) ∈ IR^(n+m) denote the slacking extension of a point (d1, · · · , dn). Point d is called a basic point, if there is a set N ⊂ {x1, · · · , xn+m} of n linearly independent variables such that dk = 0 for all xk ∈ N.
In this case, N is called the set of non-basic variables of the basic point d and
B = {x1, · · · , xn+m} \ N is called the set of basic variables of d.
A basic point d is called admissible basic point if dk ≥ 0 for all k, 1 ≤ k ≤ n + m
The basic point (0 vector, b) = (0, 0, · · · , 0, b1, · · · , bm) is called the canonical basic point. It is admissible iff b ≥ 0 vector.(原点位置)
The slacking variables xn+i measures the slacking distance of the restrictions Axi from the restriction bound bi.
The point d ∈ IR^n is a valid solution of I iff the slacking extension of d is a valid solution of SNF(I)
Let I = (n, m, c, A, b) an normal form instance. Fact: If b ≥ 0 vector then (0 vector, b) is an admissible basic point.
Directions starting from (vector 0, b)
The point (vector 0, b) is left by n lines D1, · · · , Dn, called directions.
For all q, 1 ≤ q ≤ n, direction Dq is defined by increasing component q.
Dq = {dq(λ), λ ≥ 0}
where dq(λ) = (0, · · · , 0, λ, 0 · · · , 0, b1 − λ · a1,q, · · · , bm − λ · am,q).
where λ stands at position q.
Suppose that (vector 0, b) is an admissible basic point.
(i) A direction Dj, 1 ≤ j ≤ n, is improving if and only if cj > 0.
(ii) If cj ≤ 0 for all j, 1 ≤ j ≤ n, then (vector 0, b) is optimal.(若最终的目标方程中没有正的系数,说明任意方向都无法再improving,此时为optimal状态)
(Proof)
Bounded and Unbounded Directions
Suppose that (vector 0, b) is an admissible basic point and fix some j, 1 ≤ j ≤ n.
(i) Direction Dj is bounded 等价于 there is some i, 1 ≤ i ≤ m, such that ai,j > 0.(根据bounded定义要使bi − λ · ai,j ≥ 0且0 ≤ λ ≤ λ0,ai,j 必须大于0,否则λ可以为任意值,不存在临界值λ0)
(ii) In this case dj(λ) ∈ X(I) 等价于 0 ≤ λ ≤ min{ bi/ai,j ; 1 ≤ i ≤ m, ai,j > 0}(该点在bounded内)
Dj is an improving unbounded direction等价于cj > 0, and, for all i, 1 ≤ i ≤ m, ai,j ≤ 0. In this case, opt(I) = limλ→∞ cj · λ = ∞
Suppose that (vector 0, b) is not optimal, and that all improving directions starting at (vector 0, b) are bounded. Then there is a Pivot position (p, q), and: The point y = dq( bp/ap,q ) is an admissible basic point with c(y) > c((vector 0, b)). (像improving方向q移动到临界值bp/ap,q,此时是一个admissible basic point,且带入目标方程后更大)
(Proof)
SimplexSearch(T) (* T admissible Simplex Tableaux *):
1 Repeat if T not optimal
2 then if T not unbounded
3 then choose Pivot Position (p, q)
4 T ← Pivotp,q(T)
5 until T optimal or unbounded
6 Output T
Degenerate Pivot steps: If T’= Pivotp,q(T) and tp,0 = 0 then x(T) = x(T’)
Degenerate Pivot can occur in admissible basic points with more than n zeros.
Making a degenerate Pivot step means staying in the same basic point but changing to another set of n non-basic variables
Worst Case Running Time: exponential in n and m
Average running time : polynomial
The Maximum Flow Problem refers to a system in which a material courses from
a source to a sink, where the source is the place where the material is produced and the sink is the place where the material is consumed.
a directed graph G=(V,E), and is defined as follows:
A flow network G = (V, E, c) is called restricted if it contains only one source s ∈ V and one sink t ∈ V, where indegG(s) = outdegG(t) = 0.
Moreover, G does not contain pairs (u, v), (v, u) of antiparallel edges
Let G = (V, E, c) be a general flow network with set of sources S* and set of sinks T*.
Then there is a restricted network G’ = (V’, E’, c’) with |V’| ≤ |V| + |E|/2 + 2, such that each flow on G corresponds to a flow on G’ with the same value, and vice versa
Claim: Each flow f on G corresponds to a flow f’ on G’ (and vice versa) with |f| = |f’|
Maximum flow instances G = (V, E, c) can be formulated as LP-instances
Ef consists of forward edges (u, v), for which (u, v) ∈ E and f(u, v) < c(u, v), and backward edges (v, u), for which (u, v) ∈ E and f(u, v) > 0
The capacity cf(u, v) of a forward edge (u, v) ∈ Ef indicates the maximal value by which the flow through (u, v) ∈ E on G can be increased.
The capacity cf(v, u) of a backward edge (v, u) ∈ Ef indicates the maximal value by which the flow through the corresponding edge (u, v) ∈ E can be decreased.
Each directed path p from s to t in Gf is called an augmenting path with respect to G and f. and we denote by cf(p)= min{cf(e), e ∈ p} the minimal capacity of p.
The mapping g = g(f, fp) defines a flow on G and it holds |g| = |f| + cf(p)
Let f be a flow on G and (S, T) be a cut. Then |f| = f(S,T)
For all flows f on G = (V, E, c) and cuts (S, T) of V it holds |f| ≤ c(S, T)
Let G = (V, E, c) be a flow network and f a flow on G. Conditions (1) to (3) are equivalent
(1) The flow f is maximal.
(2) There is no path from s to t in Gf .
(3) There is a cut (S, T) such that |f| = c(S, T).
Input: A Flow Network G = (V, E, s, t, c)
Output: A maximal flow f : E → IR .
Let f be the constant-0 flow on G
Repeat
Fix a path p from s to t in Gf
f ← g(f, fp)
until t is not reachable from s in Gf
Output f
If in each iteration a shortest augmenting path is chosen, then Ford-Fulkerson terminates after O(|V|·|E|) iterations. This corresponds to the Edmonds-Karp Algorithm
Given a flow f on G = (V, E, c) and nodes u, v ∈ V, we denote by δf(u, v) the distance of v from u in Gf, i.e. the length (=number of edges) of a shortest path from u to v in Gf .
Now suppose f is a flow on G = (V, E, c) and flow f’ is obtained from f by one iteration of Ford-Fulkerson, where the corresponding augmenting path is a shortest path from s to t.
For all v ∈ V it holds that δf(s, v) ≤ δf’(s, v).
Given a flow f on G = (V, E, c) and an augmenting path p in Gf. An edge e = (u, v) from p is called critical, if it has minimal capacity in p, i.e., cf(e) = cf§
During the execution of the Edmonds-Karp Algorithm on a flow network G = (V, E, c), each edge e ∈ E can become critical at most |V|/2 times
The Karp-Edmonds Algorithm stops after at most |E| ·(|V|/2) iterations. Thus the running time is O(|V|·|E|/2)
Input: An undirected graph G = (U, E).
Output: A maximal matching in G, i.e., a matching M ⊆ E in G with maximal number of edges.
A node v ∈ V is called M-exposed if no edge of M contains v.
A simple path p in G is called M-augmenting, if its endpoints are M-exposed and, if p has more than one edge, it contains alternatingly edges which are not in M and edges which are in M.
A matching M ⊆ E is maximal if and only if there is no M-augmenting path
An undirected graph G = (U, E) is called bipartite, if there is a partition U = V ∪ W of the node set into two disjoint subsets such that for all edges e = {v, w} ∈ E it holds that v ∈ V and w ∈ W.
Step1: Transform the bipartite input graph G = (V, W, E) into a flow network G’ = (V’, E’, c)
Step2: Compute a maximum flow on G’ with Ford-Fulkerson
A maximal matching in a bipartite graph G = (V, W, E) can be computed in
time O(min{|V|, |W|} · |E|) by applying the Ford-Fulkerson Method.
Note that augmenting paths p in Gf’
the subpath of p from v to w form a Mf-augmenting path p’ in G
The improved flow on G’ corresponding to f and fp corresponds to the matching in G improved via p’
Efficiently solvable (feasible) Problems:
Unfeasible Problem
The theory of NP-Completeness allows to identify such a complexity class.
A Hamilton Circuit is a simple circuit in G with |V| edges that visits all nodes v ∈ V.
Observation: Consider the Euler Circuit Problem
We say that a given decision problem Π has Efficiently Verifiable Proofs if there is a proof scheme (ProofΠ, VΠ) for Π, which is defined as follows
Efficiently Verifiable Proofs (ProofΠ, VΠ) for a decision problem Π do not
yield an efficient algorithms for Π
Observations:
SAT is NP-complete
(proof - Cook’s Theorem)
Let L ∈ NP be arbitrarily fixed. We construct for each input x ∈ {0, 1}*a CNF-formula C^x of polynomial size such that x ∈ L ==C^x ∈ SAT
Turing Machines
Extended Hypothesis of Church: each
polynomial time algorithm can be executed on a polynomial time bounded One-tape
Turing machine (for short 1-TM)
We want to show that a given NP-Problem L is NP-complete.
For that it is sufficient to find an appropriate NP-complete problem L’ (for example, SAT ), and to construct a polynomial reduction g from L’ to L
3SAT => DHC => HC => TSP
Assume P/=NP: If a decision problem L is NP-complete then L /∈ P
A corresponding concept for general computational problems Π:
Π is called NP-hard if Π ∈ PTIME implies P = NP
We showed NP-completeness by constructing polynomial reductions, a concept applicable only to decision problems. We define Turing-reducibility (Π ≤T Π’), a reducibility concept applicable to general problems Π, Π’
Informally, a Turing reduction from Π to Π’ is a polynomial time algorithm for Π, which has access to a subroutine for Π‘, which on arbitrary inputs x returns immediately a solution y with (x, y) ∈ Π‘
A Π‘-Oracle is a computational device with possibly supernatural computational power. It solves the computational problem Π‘ with maximal efficiency, i.e. for all inputs x the Π’-Oracle returns a solution y with (x, y) ∈ Π‘ in time |x| + |y|
A Π’-Oracle Algorithm for a given computational problem Π‘ is an algorithm which solves Π and has access to an Π’-oracle.
We define Π to be Turing-reducible to Π‘ (Π ≤T Π’), if there is a polynomial time Π‘-oracle algorithm for Π.
The concept of oracle algorithms corresponds to the well-known concept in programming that a given computer program calls a subprogram.
The concept of Turing-Reducibility allows to determine the complexity of a given problem Π relative to another problem Π‘ in the sense of If Π is hard then also Π’ is hard or If Π‘ is easy then also Π is easy.
Polynomial Reductions are special cases of Turing reductions, i.e., from L ≤pol L‘ it
follows that L ≤T L’
For all optimization problems Π, the decisional variant LΠ is Turing reducible to Π
Self Reducibility means that the reverse case is also true, i.e., the optimization variant is Turing-reducible to the (easier looking) decisional variant.
Example: The optimization problem MaxClique (of computing a clique of maximal size in a given input graph G = (V, E)) is Turing-reducible to its decision variant Clique (of deciding if G contains a clique of size at least k).
A computational problem Π is called
Let Π NP-hard. Then Π ∈ PTIME -> P = NP.
Let Π NP-easy. Then P = NP -> Π ∈ PTIME.
All NP problems are NP-easy, all NPC-problems are NP-equivalent
Optimization problems, for which the decisional variant is NP-complete, are NP-hard
Optimization problems, which can be Turing-reduced to its decisional variant are NP-easy (MaxClique, MinTSP, MaxKP,… )
There is an algorithm for the NP-hard problem MaxKP which needs time O(n·cmax (I)) for each integral input instance I = (n, w1,…, wn, c1, …, cn, W), where cmax (I) = max{ci, i = 1, …, n}
A problem is called number problem if the components of input instances I are natural numbers.
If I is an input instance of a number problem then let Max(I) denote the maximal component of I
Let Π denote a number problem. An algorithm A for Π is called pseudopolynomial if the running time is polynomially bounded in |I| and Max(I).
The NP-hard MaxKP has a pseudopolynomial algorithm
TSP is strong NP-hard
Many NP-complete optimization problems have polynomial time approximation algorithms which reach a good approximation ratio. In particular,
Determining the minimal ratio for which a given NP-hard optimization problem can be approximated in polynomial time is one of the main research topics in modern algorithmics
(SAT-ASSIGMENT ≤T SAT)
The list below contains some well-known problems that are NP-complete when expressed as decision problems.