Reducing Knapsack to TSP - PowerPoint PPT Presentation

About This Presentation
Title:

Reducing Knapsack to TSP

Description:

NP hard problems Satisfiability Coloring Exact cover Traveling salesman problem Knapsack Satisfiability to Coloring Satisfiability to Coloring (X1 X2 ... – PowerPoint PPT presentation

Number of Views:164
Avg rating:3.0/5.0
Slides: 23
Provided by: csUefFip
Category:

less

Transcript and Presenter's Notes

Title: Reducing Knapsack to TSP


1
Cooks theorem and NP-reductions
6.11.2016
2
Cooks theorem
Theorem Satisfiability problem (SAT) is
NP-complete Proof
TM p SAT
3
Satisfiability problem
f1
f2
f3
F(X1? X2 ? ?X3) ? (?X1? X2) ? (X1? X3)
x1 x2 x3 f1 f2 f3 F
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
4
Non-deterministic algorithm
Satisfiability(F) FOR i?1 TO n DO xi ?
Choose0,1 IF F(x)1 THEN SUCCESS ELSE FAIL
T(n)O(n) ? SAT ? NP
5
Notations needed
Implication
Equivalence
All are true
Some is true
Exactly one is true
At least oneis true
At most one is true
6
Proof of Cooks theorem
Only valid Turing machine configurations can have
value TRUE
ai tape position s has symbol ai
qj machine is at state qj and R/W head is at
position s
7
Cooks theorem
Machine is at state q0 Tape content is ai1,
ai2, , ain
8
Cooks theorem
If not at position s, then content does not change
If at position s and content is ai, then change
state and content
9
Cooks theorem
Can be in any position s but machine must be in
final state qk
10
NP hard problems
  1. Satisfiability problem (SAT)
  2. Coloring problem (Color)
  3. Exact cover problem (EC)
  4. Knapsack problem (KP)
  5. Traveling salesman problem (TSP)

11
Satisfiability to Coloring
Complete k-clique
False color
c0
Connect to all but ci
Literals
Color for fi
xj
fi
fi
Connect to all but those literals in fi
12
SP to Coloring example
(X1? X2) ? (?X1? X3)
13
Additional example
f1
f2
f3
(X2 ? ?X3) ? (?X1? X3 ) ? (X1 ? ?X2)
x1 x2 x3 f1 f2 f3 F
0 0 0 1 1 1 1
0 0 1 0 1 1 0
0 1 0 1 1 0 0
0 1 1 1 1 0 0
1 0 0 1 0 1 0
1 0 1 0 1 1 0
1 1 0 1 0 1 0
1 1 1 1 1 1 1
14
Knapsack to TSP
15
Knapsack problem
  • Input knapsack instance 2,3,5,7,11
  • Size of the knapsack S15.

16
Step 1 Create one node for every item
  • Input knapsack instance 2,3,5,7,11
  • Create a node for every knapsack element.

2
7
5
3
11
17
Step 2 Add start and end points
  • Add node 0 as the home.
  • Add node n1 as the turning point.

2
7
5
0
n1
3
11
n2 nodes needed to represent the knapsack
instance
18
Step 3 Create forward links
  • Draw links from smaller to bigger with weights
  • w(i,j) j
  • w(i,n1) 0

7
2
7
2
7
7
7
0
5
0
5
5
0
0
n1
0
5
0
11
11
3
11
3
3
11
11
19
Step 4 Create backward links
  • Draw backward links from bigger to smaller nodes.
  • Set weight of the link as w(j,i)0.

0
2
7
0
0
0
0
0
0
0
0
0
5
0
n1
0
0
0
0
0
0
0
3
11
0
20
KP ? TSP
  • All nodes have two incoming links with weights
  • w(i,j) if item j is taken into knapsack (xj1)
  • 0 if item j not is taken (xj0)
  • Visit nodes selected in KP using wgt0 link

0
select
7
0
0
n1
0
5
select
0
select
3
21
KP ? TSP
  • TSP 0-3-5-7-(N1)-11-2-0

??
KP 3,5,7 (all nodes which arrival cost gt 0)
0
select
7
0
0
n1
0
5
select
0
select
3
22
Empty space for notes
Write a Comment
User Comments (0)
About PowerShow.com