Алгоритмы для NP-трудных задач, осень 2016: Задачи поиска

  • View
    174

  • Download
    4

Embed Size (px)

Text of Алгоритмы для NP-трудных задач, осень 2016: Задачи поиска

  • NP-complete Problems:Search Problems

    Alexander S. KulikovSteklov Institute of Mathematics at St. Petersburg

    Russian Academy of Sciences

    Advanced Algorithms and ComplexityData Structures and Algorithms

    https://www.coursera.org/learn/advanced-algorithms-and-complexityhttps://goo.gl/KAfKJT

  • Outline1 Brute Force Search

    2 Search Problems

    3 Easy and Hard ProblemsTraveling Salesman ProblemHamiltonian Cycle ProblemLongest Path ProblemInteger Linear Programming ProblemIndependent Set Problem

    4 P and NP

  • Polynomial vs Exponential

    running time: n n2 n3 2n

    less than 109: 109 104.5 103 29

  • Improving Brute Force Search

    Usually, an efficient (polynomial) algorithmsearches for a solution among an exponentialnumber of candidates:

    there are n! permutations of n objects

    there are 2n ways to partition n objectsinto two setsthere are nn2 spanning trees in acomplete graph on n vertices

  • Improving Brute Force Search

    Usually, an efficient (polynomial) algorithmsearches for a solution among an exponentialnumber of candidates:

    there are n! permutations of n objectsthere are 2n ways to partition n objectsinto two sets

    there are nn2 spanning trees in acomplete graph on n vertices

  • Improving Brute Force Search

    Usually, an efficient (polynomial) algorithmsearches for a solution among an exponentialnumber of candidates:

    there are n! permutations of n objectsthere are 2n ways to partition n objectsinto two setsthere are nn2 spanning trees in acomplete graph on n vertices

  • This module

    For thousands of practically importantproblems we dont have an efficientalgorithm yet

    An efficient algorithm for one suchproblem automatically gives efficientalgorithms for all these problems!$1M prize for constructing such analgorithm or proving that this isimpossible!

  • This module

    For thousands of practically importantproblems we dont have an efficientalgorithm yetAn efficient algorithm for one suchproblem automatically gives efficientalgorithms for all these problems!

    $1M prize for constructing such analgorithm or proving that this isimpossible!

  • This module

    For thousands of practically importantproblems we dont have an efficientalgorithm yetAn efficient algorithm for one suchproblem automatically gives efficientalgorithms for all these problems!$1M prize for constructing such analgorithm or proving that this isimpossible!

  • Outline1 Brute Force Search

    2 Search Problems

    3 Easy and Hard ProblemsTraveling Salesman ProblemHamiltonian Cycle ProblemLongest Path ProblemInteger Linear Programming ProblemIndependent Set Problem

    4 P and NP

  • Boolean Formulas

    Formula in conjunctive normal form

    (x y z)(x y)(y z)(z x)(x y z)x , y , z are Boolean variables (values:true/false or 1/0)literals are variables (x , y , z) and theirnegations (x , y , z)clauses are disjunctions (logical or) ofliterals

  • Satisfiability (SAT)

    Input: Formula F in conjunctive normalform (CNF).

    Output: An assignment of Boolean values tothe variables of F satisfying allclauses, if exists.

  • Examples

    The formula (x y)(x y)(x y) issatisfiable: set x = 1, y = 0.The formula (x y z)(x y)(y z) issatisfiable: set x = 1, y = 1, z = 1 orx = 1, y = 0, z = 0.The formula(xy z)(xy)(y z)(zx)(xy z)is unsatisfiable.

  • Satisfiability

    Classical hard problemMany applications: e.g.,hardware/software verification, planning,schedulingMany hard problems are stated in termsof SAT naturallySAT solvers (will see later), SATcompetition

  • SAT is a typical search problemSearch problem: given an instance I ,find a solution S or report that noneexistsMain property: one must be able tocheck quickly whether S is indeed asolution for IBy saying quickly, we mean in timepolynomial in the length of I . Inparticular, the length of S should bepolynomial in the length of I

  • DefinitionA search problem is defined by analgorithm that takes an instance I anda candidate solution S , and runs in timepolynomial in the length of I . We say that Sis a solution to I iff (S , I ) = true.

  • Example

    For SAT, I is a Boolean formula, S is anassignment of Boolean constants to itsvariables. The corresponding algorithm checks whether S satisfies all clauses of I .

  • Next part

    A few practical search problems for whichpolynomial algorithms remain unknown

  • Outline1 Brute Force Search

    2 Search Problems

    3 Easy and Hard ProblemsTraveling Salesman ProblemHamiltonian Cycle ProblemLongest Path ProblemInteger Linear Programming ProblemIndependent Set Problem

    4 P and NP

  • Outline1 Brute Force Search

    2 Search Problems

    3 Easy and Hard ProblemsTraveling Salesman ProblemHamiltonian Cycle ProblemLongest Path ProblemInteger Linear Programming ProblemIndependent Set Problem

    4 P and NP

  • Traveling salesman problem (TSP)

    Input: Pairwise distances between n citiesand a budget b.

    Output: A cycle that visits each vertexexactly once and has total length atmost b.

  • Delivery Company

    https://simple.wikipedia.org/wiki/Travelling_salesman_problem

    https://simple.wikipedia.org/wiki/Travelling_salesman_problem

  • Drilling Holes in a Circuit Board

    https://developers.google.com/optimization/routing/tsp

    https://developers.google.com/optimization/routing/tsp

  • Example

    1

    2

    5

    3

    4

    5

    2

    4

    2

    2

    1

    13

    33

  • Example

    1

    2

    5

    3

    4

    5

    2

    4

    2

    2

    1

    13

    33

    length: 15

  • Example

    1

    2

    5

    3

    4

    5

    2

    4

    2

    2

    1

    13

    33

    length: 13

  • Example

    1

    2

    5

    3

    4

    5

    2

    4

    2

    2

    1

    13

    33

    length: 9

  • Search Problem

    TSP is a search problem: given asequence of vertices, it is easy to checkwhether it is a cycle visiting all thevertices of total length at most bTSP is usually stated as an optimizationproblem; we stated its decision versionto guarantee that a candidate solutioncan be efficiently checked for correctness

  • Algorithms

    Check all permutations: about O(n!),extremely slowDynamic programming: O(n22n)No significantly better upper bound isknownThere are heuristic algorithms andapproximation algorithms

  • Comparing to MSTMSTDecision version:given n cities, connectthem by (n 1) roadsof minimal totallength

    Can be solvedefficiently

    TSPDecision version:given n cities, connectthem in a path by(n 1) roads ofminimal total length

    No polynomialalgorithm known!

  • Comparing to MSTMSTDecision version:given n cities, connectthem by (n 1) roadsof minimal totallength

    Can be solvedefficiently

    TSPDecision version:given n cities, connectthem in a path by(n 1) roads ofminimal total length

    No polynomialalgorithm known!

  • Comparing to MSTMSTDecision version:given n cities, connectthem by (n 1) roadsof minimal totallength

    Can be solvedefficiently

    TSPDecision version:given n cities, connectthem in a path by(n 1) roads ofminimal total length

    No polynomialalgorithm known!

  • Comparing to MSTMSTDecision version:given n cities, connectthem by (n 1) roadsof minimal totallength

    Can be solvedefficiently

    TSPDecision version:given n cities, connectthem in a path by(n 1) roads ofminimal total length

    No polynomialalgorithm known!

  • Outline1 Brute Force Search

    2 Search Problems

    3 Easy and Hard ProblemsTraveling Salesman ProblemHamiltonian Cycle ProblemLongest Path ProblemInteger Linear Programming ProblemIndependent Set Problem

    4 P and NP

  • Hamiltonian cycle

    Input: A graph.Output: A cycle that visits each vertex of

    the graph exactly once.

  • Example

  • Example

  • Eulerian cycle

    Input: A graph.Output: A cycle that visits each edge of the

    graph exactly once.

    TheoremA graph has an Eulerian cycle if and only if itis connected and the degree of each vertex iseven.

  • Eulerian cycle

    Input: A graph.Output: A cycle that visits each edge of the

    graph exactly once.

    TheoremA graph has an Eulerian cycle if and only if itis connected and the degree of each vertex iseven.

  • Non-Eulerian graph

    Eulerian graph

  • Non-Eulerian graph Eulerian graph

  • Eulerian cycle

    Find a cycle visitingeach edge exactlyonce

    Can be solvedefficiently

    Hamiltonian cycle

    Find a cycle visitingeach vertex exactlyonce

    No polynomialalgorithm known!

  • Eulerian cycle

    Find a cycle visitingeach edge exactlyonce

    Can be solvedefficiently

    Hamiltonian cycle

    Find a cycle visitingeach vertex exactlyonce

    No polynomialalgorithm known!

  • Eulerian cycle

    Find a cycle visitingeach edge exactlyonce

    Can be solvedefficiently

    Hamiltonian cycle

    Find a cycle visitingeach vertex exactlyonce

    No polynomialalgorithm known!

  • Eulerian cycle

    Find a cycle visitingeach edge exactlyonce

    Can be solvedefficiently

    Hamiltonian cycle

    Find a cycle visitingeach vertex exactlyonce

    No polynomialalgorithm known!

  • Outline1 Brute Force Search

    2 Search Problems

    3 Easy and Hard ProblemsTraveling Salesman ProblemHamiltonian Cycle ProblemLongest Path ProblemInteger Linear Programming ProblemInde