De nitions Basic techniques Relax and rounddiaz/slides8-19.pdf · Basic techniques Relax and round...
Transcript of De nitions Basic techniques Relax and rounddiaz/slides8-19.pdf · Basic techniques Relax and round...
DefinitionsBasic techniquesRelax and round
Approximation Algorithms
AlCo-GMat
Fall 2019
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
1 Definitions
2 Basic techniques
3 Relax and round
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
References:Approximation
(S. = Springer)
Garey, Johnson. Computers and intractability a Theory of theNP-completessa, Freeman, 1979
Ausiello, et al. Complexity and Approximation S. 1999
Vazirani. Approximation Algorithms, S. 2001.
Willliamsom, Shmoys, The Design of ApproximationAlgorithms. Cambridge University Press, 2011.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Problems
Example:
Given a graph and two vertices, is there a path joining them?decison problem
Given a graph and two vertices, obtain a path joining themwith minimum length.optimization problem
Given a set of vertices and two of them, obtain a path joiningthem with minimum length
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Decision Problems: Complexity classes
P polynomial timethere is a polynomial time algorithm providing the correctanswer. for any input.
EXP exponential time optimizationthere is an exponential time algorithm providing the correctanswer. for any input.
NP non-deterministic polynomial timeSyntactic definition!
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Optimization Problems
An optimization problem is a structure P = (I, sol,m, goal), where
I is the input set to P;
sol(x) is the set of feasible solutions for an input x .
The objective function m is an integer (rational) measuredefined over pairs (x , y), for x ∈ I and y ∈ sol(x).
goal is the optimization criterium max or min.
That is the function problem whose goal, with respect to aninstance x , is to find an optimum solution, that is, a feasiblesolution y such that
y = goal{(m(x , y ′) | y ′ ∈ sol(x)}.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Optimization Problems: Complexity classes
PO polynomial time optimizationthere is a polynomial time algorithm computing an optimalsolution for any input.
EXPO exponential time optimizationthere is an exponential time algorithm computing an optimalsolution for any input.
NPO NP optimizationSyntactic definition:
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
The NPO class
An optimization problem P = (I, sol,m, goal) belongs to NPO iff
I is recognizable in polynomial time.
The feasible solutions are short:a polynomial p exists such that, for y ∈ sol(x), |y | ≤ p(|x |) .Moreover, it is decidable in polynomial time whethery ∈ sol(x), for x , y with |y | ≤ p(|x |),
The objective function m is computable in polynomial time.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
The NPO class: Justification
The bounded version of an optimization problem is thedecision problem
minimization P = (I, sol,m,min) is
Given x ∈ I and an integer kIs there a solution y ∈ sol(x) such that m(x , y) 6 k?
maximization P = (I, sol,m,max) is
Given x ∈ I and an integer kIs there a solution y ∈ sol(x) such that m(x , y) > k?
The bounded version of a NPO problem belongs to NP.
For a NPO problem the bounded version and the optimizationproblem are polynomially equivalent, via Turing reductions.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Some NPO problems
min-bin packingGiven n objects, object i has volume vi , 0 ≤ vi ≤ 1, compute theminimum number of unit bins needed to pack all the objects.
max-satGiven a cnf formula F , compute an assignment that satisfies themaximum number of clauses.
max-w-satGiven a cnf formula F , in which each clause has an assigned weight.Define the value of an assignment as the sum of the weights of thesatisfied clauses. The problem consists in computing an assignmentwith maximum value.
And the bounded literal per clause families max-k-sat.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
How to “solve” NP-hard optimization problems in practice
We know that an optimization problem, whose decision version isNP-hard, cannot be solved in polynomial time unless P =NP.
Exact algorithms: for instances of small size or for restrictedclasses of instances.
Randomization: algorithms that use random bits, either withhigh probability of succes or with high probability of poly time.
Heuristic method: a feasible solution with empirical guarantee.
Approximation algorithm: a feasible solution with aperformance guarantee.
Parameterization: solve efficiently some slices of the problem.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Approximation algorithms
Let P be an optimization problem.
For any instance x of P let opt(x) be the cost of an optimalsolution.
Let A be an algorithm such that for any instance x of Pcomputes a feasible solution with cost A(x).
A is an r -approximation for P (r ≥ 1) if for any instance x of P
1
r≤ opt(x)
A(x)≤ r
P is r -approximable in polynomial time if there is a polynomialtime computable r -approximation for P.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Nex Fit: An approximation algorithm for BinPacking
min-bin packingGiven n objects, object i has volume vi , 0 ≤ vi ≤ 1, compute theminimum number of unit bins needed to pack all the objects.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Nex Fit: An approximation algorithm for BinPacking
Let us assume that the bins are labeled B1,B2, . . . ,Bn and thatinitially all are closed and during the execution of the algorithmonly one bin will be open.
Next Fit places the n objects, one after the other, as follows:
Opens B1 and places the first object in B1.
If the i-th object fits in the open box, we put it inside.Otherwise, we close the bin, open the next one and place theobject in it.
For the case of v1 = 0.3, v2 = 0.8, and v3 = 0.7, Next Fit solutionneeds three bins. But there is a solution with uses only two bins.Not optimal!
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Nex Fit: An approximation algorithm for BinPacking
Theorem
Let x be an input to the min-bin packing problem and let opt(x)be the minimum number of bins needed to pack de objects in x . IfNF(x) is the number of bins in the solution computed by Next Fit,then opt(x) ≤ NF(x) ≤ 2opt(x).
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Nex Fit: An approximation algorithm for BinPacking
Theorem
Let x = (v1, . . . , vn be an input to the min-bin packing. LetNF(x) be the number of bins in the solution computed by NextFit, we have opt(x) ≤ NF(x) ≤ 2opt(x).
Proof.
The first inequality is always true:
min-bin packing is a minimization problem
Next Fit provides a feasible solution
Let V =∑n
i=1 vi , we have opt(x) ≥ dV e.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Nex Fit: An approximation algorithm for BinPacking
Proof.
Let us look to two consecutive bins in the Next Fit solution Thetotal packet size in the two bins must be bigger than 1, otherwisewe will never have opened the second bin. So,
NF(x) ≤ 2dV e.
But we have seen opt(x) ≥ dV e, so
NF(x) ≤ 2dV e ≤ 2opt(x).
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
NPO: approximation classes
Classification of NPO problems as approximablewithin a constant r in polynomial time:
APX exists r .
PTAS Polynomial Time Approximation Schemafor any r , but time may depend exponentially in 1/(r − 1).
FPTAS Fully Polynomial Time Approximation Schemafor any r in time polynomial in the input size and 1/(r − 1).
Further classification can be obtained by considering non-constantr , for example log n or log log n . . . .
Negative results through hardness APX-hard etc.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
Optimization ProblemComplexity classesAlgorithmic techniques for hard problemsDefinition and exampleComplexity classes for approximation
Hard to approximate problems
Hardness levels:
APX-hard: unless P =NP no PTASunless P =NP no constant approximation...Non-approximableunless P =NP, for any r at most a polynomial function of n, thereis no polynomial time r -approximation algorithm
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
1 Definitions
2 Basic techniques
3 Relax and round
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Load Balancing problem
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Processing scenario
We have m identical machines;n jobs, job j has processing time tj
Job j must run contiguously on one machine.
A machine can process at most one job at a time.
We want to assign jobs to machines optimizing the makespan.
Let J(i) be the subset of jobs assigned to machine i .
The load of machine i is Li =∑
j∈J(i) tj
The makespan is the maximum load on any machine,L = maxi Li .
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Load Balancing problem
lbalGiven n jobs, job j has processing time tj , assign jobs to m identicalmachines as to minimize the makespan.
The problem is NP-hard and belongs to NPO.Load balancing is hard even if m = 2 machines(reduction from Partition).
The approximation algorithm we propose is a greedy algorithmcalled list-scheduling.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
List scheduling
List schedulingFor j = 1, . . . , n:
Assign job j to the machine having smallest load so far.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
List scheduling: Implementation
function List Scheduling(m, n,T )for i = 1, dots,m do
L[i ] = 0 load on machineJ[i ] = ∅ jobs assigned to
end forfor j = 1, . . . , n do
i = argminkLk machine with smallest loadJ[i ] = J[i ] ∪ {j}L[i ] = L[i ] + T [j ]
end forend function
Cost: Using a priority queue to maintain L, the cost is O(n log m)
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
List scheduling: Approximation rate
Theorem
List scheduling is a polynomial 2-approximation algorithm forlbal.
Proof.
Let L∗ be the optimum makespan and L the makespan of thesolution computed by list scheduling.
L∗ ≥ maxj tj and L∗ ≥ 1m
∑j tj .
Assume that L = Li . Let j be the last job scheduled inmachine i .
When job j was assigned, all the other machines have higherload, so Li − tj ≤ Lk , for k 6= i .
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
List scheduling: Approximation rate
Theorem
List scheduling is a polynomial 2-approximation algorithm forlbal.
Proof.
When job j was assigned, all the other machines have higherload, so Li − tj ≤ Lk , for 1 ≤ k ≤ m. Summing up for all kand dividing by m we get
Li − tj ≤ 1m
∑k Lk ≤ 1
m
∑j tj ≤ L∗
We have, L = Li = (Li − tj) + tj ≤ L∗ + L∗ = 2L∗
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
List scheduling: Tightness?
m machines, m(m − 1) length 1 jobs and 1 job of length m.
List scheduling assigns the first m length 1 jobs, to differentmachines, and
after scheduling the unit length jobs, all machines have loadLi = m − 1.
The last job is assigned to one machine, giving a makespanL = m + m − 1 = 2m − 1.
An optimal solution assigns the big job to one machine and munit jobs to the other machines, so L∗ = m.
The approximation rate is tight
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Longest processing first
Analizamos una variante,
Longest processing first:Sort jobs in decreasing order of processing time.Run list scheduling.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Longest processing first: Approximation rate
Theorem
Longest processing first is a polynomial 3/2-approximationalgorithm for lbal.
Proof.
If n ≤ m, L = t1 = L∗ ≤ 3/2L∗
If n > m, since there are more jobs than machines, a machinemust take two jobs in (t1, . . . , tm+1).
Therefore, L∗ ≥ 2tm+1 ≥ 2tj , being j the last job assigned tothe machine i that gives the makespan.
So, Li = (Li − tj) + tj ≤ L∗ + 12L∗ ≤ 3
2L∗.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Longest processing first: Tightness?
The 3/2 bound on the approximation rate is not tight
In fact Longest processing first is a 4/3-approximationalgorithm [Graham 1969]
4/3 is tight:
m machinesn = 2m + 1 jobs2 jobs of length m,m + 1, . . . , 2m − 1 and one more job oflenght m.L∗ = 3m and L = 4m − 1, which gives a ratio tending to 4/3.4/3 is tight
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Max Cut
max-cutGiven a graph G = (V ,A) we want to find a partition of V into V1,V2 in such a way that
cut(V1,V2) = ||{(u, v) | u ∈ V1 v ∈ V2}||
is maximum.
The problem is NP-hard and belongs to NPO.
Let us analyze a local search algorithm using the HillClimbingparadigm.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Local search
A neighborhood structure is defined on the solution set.
The algorithm performs an exploration of the neighborhoodgraph.
It starts at one feasible solution moves to a better one andfinishes at a local optimum
A local optimum is a solution such that all its neighbors have equalor worse cost.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Neighborhood for MaxCut
Given a graph G = (V ,E ) define N (G ):
The neighbors of a solution (V1,V2) are all those partitionsthat can be obtained by moving either one element fromV1 to V2 or one element from V2 to V1.
Using N (G ) we consider the following algorithm:
HillClimbing Max-Cut (G:graph, n: integer)V1,V2: set of [1 . . . n];V1 := ∅; V2 := V(G );while not local-optimum(V1,V2) do(V1,V 2):= a neighboring partition of (V1,V2)with improved cost
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
HillClimbing MaxCut
Observe that the algorithm needs only polyomial time as
we can compute cut(X ,Y ) in O(|E(G )|) teps.
The number of neighbors of a solution is n.
The cost of the initial solution is 0.
The maximum partition cut is upper bounded by |E(G )|.At each step the cut is increased in one unit.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
HillClimbing MaxCut
Lemma
Let G = (V ,A) be a graph, if (V1,V2) is a local optimum ofN (G ) then cut((V1,V2)) ≤ 2opt(G ).
Proof.
Let
(V1,V2) be a local optimum
m1 be the number of edges in G joining two vertices in V1
m2 be the number of edges in G joining two vertices in V2
m = |E(G )|Therefore, m = m1 + m2 + cut(V1,V2).
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
HillClimbing MaxCut
Proof.
For any vertex u, set
mu1 = |{v | v ∈ V1, (v , u) ∈ A}|
mu2 = |{v | v ∈ V2, (v , u) ∈ A}|.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
HillClimbing MaxCut
Proof.
As (V1,V2) is a local optimum, for any u, moving only u providesa new partition with equal or smaller cost.
for u ∈ V1,cut((V1 − u,V2 + u))− cut((V1,V2)) = mu
1 −mu2 ≤ 0
for u ∈ V1,cut((V1 + u,V2 − u))− cut((V1,V2) = mu
2 −mu1 ≤ 0
So, ∑u∈V1
(mu1 −mu
2) = 2m1 − cut(V1,V2) ≤ 0
∑u∈V2
(mu2 −mu
1) = 2m2 − cut(V1,V2) ≤ 0
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
HillClimbing MaxCut
Proof.
Adding the las two quantities we have
2m1 + 2m2 − 2cut(V1,V2) ≤ 0
As m = m1 + m2 + cut(V1,V2) we get
cut(V1,V2) ≥ m/2.
As we always have opt(G ) ≤ m, then we have that
2cut(V1,V2) ≥ opt(G ).
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
HillClimbing MaxCut
Taking into account that the proposed algorithm always finds alocal optimum in polynomial time, we have
Theorem
HillClimbing Max-Cut is a polynomial 2-approximationalgorithm for max-cut.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
A problem in FPTAS: 0-1 Knapsack
0-1 knapsackGiven an integer b and a set of n objects, object i has weight wi andvalue vi , compute a selection of objects with total size less than orequal to b and maximum profit.
The problem is NP-hard and belongs to NPO. There is a dynamic
programming algorithm that solves 0-1 knapsack in time
∼ nn∑
i=1
vi .
The algorithm is polynomial for poly(n) values.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Consider the following Scaledown algorithm which has r asinput:
Scaledown(w , v , b, r)
vmax := max vi ;
t := blog[ r−1rvmaxn ]c;
z := instance obtained by changing profits to v ′i = vi/2t ;
y := optimal solution for z ;
return y
Is Scaledown a polynomial time approximation schema? time?rate of approximation?
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
TimeThe most difficult part is the computation of the optimal solutionthat takes time
nn∑
i=1
v ′i = n
∑ni=1 vi2t
= n2 vmax
2t
But, t = blog r−1r
vmaxn c
Thus, for r → 1, = n2 vmaxr−1r
vmaxn
= rn3
r−1 = O( n3
r−1).
polynomial in input size and 1/(r − 1)
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Quality of the solutionopt(x)− A(x , r) ≤ n2t , and nvmax ≥ opt(x) ≥ vmax. Thus
n2t
vmax≥ opt(x)− A(x , r)
opt(x)= 1− A(x , r)
opt(x)
A(x , r)
opt(x)≥ 1− n2t
vmax=
vmax − n2t
vmax
But t = blog r−1r
vmaxn c and n2t = n r−1
rvmaxn = vmax
r−1r .
opt(x) ≤ vmax
vmax − n2tA(x , r) =
vmax
vmax − Vmax(r−1)r
A(x , r) ≤ rA(x , r).
Thus, Scaledown is an r -approximation, we have a FPTAS forKnapsack.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Min-TSP with triangle inequality
min-m-tspGiven a set of n cities together with distances among any pair of cities,under the assumption that distances verify the triangle inequality, finda shortest tour.
We model the instance by a weighted graph G = (V ,E , d).
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Algorithm TSP-ST
Compute a minimum spanning tree T of G .
Find the directed graph T ′ obtained from T by replacing eachedge with two arcs in oposite directions.
Find an Eulerian circuit R of T ′.
Let S be the walk in G directed by R.
Transform S in a tour C , by removing (in order) all thevertices that have been already visited in S .
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Theorem
Algorithm TSP-ST is a polynomial 2-aproximation algorithm formin-m-tsp.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Theorem
Algorithm TSP-ST is a polynomial 2-aproximation algorithm formin-m-tsp.
Proof.
Observe that:
opt(G ) ≤ c(C ) ≤ c(S) = c(R) due to triangle inequality.
c(R) = 2c(T ) as we use each edge twice.
Furthermore, any circuit provides a spanning tree, just byremoving one of their edges, amb total distance below thecircuit’s distance:c(T ) ≤ opt(G ).
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Christofides’ algorithm TSP-CH
Handshaking lemma: every finite undirected graph has an evennumber of vertices with odd degree
Compute a minimum spanning tree T of G .
Let O be the set of vertices with odd degree in T . By thehandshaking lemma, O has an even number of vertices.
Find a minimum-weight perfect matching M in the inducedsubgraph given by the vertices from O.
Combine the edges of M and T to form a connectedmultigraph H in which each vertex has even degree.
Find an Eulerian circuit R of H.
Let S be the walk in G directed by R.
Transform S in a tour C , by removing (in order) all thevertices that have been already visited in S .
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Lemma
G = (V ,E ) is a graph. Let M be a minimum-weight perfectmatching for O. Then c(M) ≤ opt(G )/2.
Proof.
Take any optimal tour of G , take the shortcuts to make a tourK for O. By the triangle inequality c(K ) ≤ opt(G )
As O has even number of vertices K can be decomposed intotwo (alternating) perfect matchings S and S ′.M is a minimum weight perfect matching and2c(M) ≤ c(S) + c(S ′) = c(K ) ≤ opt(G )
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Theorem
Algorithm TSP-CH is a polynomial 3/2-aproximation algorithmfor min-m-tsp.
Proof.
By the previous lemma c(M) ≤ opt(G )/2.
We already know that c(T ) ≤ opt(G )
Also, opt(G ) ≤ c(C ) ≤ c(S) = c(R) due to triangleinequality.
By construction, c(R) ≤ c(T ) + w(M) ≤ opt(G ) + opt(G)2
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Shortest superstring
shsstrGiven an alphabet Σ and a set of n strings, S = {s1, ..., sn} ⊆ Σ∗,we want to find the shortest string s that, for i = 1, . . . , n, containssi as a substring.
Input
CATGCCTAAGTGCTATTCAATGCATC
Output GCTAAGTTCATGCATC
CATGCCTAAGT
GCTATTCA
ATGCATC
We assume that no si ∈ S is a substring of sj ∈ S .ShSStr belongs to NPO and it is NP-hard, by a reductionfrom TSP.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
An expression for the optimal cost
For two strings s and t define
overlap(s, t) = the longest suffix of s that is a prefix of t.
prefix(s, t) = s after deleting overlap(s, t).
Assume that in an optimal solution s∗ the strings appear in theorder s1, . . . , sn.
The overlap among two consecutive strings must bemaximum.
opt(S) = |s∗| =|prefix(s1, s2)|+ · · ·+ |prefix(sn, s1)|+ |overlap(sn, s1)|.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
opt(S) = |prefix(s1, s2)|+ · · ·+ |prefix(sn, s1)|+ |overlap(sn, s1)|.
GCTAAGTTCATGCATC
s1 GCTAs2 CTAAGTs3 TTCAs4 CATGCs5 ATGCATCs1 GCTA
s1 is repeated at the end to get the last two terms.
opt(G ) is lower bounded by a minimum TSP tour in the prefixgraph having w(si , sj) = |prefix(si , sj)|. Hard to compute §
Any cycle related problem easy to compute?MinWCycleCover
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Minimum weight cycle cover
minwcyclecoverGiven a weighted graph G find a minimum weight collection of disjointcycles covering all the vertices in G .
MinWCycleCover can be solved as a minimum weightperfect matching in a bipartite graph
G ′ = (V1,V2,E′) if (u, v) ∈ E we have an edge (u1, v2) with
weight w(u, v).
Cycle covers in G are in a one to one correspondence withperfect matchings in G ′.
A minimum weight perfect matching in G ′ can be computedusing a MaxFlow algorithm in poly time.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
From cycles to strings
Assume that c is a cycle in the prefix graph of a set of stringsS .
c = i1 → i2 → · · · → i` → i1.
Consider the stringσ(c) = prefix(si1 , si2) · · · · · prefix(si` , si1) · si1 .
σ(c) is a superstring of si1 · · · · · si`σ(c) starts and ends with si1 .
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
SSS-CycleCover
Algorithm SSS-CycleCover(S)
Construct the prefix graph associated to S .
Find a minimum weight cycle cover C = {c1, . . . , ck}.Break each cycle i at a position i1.
Output σ(c1) · · · · · σ(ck)
Observe that, for two consecutive cycles c and c ′ with breakingstrings t and t ′, we have |overlap(t, t ′)| ≤ w(c) + w(c ′).
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
SSS-CycleCover
Theorem
Algorithm SSS-CycleCover is a 4-approximation algorithm forShSString.
Proof.
opt(S) = w(C) =∑k
i=1 w(ci ).
A(S) =∑k
i=1 |σ(ci )| = w(C ) +∑k
i=1 |ti |.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
GreedyLocal SearchScalingCombinatorial algorithms
Proof.
Assume that ti (and si ) are numbered in order of theirleftmost occurrence in a shortest superstring s∗ for S .
opt(S) =∑n−1
i=1 |prefix(si , si+1)|+ |prefix(sn, s1)|+|overlap(sn, s1)| ≤
∑n−1i=1 |prefix(si , si+1)|
|ti | − overlap(ti , ti+1) = |prefix(si , si+1)|, so
opt(S) ≥k∑
i=1
|ti | ≥k∑
i=1
|ti | −k−1∑i=1
|overlap(ti , ti+1)|
k∑i=1
|ti | − 2k∑
i=1
w(ci ) =k∑
i=1
|ti | − 2opt(S)
Therefore,∑k
i=1 |ti | ≤ 3opt(S), and A(S) ≤ 4opt(S).
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
1 Definitions
2 Basic techniques
3 Relax and round
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Relaxation and rounding
Many real-life problems can be modeled as Integer LinearPrograms (IP).The IP can be relaxed to a linear program (LP).We can solve the LP in polynomial timeSimplex method: Dantzig in 1947 (exponential Klee andMinty 1972), Ellipsoid method: Khachiyan 1979 (O(n6)),Interior-point method: Karmarkar 1984 (O(n3)).
LP optimal solution might not be integral, transform it to geta feasible solution not far from opt.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Vertex cover
min-vcGiven a graph G = (V ,A) we want to find a set S ⊂ V with minimumcardinality, so that every edge in G has at least one end point in S .
VC-IP
minn∑
i=1
cixi
s.t. xi + xj ≥ 1 for all (i , j) ∈ E
xi ∈ {0, 1} for all i ∈ V
VC-LP
minn∑
i=1
cixi
s.t. xi + xj ≥ 1 for all(i , j) ∈ E
xi ≥ 0 for all i ∈ V
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Min Vertex cover: relaxed solutions
Lemma
VC-LP has an optimal solution x∗ such that xi ∈ {0, 1, 1/2}.Furthermore, such a solution can be computed in polynomial time.
Proof.
Let y be an optimal solution s.t. not all its coordinates are in {0, 1, 1/2}.Set ε = minyi /∈{0,1,1/2}{yi , |yi − 1/2|, 1− yi}. Consider
y ′i =
yi − ε 0 < yi < 1/2
yi + ε 1/2 < yi < 1
yi otherwise
y ′′i =
yi + ε 0 < yi < 1/2
yi − ε 1/2 < yi < 1
yi otherwise∑yi = (
∑y ′i +
∑y ′′i )/2, so both are optimal solutions. One of them
has more {0, 1, 1/2} coordinates than y .
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Vertex cover: Relax + Round algorithm
function Relax+Round VC(G )Construct the LP-VC associated GLet y be an optimal relaxed solution (of the LP instance)Using the previous lemma, construct an optimal relaxed
solution y ′ such that y ′i ∈ {0, 1, 1/2}Let x defined as xi = 0 if y ′i = 0, xi = 1 otherwise.return (x)
end function
Relax+Round VC
runs in polynomial time
x defines a vertex cover∑ni=1 xi ≤ 2
∑ni=1 y ′i ≤ 2opt
is a 2-approximation for VC.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Min Weighted vertex cover: Relax+Round approximation
LP WVC
minn∑
i=1
cixi
s.t. xi + xj ≥ 1 for all(i , j) ∈ E
xi ≥ 0 for all i ∈ V
function WVC(G , c)Construct the LP WVC, Iy = LP.solve(I )for i = 1, . . . , n do
if yi < 1/2 thenxi = 0
elsexi = 1
end ifend forreturn (x)
end functionRelax+Round WVC
runs in polynomial timex defines a vertex cover∑n
i=1 cixi ≤ 2∑n
i=1 ciyi ≤ 2optis a 2-approximation for WVC.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Minimum 2-Satisfiability
min 2-satGiven a Boolean formula in 2-CNF, determine whether it is satisfi-able and, in such a case, find a satisfying assignment with minimumnumber of true variables.
2-SAT can be solved in polynomial time
Min 2-SAT IP formulation?
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Minimum 2-Satisfiability: IP formulation
Suppose that F has n variables x1, . . . xn and m clauses with 2literals per clause
IP Min 2-SAT
minn∑
i=1
xi
s.t. xi + xj ≥ 1 for all clauses (xi ∨ xj) ∈ F
(1− xi ) + xj ≥ 1 for all clauses (x i ∨ xj) ∈ F
(1− xi ) + (1− xj) ≥ 1 for all clauses (x i ∨ x j) ∈ F
xi ∈ {0, 1} 1 ≤ i ≤ n
LP Min 2-SAT is obtaining replacing xi ∈ {0, 1} by xi ≥ 0.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Minimum 2-Satisfiability: LP relaxation
LP Min 2-SAT
minn∑
i=1
xi
s.t. xi + xj ≥ 1 for all clauses (xi ∨ xj) ∈ F
(1− xi ) + xj ≥ 1 for all clauses (x i ∨ xj) ∈ F
(1− xi ) + (1− xj) ≥ 1 for all clauses (x i ∨ x j) ∈ F
xi ≥ 0 1 ≤ i ≤ n
Let y be an optimal solution to LP Min 2-SAT.Can we use the same rounding scheme as for WVC?Setting xi = 1 if yi > 1/2 and xi = 0 if yi < 1/2 is safe, allclauses with at least one literal with value > 1/2 will besatisfied.When yi = 1/2?
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Minimum 2-Satisfiability: LP relaxation
Let y be an optimal solution to IP Min 2-SAT.
What to do when yi = 1/2? 1? 0?
If F contains the clauses (xi ∨ xj) and (x i ∨ x j) andyi = yj = 1/2, neither xi = xj = 1 nor xi = xj = 0 satisfy theformula.
F1 = clauses whose two variables have y value = 1/2.
Rounding those values to 1 or 0 would keep the approximationratio to 2, provided the constructed solution x to Min 2-SATis still a satisfying assignment.
Any satisfying assignment for the clauses in F1 and get a2-approximation
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Minimum 2-Satisfiability: Relax+Round approximation
function Relax+Round Min 2-SAT(F )if F is not satisfiable then return falseend ifConstruct the LP Min 2-SAT, Iy = LP.solve(I )for i = 1, . . . , n do
if y ′i < 1/2 then xi = 0end ifif y ′i > 1/2 then xi = 1end if
end forF1 = clauses with both y values = 1/2.Let J = {j | xj ∈ F1}for i=1,. . . , n do
if yi = 1/2 and i 6∈ J then xi = 1end if
end forComplete x with a satisfying assignment for F1
return (x)end function
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Minimum 2-Satisfiability: Relax+Round approximation
Theorem
Relax+Round Min 2-SAT is a 2-approximation for Min2-SAT.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Max Satisfiability
max satGiven a Boolean formula in CNF and weights for each clause, find aBoolean assignment to maximize the weight of the satisfied clauses.
Suppose that F has n variables x1, . . . xn and m clauses C1, . . . ,Cm.
IP Max SAT
maxm∑j=1
wjzj
s.t.∑xi∈Cj
yi +∑x i∈Cj
(1− yi ) ≥ zj = 1, . . . ,m
yi ∈ {0, 1} 1 ≤ i ≤ n
zj ∈ {0, 1} 1 ≤ j ≤ m
LP Max SAT is obtaining replacing a ∈ {0, 1} by 0 ≤ a ≤ 1.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Max Satisfiability: Relax+RRound
function Relax+RRound(F )Construct the LP Max SAT, I(y , z) = LP.solve(I )for i=1,. . . , n do
Set xi = 1 with probability yiend forreturn (x)
end function
The optimal LP solution is used as an indicator of theprobability that the variable has to been set to 1.
The performance of a randomized algorithm is the expectednumber of satisfiable clause.
This expectation has to be compared with opt.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Max Satisfiability: Relax+RRound
Let (y∗, z∗) be an optimal solution of LP Max SAT
Let Zj be the indicator random variable for the event thatclause Cj is satisfied.
Assume that Cj has k-literals and that ` of them are negatedvariables.
Lemma
For any 1 ≤ j ≤ m, E [Zj ] ≥ z∗j (1− 1/e).
Recall (a1 . . . ak)1/k ≤ (a1 + · · ·+ ak)/k .
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Max Satisfiability: Relax+RRound
Proof.Zj is an indicator random variable, and soE [Zj ] = Pr [Zj = 1] = 1− Pr [Zj = 0]
Pr [Zj = 0] =∏xi∈Cj
(1− y∗i ) ·∏x i∈Cj
y∗i ≥
((k − `)−
∑xi∈Cj
y∗i +∑
x i∈Cjy∗i
k
)k
≥
((k −
∑xi∈Cj
y∗i −∑
x i∈Cj(1− y∗i )
k
)k
≥(
(k − z∗j )
k
)k
≥(
1−z∗jk
)k
E [Zj ] ≤ 1−(
1−z∗jk
)k
≥ z∗j
(1− 1
k
)k
≥ z∗j (1− 1/e)
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Max Satisfiability: Relax+RRound approximation
Theorem
Relax+RRound is a e/(e − 1)-approximation for Max SAT.
Proof.
Let (y∗, z∗) be an optimal solution of LP Max SAT
Let Zj be the indicator r.v.a for clause Cj is satisfied.
Let W be the r.v. weight of satisfied clauses:W =
∑mj=1 wjZj .
E [W ] =∑m
j=1 wjE [Zj ] ≥ (1− 1/e)∑m
j=1 wjz∗j ≥ (1− 1/e)opt
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Max Satisfiability:RandAssign
function RandAssign(F )for i=1,. . . , n do
Set xi = 1 with probability 1/2end forreturn (x)
end function
Theorem
RandAssign is a 2-approximation for Max SAT.
Proof.
E [W ] =∑m
j=1 wjE [Zj ] =∑m
j=1 wj
(1− (12)kj
)≥ 1
2
∑mj=1 wj ≥
12opt.
We move from r = 2 (RandAssign) to r = 1.581977(Relax+RRound).
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Max Satisfiability:Best2
function Best2(F )x1,W1 = RandAssign(F )x2,W2 = Relax+RRound(F )if W1 ≥W2 then
return (x1)else
return (x2)end if
end function
Theorem
Best2 is a 4/3 (1.33333)-approximation for Max SAT.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Max Satisfiability:Best2
Proof.
E [W ] = E [max{W1,W2}] ≥ E [(W1 + W2)/2}].
E [W ] ≥m∑j=1
wj
[1
2
(1−
(1
2
)kj)
+1
2z∗j
(1−
(1
kj
)kj)]
≥m∑j=1
wj3
4z∗j ≥
3
4
m∑j=1
wjz∗j ≥
3
4opt.
AlCo-GMat Approximation Algorithms
DefinitionsBasic techniquesRelax and round
The frameworkVertex CoverMin Weighted Vertex COverMin 2-SATMax Satisfiability
Max Satisfiability:Best2
Proof.
Is
[12
(1−
(12
)kj)+ 12z∗j
(1−
(1kj
)kj)]≥ 3
4z∗j ?
kj = 1: 1212 + 1
2z∗j ≥34z∗j .
kj = 2: 1234 + 1
234z∗j ≥
34z∗j .
kj ≥ 3: the minimum possible of each term is
1
2
7
8+
1
2
(1− 1
e
)z∗j ≥
3
4z∗j
AlCo-GMat Approximation Algorithms