Docsity

Approximation Algorithms: Solving NP-Hard Problems with Suboptimal Solutions - Prof. Eric , Study notes of Computer Science

Toggle sidebar
bg1
Approximation Algorithms
•Main issues
–Finding a good lower or upper bound for the optimal solution value
–Relating your algorithm’s solution value to this bound
–Examples: Scheduling and Vertex Cover
•Basic Setting
–Working with an optimization problem, not a decision problem, where you are
trying to minimize or maximize some value
–Examples:
∗Vertex cover
·Input: Graph G= (V, E )
·Task: Find a vertex cover of minimum size
·Value to be minimized: vertex cover size
∗Independent Set
·Input: Graph G= (V, E )
·Task: Find an independent set of maximum size
·Value to be maximized: independent set size
–The problems are NP-hard
∗The decision version of all these problems is NP-complete
∗Thus, we probably cannot find a polynomial time algorithm that solves the
problem optimally for all input instances.
–Notation
∗Let Π be the problem under consideration
∗Let Ibe an input instance of Π
∗let OPT denote the optimal algorithm
∗Let A denote the algorithm under consideration
∗For any algorithm A and any input instance I, let A(I) denote the value of
A’s solution for input instance I
–Absolute approximation of c(c-absolute-approximation algorithm)
∗ ∃csuch that ∀IA(I)≤OP T (I) + cfor minimization problem Π
·A is a 2-absolute-approximation algorithm for vertex cover if A can always
find a vertex cover at most 2 nodes larger than the optimal size.
∗ ∃csuch that ∀IA(I)≥OP T (I)−cfor maximization problem Π
·A is a 2-absolute-approximation algorithm for independent set if A can
always find an independent set at most 2 nodes smaller than the optimal
size.
∗Very few NP-hard problems have polynomial-time absolute approximation
algorithms
1
pf3
pf4
pf5
pf8

Partial preview of the text

Download Approximation Algorithms: Solving NP-Hard Problems with Suboptimal Solutions - Prof. Eric and more Study notes Computer Science in PDF only on Docsity!

Approximation Algorithms

  • Main issues
    • Finding a good lower or upper bound for the optimal solution value
    • Relating your algorithm’s solution value to this bound
    • Examples: Scheduling and Vertex Cover
  • Basic Setting
    • Working with an optimization problem, not a decision problem, where you are trying to minimize or maximize some value
    • Examples: ∗ Vertex cover · Input: Graph G = (V, E) · Task: Find a vertex cover of minimum size · Value to be minimized: vertex cover size ∗ Independent Set · Input: Graph G = (V, E) · Task: Find an independent set of maximum size · Value to be maximized: independent set size
    • The problems are NP-hard ∗ The decision version of all these problems is NP-complete ∗ Thus, we probably cannot find a polynomial time algorithm that solves the problem optimally for all input instances.
    • Notation ∗ Let Π be the problem under consideration ∗ Let I be an input instance of Π ∗ let OPT denote the optimal algorithm ∗ Let A denote the algorithm under consideration ∗ For any algorithm A and any input instance I, let A(I) denote the value of A’s solution for input instance I
    • Absolute approximation of c (c-absolute-approximation algorithm) ∗ ∃c such that ∀IA(I) ≤ OP T (I) + c for minimization problem Π · A is a 2-absolute-approximation algorithm for vertex cover if A can always find a vertex cover at most 2 nodes larger than the optimal size. ∗ ∃c such that ∀IA(I) ≥ OP T (I) − c for maximization problem Π · A is a 2-absolute-approximation algorithm for independent set if A can always find an independent set at most 2 nodes smaller than the optimal size. ∗ Very few NP-hard problems have polynomial-time absolute approximation algorithms
  • Relative approximation (c-approximation algorithm) ∗ ∃c such that ∀IA(I) ≤ c × OP T (I) for minimization problem Π · For example, A is a 2-approximation algorithm for vertex cover if A can always find a vertex cover of at most twice the optimal size. ∗ ∃c such that ∀IA(I) ≥ (1/c) × OP T (I) for maximization problem Π · For example, A is a 2-approximation algorithm for independent set if A can always find an independent set of at least half the optimal size. ∗ Most of our focus is finding good relative approximation algorithms; unless explicitly stated otherwise, when I talk about approximation algorithms, I mean relative approximation algorithms
  • Example: Multiprocessor scheduling to minimize makespan
  • Input ∗ Set of n jobs with processing times xn ∗ Number of machines m
  • Task ∗ Schedule the jobs on the m machines with the goal of minimizing the makespan (maximum completion time of any job) of the schedule.
  • Initial thoughts about this problem ∗ Suppose m = 1: is this problem hard? ∗ We know this problem is hard for m ≥ 2 because of a reduction from the partition problem.
  • Graham’s list scheduling algorithm (Greedy)
  • Take the items in an arbitrary order
  • Place each item on the currently least loaded machine
  • This is a greedy algorithm
  • Proof of (2 − 1 /m)-approximation factor
  • Greedy’s cost ∗ Let job j be the last job to complete by Greedy ∗ Let h be the load of the machine j is placed onto before job j is placed ∗ Greedy’s cost is h + xj
  • Bounds on OP T (I) ∗ OP T (I) ≥ maxj xj ∗ OP T (I) ≥ (^) m^1

∑n i=1 xi

  • Relating the two costs ∗ h ≤ (^) m^1 ((

∑n i=1 xi)^ −^ xj^ ) · This follows because greedy places j onto the least loaded machine available

