Algoritmer och Komplexitet ht 08. Övning 6. NP-problem

Relevanta dokument
NP-fullständighetsbevis

Algoritmer, datastrukturer och komplexitet

Algoritmer, datastrukturer och komplexitet

Isometries of the plane

Solutions to exam in SF1811 Optimization, June 3, 2014

Pre-Test 1: M0030M - Linear Algebra.

Graphs (chapter 14) 1

Tentamen MMG610 Diskret Matematik, GU

Grafer, traversering. Koffman & Wolfgang kapitel 10, avsnitt 4

Algoritmer, datastrukturer och komplexitet

12.6 Heat equation, Wave equation

Tentamen i Matematik 2: M0030M.

denna del en poäng. 1. (Dugga 1.1) och v = (a) Beräkna u (2u 2u v) om u = . (1p) och som är parallell

Module 1: Functions, Limits, Continuity

This exam consists of four problems. The maximum sum of points is 20. The marks 3, 4 and 5 require a minimum

LUNDS TEKNISKA HÖGSKOLA Institutionen för Elektro- och Informationsteknik

Föreläsning 9: NP-fullständighet

Webbregistrering pa kurs och termin

1. Compute the following matrix: (2 p) 2. Compute the determinant of the following matrix: (2 p)

Workplan Food. Spring term 2016 Year 7. Name:

Styrteknik: Binära tal, talsystem och koder D3:1

Webbreg öppen: 26/ /

Support Manual HoistLocatel Electronic Locks

(D1.1) 1. (3p) Bestäm ekvationer i ett xyz-koordinatsystem för planet som innehåller punkterna

Kurskod: TAMS28 MATEMATISK STATISTIK Provkod: TEN1 05 June 2017, 14:00-18:00. English Version

8 < x 1 + x 2 x 3 = 1, x 1 +2x 2 + x 4 = 0, x 1 +2x 3 + x 4 = 2. x 1 2x 12 1A är inverterbar, och bestäm i så fall dess invers.

Övning 3 - Tillämpad datalogi 2012

Kurskod: TAMS11 Provkod: TENB 28 August 2014, 08:00-12:00. English Version

F ξ (x) = f(y, x)dydx = 1. We say that a random variable ξ has a distribution F (x), if. F (x) =

1. (3p) Bestäm den minsta positiva resten vid division av talet med talet 31.

Preschool Kindergarten

Module 6: Integrals and applications

Algoritmer, datastrukturer och komplexitet

Resultat av den utökade första planeringsövningen inför RRC september 2005

Tentamen i Matematik 3: M0031M.

Discrete Mathematics (English)

Writing with context. Att skriva med sammanhang

Högskolan i Skövde (SK, JS) Svensk version Tentamen i matematik

MVE500, TKSAM Avgör om följande serier är divergenta eller konvergenta. Om konvergent, beräkna summan. (6p) ( 1) n x 2n+1 (a)

FÖRBERED UNDERLAG FÖR BEDÖMNING SÅ HÄR

1. Varje bevissteg ska motiveras formellt (informella bevis ger 0 poang)

Discovering!!!!! Swedish ÅÄÖ. EPISODE 6 Norrlänningar and numbers Misi.se

Kvalitetsarbete I Landstinget i Kalmar län. 24 oktober 2007 Eva Arvidsson


Quicksort. Koffman & Wolfgang kapitel 8, avsnitt 9

Kurskod: TAIU06 MATEMATISK STATISTIK Provkod: TENA 17 August 2015, 8:00-12:00. English Version

E: 9p D: 10p C: 14p B: 18p A: 22p

Information technology Open Document Format for Office Applications (OpenDocument) v1.0 (ISO/IEC 26300:2006, IDT) SWEDISH STANDARDS INSTITUTE

Rastercell. Digital Rastrering. AM & FM Raster. Rastercell. AM & FM Raster. Sasan Gooran (VT 2007) Rastrering. Rastercell. Konventionellt, AM

Tentamen i Matematik 2: M0030M.

x 2 2(x + 2), f(x) = by utilizing the guidance given by asymptotes and stationary points. γ : 8xy x 2 y 3 = 12 x + 3

Lösningar till tentan i SF1861/51 Optimeringslära, 3 juni, 2015

Övning 5 ETS052 Datorkommuniktion Routing och Networking

Beijer Electronics AB 2000, MA00336A,

F11. Läsanvisning: kap 10 + dessa OH. Kruskals algoritm kortaste vägar en till alla

Kurskod: TAMS11 Provkod: TENB 07 April 2015, 14:00-18:00. English Version

Isolda Purchase - EDI

Lösenordsportalen Hosted by UNIT4 For instructions in English, see further down in this document

Föreläsning 12+13: Approximationsalgoritmer

