De presentatie wordt gedownload. Even geduld aub

De presentatie wordt gedownload. Even geduld aub

1 2 3 4 5 6 7 8 9 5 14 5 13 9 16 8 8 7 12 14 7 3-5 0,1 5,1 13,4 11,1 10,2 17,1 M,0 18,4 26,4 11 25,4 17 3 15 d[1]:=0;  i>1: d[i]:=  ; S:=  ; Repeat.

Verwante presentaties


Presentatie over: "1 2 3 4 5 6 7 8 9 5 14 5 13 9 16 8 8 7 12 14 7 3-5 0,1 5,1 13,4 11,1 10,2 17,1 M,0 18,4 26,4 11 25,4 17 3 15 d[1]:=0;  i>1: d[i]:=  ; S:=  ; Repeat."— Transcript van de presentatie:

1 ,1 5,1 13,4 11,1 10,2 17,1 M,0 18,4 26, , d[1]:=0;  i>1: d[i]:=  ; S:=  ; Repeat u:=argmin{d[i]|i  N\S}, S:=S  {u}  i  N\S: d[i]:=min{d[i],d[u]+c[u,i]} until S=N No! Better now Bellman-Ford: Shortest path with negative arc-costs allowed. Dijkstra?

2 Search(s: node); inputA(i)’s of a (di)graph (N,A) [1]; node-labels pr(i)  N; integer k(=0);[1] output for j in component of s an s-j path for all (i,j)  A(i) with pr(j)=0 do pr(j):=i; put j on LIST; end; [1][1] if (N,A) is undirected then for any edge (i,j): (i,j)  A(i) and (j,i)  A(j) begin  i  N: pr(i):=0; pr(s):=s; LIST:= ; while LIST   do remove the first node from LIST, say i; k:=k+1; /* just counting the number of list-removals/scannings  i  N: pr(i)=0; compNr:=0; for all s  N with pr(s)=0 do compNr:=compNr+1, Search(s) ;

3 reNumbering inputA(i)’s of acyclic digraph (N,A); node-labels nr(i), indgr(i)  Z; integer k(=0); output topological numbering s.t. nr(i)

4 Search(s: node) inputA(i)’s of a (di)graph G=(N,A); labels pr(i)  N  {0}; output for j in component of s an s-j path for all (i,j)  A(i) with pr(j)=0 do pr(j):=i; put j on LIST; end; begin  i  N: pr(i):=0; pr(s):=s; LIST:= ; while LIST   do remove a node from LIST, say i;

5 BreadthFirst(s: node); /* scan first nodes first: fifo list management inputA(i)’s of a (di)graph G=(N,A); labels pr(i)  N  {0}, d(i)  Z  0 ; output for j in component of s an arc-minimal s-j path with d(j) arcs for all (i,j)  A(i) with d(j)=  do pr(j):=i, d(j):=d(i)+1; put j last on LIST; end; begin  i  N: pr(i):=0, d(i):=  ; pr(s):=s; LIST:= ; d(s):=0; while LIST   do remove the first node from LIST, say i;

6 Dijkstra(s: node); /* scan 'best' nodes first inputA(i)’s of a (di)graph G=(N,A); labels pr(i)  N  {0}, d(i)  Z  0 ; output for j in component of s a minimal-cost s-j path of cost d(j) for all (i,j)  A(i) with d(j)>d(i)+c(i,j) do pr(j):=i, d(j):=d(i)+c(i,j) put j on LIST (if not yet in) end; begin  i  N: pr(i):=0, d(i):=  ; pr(s):=s; LIST:= ; d(s):=0; while LIST   do remove the best node from LIST, say i with minimal d(i);

7 Stel algoritme A lost op: yes-no versies TSP <=k in complexiteit t A (n) Þer is algoritme B voor TSP opt in complexiteit t B (n)= log(nC) · t A (n) algoritme B */ past bisectie toe met A U:=nC; */ C=max {c ij | (i,j) in E} L:=0; */ U is boven- en L is ondergrens op z* Repeat k:=(U+L)/2; if algoritme A op TSP <=k returns YES then U:=k else L:=k ; /* opnieuw geldt: U is boven- en L is ondergrens op z* en het interval [L,U] is gehalveerd ! Until |U-L|< 1; Complexiteitstheorie: YES\NO recognition problems TSP >=k Instance: netwerk (N,E,c) met c:E  Z + ; getal k Question:Is er een tour met lengte < k?

8 Voorbeelden YES\NO recognition problems Graph-Connectedness Instance: graph G=(V, E) Question:Is G connected? Satisfiability (informeel) Instance:Boolean expression Question: Kan deze expressie de waarde ‘true’ aannemen (is it satisfiable) LP Instance: (c,A,b) resp. n-vector, mxn matrix en m-vector; getal k Question:Is max{cx| x  R n met Ax k? Langste Pad Instance: netwerk (N,E,c) met c:E  Z + ; s,t  N; getal k Question:Is er een s-t pad P met lengte > k? Graph-Isomorfisme (informeel) Instance: graphs G 1 =(V 1, E 1 ) en G 2 =(V 1, E 1 ) Question:Zijn G 1 en G 2 hetzelfde? ILP ZnZn

9 Graph-Connectedness Instance: graph G=(V, E) Question:Is G connected? MST Instance: graph G=(V, E,c); number k; Question:Is there a tree T spanning V of total weight <=k? Steiner tree Instance: graph G=(V, E,c); subset of nodes K; number k; Question:Is there a tree spanning K of length <=k? UFL Instance: clients i=1,…,m with unit demand, facilities j=1,…n with one-time fixed charge opening costs f j ; costs c ij for delivering the unit of i from j; number k; Question: Can we satisfy all demands at a total cost <=k?

10 DEFINITIONS the time complexity (function) t A of algorithm A for problem P is t A (n)= max {#operaties of A on instance I | over I  P with |I|=n} P is polynomial solvable - notation P   - if  algorithm A with t A (n) of O(n q ) for some q  Z + P is non-deterministically polynomial solvable -notation P   - if all I  P with answer YES have a ‘  -certificate’, checkable in polytime EXAMPLES    (if P is polynomial solvable then P is in  ) TSP   : Instance: network (N,E,c) with number k  R Question:  tour of length <=k? a  -certificate is a set of n edges; polytime checkable: tour of length <= k coTSP   ?! Instance: netwerk (N,E,c) with number k  R Question: Are all tours of length > k? no  -certificate?!

11 TSP >=k Instance: netwerk (N,E,c) met c:E  Z + ; getal k Question:Is er een tour met lengte < k? TSP Instance: netwerk (N,E,c) met c:E  Z + ; getal k Question:Is er een tour met lengte < k? ShortestPath Instance: netwerk (N,E,c) met c:E  Z + ; s,t  N ; getal k Question:Is er een s-t path van lengte < k?

12 M +c ij -M 9'' -M +16 Kortste9-9'' padbevatn kanten-als mogelijk- voor lengte-nM+ I heeft TSP tour <= 63 desda I' heeft kortste 9-9'' pad <= -9M+63 Transformatie-afbeelding van I  TSP naar I':=  (I)  Kortste Pad - 1)Neem(N',E')=(N,E) met extrakopien' van n (dezelfde kantenalsn); 2) c'verlaagt alle kantkostenmet M 3) s=n en t=n'' 4) k'=-nM+k tourlengte +3

13 probleem P 1 is reduceerbaar tot P 2 als  afbeelding  :P 1  P 2 zo dat: I yes-instantie van P 1   (I) yes-instantie van P 2 als ook:  polytime-algoritme, zeg A , met inputs I  P 1 en outputs  (I)  P 2 dan P 1 is 'polynomial ‑ reducable' tot P 2, notatie: P 1  P 2 Theorem Cook (1971): SAT is  -compleet, i.e.: each problem P of  is polynomial reducable to SAT Corollary If SAT can be solved by some polynomial algorithm A, then all problems P   are polynomial solvable (  =  ) Proof: IPIP  P (I)  SAT A  P O(| | r ) alg. A O(| | q ) yes/no algoritme in O(|I| qr ) time voor I in P: doe eerst A  P /* geeft I' in SAT van size O(| | r ) doe dan A


Download ppt "1 2 3 4 5 6 7 8 9 5 14 5 13 9 16 8 8 7 12 14 7 3-5 0,1 5,1 13,4 11,1 10,2 17,1 M,0 18,4 26,4 11 25,4 17 3 15 d[1]:=0;  i>1: d[i]:=  ; S:=  ; Repeat."

Verwante presentaties


Ads door Google