∗ Thus, in this case LJF (I) = OP T (I)

  • Since in both cases we have shown that LJF (I) ≤ (4/ 3 − (^31) m )OP T (I), the result follows.
  • Example: Vertex Cover
  • Input ∗ Graph G = (V, E)
  • Task ∗ Find a vertex cover of minimum possible size
  • NP-hardness result ∗ We know this problem is NP-hard because of a reduction from the independent set problem.
  • Greedy is NOT good for vertex cover
  • Choose a node with highest updated degree breaking ties arbitrarily
  • Update degrees of remaining nodes
  • Can produce solution log n times as large as optimal
  • Maximal matching algorithm
  • Find a maximal matching in the graph ∗ A matching is a set of edges such that no two edges in the matching share a node ∗ A maximal matching is a matching that cannot be increased by the addition of an edge without violating the condition of no two edges sharing a node · A maximum matching is a largest possible maximal matching. · Maximum matchings can be found in polynomial time, but the algorithm is fairly sophisticated ∗ Maximal matchings can be found efficiently by processing the edges one at a time retaining an edge if and only if it does not share a node with any of the already chosen edges
  • Choose both nodes from all edges in the matching to be in the vertex cover ∗ This set of nodes must be a vertex cover ∗ Suppose it is not. ∗ Then there is some edge (u, v) that does not include a node in the candidate vertex cover ∗ In this case, edge (u, v) can be added to the maximal matching contradicting the claim that we had a maximal matching.
  • Proof of 2-approximation ratio
  • Let the matching size be M
  • Our algorithm’s cost is 2M

– OP T (I) ≥ M

∗ This follows because each edge in the matching must be covered by at least one node ∗ Since no two edges in the matching share a node, at least one of the two nodes from each edge must be chosen.

  • Example: Bin Packing
    • Input ∗ Set of n objects of sizes si ∗ Infinite number of bins of size B
    • Task ∗ Find a packing of the n objects into the minimum possible number of bins
    • Bin packing is NP-complete ∗ Can reuse the reduction from Partition to Makespan Scheduling
  • Algorithms
    • First Fit Algorithm ∗ Arbitrarily order the items ∗ Number the bins by the order they are opened (initially no bins are open) ∗ When working with item i, place it into the first open bin it fits into. If it does not fit into any open bin, open a new bin and place it into that bin.
    • Best Fit Algorithm ∗ Arbitrarily order the items ∗ When working with item i, place it into the open bin it fits most tightly into. If it does not fit into any open bin, open a new bin and place it into that bin.
    • First Fit Decreasing Algorithm ∗ Sort the items into non-decreasing order by size ∗ Number the bins by the order they are opened (initially no bins are open) ∗ When working with item i, place it into the first open bin it fits into. If it does not fit into any open bin, open a new bin and place it into that bin.
    • Best Fit Decreasing Algorithm ∗ Sort the items into non-decreasing order by size ∗ When working with item i, place it into the open bin it fits most tightly into. If it does not fit into any open bin, open a new bin and place it into that bin.
    • Proof that all algorithms are at least 2-approximations ∗ There is at most 1 open bin that is more than half empty · If not, any of the algorithms would have combined the items in the two at least half-empty bins into 1 bin ∗ Thus, an upper bound on the number of bins (ignoring the one possibly half- empty bin) used by any of these algorithms is 2 (^) B^1

∑n i=1 si

  • Task ∗ Find a tour of the cities of minimum possible total length
  • Greedy algorithm
  • Best guarantee is O(log n)OP T (I)
  • MST algorithm
  • Find a minimum spanning tree T.
  • Double all the edges in T to create an Eulerian graph.
  • Take an Euler tour of the graph using shortcuts to avoid visiting cities more than once. ∗ Shortcuts cannot increase cost because of triangle inequality
  • Proof of 2-approximation ratio
  • Let C(T ) be the total weight of the minimum spanning tree T
  • OP T (I) ≥ C(T ) ∗ Remove an edge from the optimal tour. ∗ We now have a path which is one possible spanning tree. ∗ The minimum spanning tree must have cost no more than this path.
  • M ST (I) ≤ 2 C(T ) ∗ The Eulerian tour has cost exactly 2C(T ) ∗ When taking shortcuts, this cost may decrease but cannot increase because of triangle inequality
  • Christofides’ matching improvement
  • Find a minimum spanning tree T.
  • Find all the nodes in T with odd degree
  • Find a minimum weight matching M of these nodes
  • Create an Eulerian graph by adding the edges in M to those in T
  • Take an Euler tour of the graph using shortcuts to avoid visiting cities more than once.
  • Proof of 3/2-approximation ratio
  • Let C(T ) be the total weight of the minimum spanning tree T and let C(M ) be the total weight of M
  • OP T (I) ≥ C(T ) ∗ Remove an edge from the optimal tour. ∗ We now have a path which is one possible spanning tree. ∗ The minimum spanning tree must have cost no more than this path.
  • 1 / 2 OP T (I) ≥ C(M )

∗ Consider the optimal tour ∗ Take shortcuts to produce a tour that only includes the nodes with odd degree in T ∗ This reduced tour has total weight at most OP T (I) because shortcuts cannot increase the weight by the triangle inequality ∗ This reduced tour an be used to create two possible matchings of these nodes by selecting every other edge ∗ The minimum weight matching M must choose a matching that is less than the minimum of these two matchings, and the result follows.

  • Chr(I) ≤ 3 / 2 C(T )

∗ The Eulerian tour has cost exactly C(T ) + C(M ) ≤ 3 / 2 OP T (I) ∗ When taking shortcuts, this cost may decrease but cannot increase because of triangle inequality