Provlektion Just Stuff B Textbook Just Stuff B Workbook

samhälle Susanna Öhman

Viktig information för transmittrar med option /A1 Gold-Plated Diaphragm

Problem som kan uppkomma vid registrering av ansökan

Boiler with heatpump / Värmepumpsberedare

Föreläsning 7+8: NP-problem. Begreppet effektiv algoritm är alltså synonymt med går i polynomisk tid i den här kursen. Är detta en rimlig uppdelning?

Par m 328 feet. Lång höger sväng. Korgen står placerad i en skogsglänta OB-linje på vänster sida.

COMPUTABILITY BERÄKNINGSBARHET. Källa: Goldschlager, Lister: Computer Science A Modern Introduction 2. upplaga 1988, Prentice Hall

Hjälpmedel: Inga, inte ens miniräknare Göteborgs Universitet Datum: 2018 kl Telefonvakt: Jonatan Kallus Telefon: ankn 5325

LUNDS TEKNISKA HÖGSKOLA Inst. for Elektro- och Informationsteknik. SIGNALBEHANDLING I MULTIMEDIA, ETI265 Inlämningsuppgift 1 (av 2), Task 1 (out of 2)

Vässa kraven och förbättra samarbetet med hjälp av Behaviour Driven Development Anna Fallqvist Eriksson

FORTA M315. Installation. 218 mm.

and u = och x + y z 2w = 3 (a) Finn alla lösningar till ekvationssystemet

SAMMANFATTNING AV SUMMARY OF

2.1 Installation of driver using Internet Installation of driver from disk... 3

2(x + 1) x f(x) = 3. Find the area of the surface generated by rotating the curve. y = x 3, 0 x 1,

Adding active and blended learning to an introductory mechanics course

Grafisk teknik IMCDP IMCDP IMCDP. IMCDP(filter) Sasan Gooran (HT 2006) Assumptions:

Föreläsning 8+9: NP-problem. Begreppet effektiv algoritm är alltså synonymt med går i polynomisk tid i den här kursen. Är detta en rimlig uppdelning?

Collaborative Product Development:

1 Find the area of the triangle with vertices A = (0,0,1), B = (1,1,0) and C = (2,2,2). (6p)

Föreläsning Datastrukturer (DAT037)

NO NEWS ON MATRIX MULTIPLICATION. Manuel Kauers Institute for Algebra JKU

Make a speech. How to make the perfect speech. söndag 6 oktober 13

Hemuppgifter till fredagen den 16 september Exercises to Friday, September 16

Calculate check digits according to the modulus-11 method

Välkommen in på min hemsida. Som företagsnamnet antyder så sysslar jag med teknisk design och konstruktion i 3D cad.

Grafisk teknik IMCDP. Sasan Gooran (HT 2006) Assumptions:

Föreläsning 10. Grafer, Dijkstra och Prim

Protokoll Föreningsutskottet

Health café. Self help groups. Learning café. Focus on support to people with chronic diseases and their families

How to format the different elements of a page in the CMS :

SF2715 Applied Combinatorics Notes and Exercises, Part IV

Algoritmer, datastrukturer och komplexitet

2 Uppgifter. Uppgifter. Svaren börjar på sidan 35. Uppgift 1. Steg 1. Problem 1 : 2. Problem 1 : 3

Rep MEK föreläsning 2

Chapter 1 : Who do you think you are?

Mönster. Ulf Cederling Växjö University Slide 1

LÄNKHJUL S3. Monteringsanvisning för: Länkhjul S3

Grafisk teknik. Sasan Gooran (HT 2006)

Transkript:

