Reducing Knapsack to TSP Pasi Fränti. Knapsack problem Input: knapsack instance {2,3,5,7,11} Size of the knapsack S=15.

Slides:



Advertisements
Similar presentations
Knapsack Problem Section 7.6. Problem Suppose we have n items U={u 1,..u n }, that we would like to insert into a knapsack of size C. Each item u i has.
Advertisements

O(N 1.5 ) divide-and-conquer technique for Minimum Spanning Tree problem Step 1: Divide the graph into  N sub-graph by clustering. Step 2: Solve each.
1.1 Data Structure and Algorithm Lecture 6 Greedy Algorithm Topics Reference: Introduction to Algorithm by Cormen Chapter 17: Greedy Algorithm.
Greedy Algorithms Pasi Fränti Greedy algorithm 1.Coin problem 2.Minimum spanning tree 3.Generalized knapsack problem 4.Traveling salesman problem.
Converting between metric weight units. Converting metric weights How many mg to 1 g? How many g to 1 kg? How many kg to 1 t? 1000 mg = 1 g 1000 g = 1.
The Stagecoach Problem
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Chapter 10 Dynamic Programming. 2 Agenda for This Week Dynamic Programming –Definition –Recursive Nature of Computations in DP –Forward and Backward Recursion.
Dave Risch. Project Specifications There is a “knapsack” that you want to fill with the most valuable items that are available to you. Each item has a.
Addition and Subtraction of Integers
Objective How to solve Integer problems
Name: Date: How to Find the Number You Are Skip Counting By 1) Find 2 numbers next to each other. 2) Find the smaller number on the number grid. 3) Hop.
Multiplication Using Manipulatives & Algorithms for Whole-Number Multiplication.
GRASP: A Sampling Meta-Heuristic
Design & Analysis of Algorithms Combinatory optimization SCHOOL OF COMPUTING Pasi Fränti
Chapter 9: Rules and Expert Systems Lora Streeter.
Design of Algorithms using Brute Force Approach. Primality Testing (given number is n binary digits)
Heuristic Optimization Methods Tabu Search: Advanced Topics.
Complementary and Supplementary Angles
Today’s Agenda  Linked Lists  Double ended Linked Lists  Doubly Linked Lists CS2336: Computer Science II.
Dynamic Programming - II. Integer Knapsack Problem
Backtracking Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignments?
Solving Inequalities by adding or subtracting, checking the inequality & graphing it!! This is so easy you won’t even need one of these!!!
Local Search Stuffs In these slides, you will find: –Solution Representation –Local Move/Neighborhood Swap k-Nodes Swap k-Edges –Distance Metric For –Traveling.
Lecture - 11 on Data Structures. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Threaded Trees Binary trees have a lot of wasted space: the leaf nodes each.
Atomic Structure Worksheet
Cook’s theorem and NP-reductions Pasi Fränti
Approximation Algorithms
Learning about Inverse Operations. What is the inverse of Opening the door? Turning Right? Driving Forward? The inverse undoes the original function.
Stage 6: Bee: Functions What do you remember from the last class? What did you like the best? Any questions?
Reducing Knapsack to TSP Professor Pasi Franti. Step 1: Equivalent Graph Construction Given Knapsack instance: –KP={2,3,5,7,11} Draw A node in the plane.
Visit:
MGT 426 Complete Class Solution- NO DQ's To purchase this material click below link 426-Complete-Class-Solution-No-DQs.
IT 210 Week 1 CheckPoint Input Data and Output Process To purchase this material link Input-Data-and-Output-Process.
Brute Force II.
Linked List ADT used to store information in a list
Add and Subtract Negative Numbers
EMIS 8373: Integer Programming
AKA – Input/output tables
Approximation algorithms
Godrej Prakriti Sodepur | Godrej Prakriti Kolkata
Input/Output Tables Please cooperate and take turns with writing on the Smartboard. Go onto the next slide when your group is ready!
The Best Way To Lose Weight Naturally - f9health.com
BACK SOLUTION:
24*7 Help Norton Antivirus Toll-Free Number
Giftalove Best Cake Offers
Approximation Algorithms
Appropriate algorithms for Generalized Maximum Coverage
Approximation Algorithms
Polynomial time approximation scheme
Design & Analysis of Algorithms Combinatorial optimization
Linked List and Selection Sort
Which way does the robot have to turn to get to the charger?
Using a Drawing Robot to Make Angles (Using Rotations)
Brackets: Multiplies to…, adds to… (positive)
Hot Seat Circular Functions.
Lecture 15 Doubly Linked Lists CSE /26/2018.
Cook’s theorem and NP-reductions
Advanced LP models column generation.
Advanced LP models column generation.
Rate of Change The rate of change is the change in y-values over the change in x-values.
Using a Drawing Robot to Make Angles (Using Rotations)
Which is bigger 3 5
Lecture 5 Dynamic Programming
Linked Lists.
Average Atomic Mass.
8 + (-6) = 2 ______ Different Signs Subtract.
Section 1.5 Adding Integers
Visit us:
2 Making Blocks.
Presentation transcript:

Reducing Knapsack to TSP Pasi Fränti

Knapsack problem Input: knapsack instance {2,3,5,7,11} Size of the knapsack S=15.

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

N+2 nodes needed to represent the knapsack instance n+1 Step 2: Add start and end points Input: knapsack instance {2,3,5,7,11} Add node 0 as the home. Add node N+1 as the turning point.

Step 3: Create forward links Input: knapsack instance {2,3,5,7,11} Draw links from smaller nodes to bigger ones. Set weights according to the bigger node: w(i,j)=j n

Step 4: Create forward links for node N n Input: knapsack instance {2,3,5,7,11} Draw links to N+1 with weights w(i,N+1)=0.

n Step 5: Create backward links Input: knapsack instance {2,3,5,7,11} Draw backward links from bigger to smaller nodes. Set weight of the link as w(j,i)=

Solution for KP  Solution for TSP KP = {3,5,7} n  TSP = (N+1) (S=15) Visit the nodes in an increasing order !

Solution for TSP  Solution for KP TSP = (N+1)  KP = {3,5,7} (all nodes which arrival cost > 0) n Select nodes with entrance w>0 ! 3 7 5