Algoritmer och Komplexitet ht 08. Övning 6 NP-problem Frekvensallokering Inom mobiltelefonin behöver man lösa frekvensallokeringsproblemet som lyder på följande sätt. Det finns ett antal sändare utplacerade. Varje sändare kan sända på någon av en given uppsättning frekvenser. Olika sändare kan ha olika frekvensuppsättningar. Vissa sändare är så nära varandra att dom inte kan sända på samma frekvens, för då skulle dom störa varandra. (Detta beror faktiskt inte så mycket på avståndet som på geografin om det finns något berg, hus eller liknande som skärmar av.) Man vet från början vilka sändare som finns, vilken frekvensuppsättning varje sändare har och vilka par av sändare som skulle störa varandra om dom sände på samma frekvens. Problemet är att avgöra ifall det finns något möjligt val av frekvenser så att inte någon sändare stör någon annan. Formulera detta problem som ett grafproblem och visa att det är NP-fullständigt! Hamiltonsk stig i graf Visa att problemet Hamiltonian Path är NP-fullständigt. Problemet är att avgöra ifall det finns någon enkel stig som passerar alla hörn i en graf. Spännande träd med begränsat gradtal Visa att följande problem är NP-fullständigt: Givet en oriktad graf G =(V,E) och ett heltal k, avgör ifall G innehåller ett spännande träd T så att varje hörn i trädet har gradtal högst k. Polynomisk reduktion Konstruera en polynomisk reduktion av Cnf-sat till Eq-gf[], satisfierbarhetsproblemet för ett system av polynomekvationer över GF[] (alltså heltal modulo ). Är en Eulergraf k-färgbar? Många problem av typen avgör om grafen G har egenskapen e kan eventuellt förenklas om vi antar att grafen har någon speciell annan egenskap. Vi ska studera ett specialfall. Vi säger att en sammanhängande graf är en Eulergraf om varje hörn i grafen har jämn grad. Vi vill nu avgöra om en sådan graf är k-färgbar. Vi har närmare bestämt följande problem: Indata: En Eulergraf G och ett heltal k. Utdata: JA om grafen är k-färgbar. NEJ annars. För k finns det en polynomisk algoritm för att avgöra färgbarhet.vi antar därför att k. Avgör nu om det finns en polynomisk algoritm för att lösa ovanstående problem eller om problemet är NP-fullständigt.

Lösningar Lösningar Lösning till Frekvensallokering a) Formulera frekvensallokeringsproblemet som ett grafproblem. Låt hörnen motsvara sändare och kanter motsvara sändare som stör varandra. Varje hörn v i är märkt med en frekvensuppsättning F i. Frågan är om det går tilldela varje hörn en frekvens från dess frekvensuppsättning så att inga hörn som är förbundna med en kant har samma frekvens. b) Visa att frekvensallokeringsproblemet ligger i NP. Gissa (ickedeterministiskt) en frekvenstilldelning. Gå igenom varje hörn och verifiera att dess frekvens är med i frekvensuppsättningen. Gå också igenom varje kant och verifiera att ändpunkternas frekvenser är olika. Detta tar linjär tid i grafens storlek. c) Visa att frekvensallokeringsproblemet är NP-svårt. Reducera k-färgningsproblemet till frekvensallokering: k-färgning(g, k)= för varje hörn v i igrafeng F i {,...,k} return frekvensallokering(g, {F i }) Visa nu att det finns en k-färgning av grafen G om och endast om det finns en tillåten frekvenstilldelning till G där alla hörn har frekvensuppsättningen {,...,k}. Anta att vi har en k-färgning av G. Numrera färgerna till k. Om ett hörn har fått färg i så låter vi motsvarande hörn (sändare) i frekvensallokeringsproblemet få frekvensen i. Detta blir en tillåten frekvenstilldelning eftersom vi har utgått från en tillåten k-färgning. Åt andra hållet: anta att vi har en tillåten frekvenstilldelning. Vi får en k-färgning genom att låta ett hörn få färg i om motsvarande sändare har fått frekvens i. Solution to Hamiltonsk stig i graf A Hamiltonian path is a simple open path that contains each vertex in a graph exactly once. The Hamiltonian Path problem is the problem to determine whether a given graph contains a Hamiltonian path. To show that this problem is NP-complete we first need to show that it actually belongs to the class NP and then find a known NP-complete problem that can be reduced to Hamiltonian Path. For a given graph G we can solve Hamiltonian Path by nondeterministically choosing edges from G that are to be included in the path. Then we traverse the path and make sure that we visit each vertex exactly once. This obviously can be done in polynomial time, and hence, the problem belongs to NP. Now we have to find an NP-complete problem that can be reduced to Hamiltonian Path. A closely related problem is the problem to determine whether a graph contains a Hamiltonian cycle, that is, a Hamiltonian path that begin and end in the same vertex. Moreover, we know that

Hamiltonian Cycle is NP-complete, so we may try to reduce this problem to Hamiltonian Path. Given a graph G = V,E we construct a graph G such that G contains a Hamiltonian cycle if and only if G contains a Hamiltonian path. This is done by choosing an arbitrary vertex u in G and adding a copy, u, of it together with all its edges. Then add vertices v and v to the graph and connect v with u and v with u ; see Figure for an example. v v 6 6 G G Figur : En graf G och hamiltonstigsreduktionens konstruerade graf G. Suppose first that G contains a Hamiltonian cycle. Then we get a Hamiltonian path in G if we start in v, follow the cycle that we got from G back to u instead of u and finally end in v. For example, consider the left graph, G, in Figure which contains the Hamiltonian cycle,,, 6,,,. InG this corresponds to the path v,,,, 6,,,,v. Conversely, suppose G contains a Hamiltonian path. In that case, the path must necessarily have endpoints in v and v. This path can be transformed to a cycle in G. Namely, if we disregard v and v, the path must have endpoints in u and u and if we remove u we get a cycle in G if we close the path back to u instead of u. The construction won t work when G is a single edge, so this has to be taken care of as a special case. Hence, we have shown that G contains a Hamiltonian cycle if and only if G contains a Hamiltonian path, which concludes the proof that Hamiltonian Path is NP-complete. Solution to Spännande träd med begränsat gradtal First note that the problem can be solved by the following nondeterministic algorithm:. For each edge in E, choose nondeterministically if it is to be included in T.. Check that T is a tree and that each vertex has degree less than k. This means that the problem is in NP. Now we need to reduce a problem known to be NP-complete to our spanning tree problem. In this way we can state that determining whether a graph has a k-spanning tree is at least as hard as every other problem in NP. Consider the problem Hamiltonian Path that was shown to be NP-complete in the previous exercise. Can we reduce this problem to the spanning tree problem? That is, can we solve Hamiltonian Path if we know how to solve the spanning tree problem? We claim that we can and that G has a Hamiltonian path if and only if it has a spanning tree with vertex degree. It is easy to see that such a spanning tree is a Hamiltonian path. Since it has degree it cannot branch and since it is spanning only two vertices can have degree <. So the spanning tree is a Hamiltonian path. If, on the other hand, G contains a Hamiltonian path, this path must be a spanning tree since the path visits every node and a path trivially is a tree.

We have reduced Hamiltonian Path to the spanning tree problem and, therefore, our problem is NP-complete. Solution to Polynomisk reduktion Suppose we have a formula ϕ Cnf-sat, for example ϕ(x,x,x,x )=(x x x ) (x x x ) (x x x ) Reducing Cnf-sat to Eq-gf[] means that, for every formula ϕ, we can create an equation that is solvable if and only if ϕ is satisfiable. Now, ϕ is only satisfiable if every clause can be satisfied simultaneously, so let s start with finding an equation for an arbitrary clause (x y z), where x, y and z are considered as literals rather than variables. For a start, the clause is satisfiable with one of the literals set to true, so in that case the equation x + y + z =is also solved. But this fails if two literals are true! We can fix this by adding three more terms, where one and only one is if two variables are. We get x + y + z + xy + yz + xz = Again, this is not complete. if all variables are set to, it fails. Of course, the solution is to add a term for this case, xyz. Our result is x + y + z + xy + yz + xz + xyz = If one of the literals in the clause happened to be inverted, e.g. we have x instead of x, replace x by ( + x) in the equation. The first clause in the example would be turned into x + x +(+x )+x x + x ( + x )+x ( + x )+x x ( + x )= We are now ready to create an equation from an arbitrary -CNF formula ϕ. For every clause ϕ i in ϕ, create a corresponding equation Q i. Our claim is that this system of equations is solvable if and only if ϕ is satisfiable and we must prove that this is correct. To begin with, we note that ( + x) is a proper way to handle inverses, + = 0 and +0 =, so in the following we will only consider literal values and not variables.. ( ) IfanequationinQ i is satisfiable, then there exists an assignment to the variables such that each left hand expression is summed to. Hence, at least one of the literals is and the corresponding literal in the boolean formula set true would make it s clause satisfied. The equation system Q i being satisfied means that each equation is satisfied and consequently is each clause in ϕ satisfied.. ( ) Whenϕ is satisfied, we have an assignment on the variables such that each clause is satisfied. There are three cases for the clauses, (i) one literal is true, (ii) two literals are true and (iii) three literals are true. By construction, the corresponding equations are all satisfied. Lösning till Är en Eulergraf k-färgbar? Problemet är NP-fullständigt. Det är enkelt att visa att problemet ligger i NP genom att gissa en färgning och verifiera att den är korrekt. För att visa fullständighet reducerar vi det generella k-färgningsproblemet till vårt problem. Vi antar att k. AntaattviharengrafG. Vi gör om den till en Eulergraf G på följande sätt: Det måste finnas ett jämnt antal hörn med udda grad. Dela in dessa hörn i par. För varje par införs ett nytt hörn. Till detta hörn dras två kanter, en från vart och ett av de gamla hörn som genererat det nya hörnet. Grafen G plus de nya hörnen och kanterna utgör grafen G. Det är lätt att se att G är en Eulergraf.

Vi visar nu att G är k-färgbar G är k-färgbar. Anta att f är en färgning av G, det vill säga att varje hörn x får en färg f(x). Vi definierar då en k-färgning f av G på följande sätt: Om x är ett hörn i G som också tillhör G sätts f (x) =f(x). Omx inte tillhör G så finns det två grannhörn y och z i G. Visätterdåf(x) till någon annan ledig färg än f(y) och f(z). (Detär möjligt att göra det eftersom k.) Implikationen åt andra hållet är trivial.