Part3 Algorithms By example … Overview Shortest Path Knapsack.

Slides:



Advertisements
Similar presentations
and 6.855J Cycle Canceling Algorithm. 2 A minimum cost flow problem , $4 20, $1 20, $2 25, $2 25, $5 20, $6 30, $
Advertisements

Part 1 Overview, introduction, examples What is Operations Research? What is Optimization What is Sequential Decision Making? What is Dynamic Programming?
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.
Introduction to Algorithms
Chapter 4 The Greedy Approach. Minimum Spanning Tree A tree is an acyclic, connected, undirected graph. A spanning tree for a given graph G=, where E.
1 Chapter 9 Dynamic Programming General Problem-Solving strategy Was born in the 1950s (Bellman) Based on successive decomposition Leads to functional.
9.2 Knapsack Problem There are many other versions.
MIT and James Orlin © Dynamic Programming 2 –Review –More examples.
© 5/7/2002 V.S. Subrahmanian1 Knapsack Problem Notes V.S. Subrahmanian University of Maryland.
ASC Program Example Part 3 of Associative Computing Examining the MST code in ASC Primer.
Network Flow Models Chapter 7.
1 1 Slide © 2000 South-Western College Publishing/ITP Slides Prepared by JOHN LOUCKS.
Introduction to Management Science
NetworkModel-1 Network Optimization Models. NetworkModel-2 Network Terminology A network consists of a set of nodes and arcs. The arcs may have some flow.
The Simplex algorithm.
7-1 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall Network Flow Models Chapter 7.
Shortest Route, Minimal Spanning Tree and Maximal Flow Models
Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm.
Operations Research Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD4207 University of Palestine.
and 6.855J The Capacity Scaling Algorithm.
1 Network Optimization Chapter 3 Shortest Path Problems.
Transportation Problem
Recursion and Dynamic Programming. Recursive thinking… Recursion is a method where the solution to a problem depends on solutions to smaller instances.
Dynamic Programming Sequence of decisions. Problem state. Principle of optimality. Dynamic Programming Recurrence Equations. Solution of recurrence equations.
1 1 Slide © 2000 South-Western College Publishing/ITP Slides Prepared by JOHN LOUCKS.
Exact methods for ALB ALB problem can be considered as a shortest path problem The complete graph need not be developed since one can stop as soon as in.
CSC401: Analysis of Algorithms CSC401 – Analysis of Algorithms Chapter Dynamic Programming Objectives: Present the Dynamic Programming paradigm.
Stevenson and Ozgur First Edition Introduction to Management Science with Spreadsheets McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies,
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
Greedy Algorithms. What is “Greedy Algorithm” Optimization problem usually goes through a sequence of steps A greedy algorithm makes the choice looks.
1 Branch and Bound Searching Strategies Updated: 12/27/2010.
1 Network Models Transportation Problem (TP) Distributing any commodity from any group of supply centers, called sources, to any group of receiving.
CS 3343: Analysis of Algorithms Lecture 18: More Examples on Dynamic Programming.
1 Dynamic Programming Topic 07 Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information and Computer Technology.
Thursday, May 2 Dynamic Programming – Review – More examples Handouts: Lecture Notes.
CS38 Introduction to Algorithms Lecture 10 May 1, 2014.
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
Dynamic Programming … Continued 0-1 Knapsack Problem.
Dijkstra animation. Dijksta’s Algorithm (Shortest Path Between 2 Nodes) 2 Phases:initialization;iteration Initialization: 1. Included:(Boolean) 2. Distance:(Weight)
Dynamic Programming … Continued
Minimum Cost Flow Algorithms and Networks. Algorithms and Networks: Minimum Cost Flow2 This lecture The minimum cost flow problem: statement and applications.
1 1 Slide © 2005 Thomson/South-Western Chapter 9 Network Models n Shortest-Route Problem n Minimal Spanning Tree Problem n Maximal Flow Problem.
Cycle Canceling Algorithm
St. Edward’s University
Shortest Path from G to C Using Dijkstra’s Algorithm
CS 3343: Analysis of Algorithms
Network Simplex Animations
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Design & Analysis of Algorithm Greedy Algorithm
Various Graph Algorithms
Greedy Method     Greedy Matching     Coin Changing     Minimum Spanning Tree     Fractional Knapsack     Dijkstra's Single-Source Shortest-Path.
Unit-5 Dynamic Programming
Dynamic Programming General Idea
Course Contents: T1 Greedy Algorithm Divide & Conquer
MCA 301: Design and Analysis of Algorithms
Introduction to Minimum Cost Flows
Dynamic Programming Dynamic Programming 1/15/ :41 PM
Network Models 7-1.
Branch and Bound Searching Strategies
Advanced Computer Networks
Dynamic Programming General Idea
Chapter 6 Network Flow Models.
Advanced LP models column generation.
Lecture 6 Greedy Algorithms
The Theory of NP-Completeness
Network Simplex Animations
Dynamic Programming Sequence of decisions. Problem state.
Shortest Path Solutions
Dynamic Programming Sequence of decisions. Problem state.
Maximum Flow Problems in 2005.
Presentation transcript:

Part3 Algorithms By example … Overview Shortest Path Knapsack

Overview Major Approaches Recursive (eg. Tower of Hanoi) Non-recursive (eg. Shortest path example) Successive Approximation (time permitting) Variations on a theme...

Non-Recursive There is an easy modified problem. The functional equation can be solved in a well defined order starting with the easy problem. Classical example: shortest path problem with no cycles.

P(j):= set of immediate predecessors of node j. A very simple example f(j):= shortest distance from node 1 to node j.

(0) (3) (2) x x (6) x (10) x (9) x x (15) x

Recovery of Optimal Path(s) Go along marked arcs from the destination to the origin

(0) (3) (2) x x (6) x (10) x (9) x x (15) x O O O O O O There are two optimal paths: P (1) = (1,2,4,5,7) P (2) = (1,3,4,5,7)

Another Famous Example Unbounded Knapsack problem n piles (j=1,2,3,…,n) Infinitely many identical items on each pile (weight = w j, value = v j ) Total capacity (weight) of knapsack is W. Objective: Maximize total value

Functional Equation Let, f(c):= maximum value of a knapsack of capacity c, c=0,1,2,..W. Then clearly

Functional Equation We shall organise the workout as a table with three columns: X(c):= Set of optimal solutions obtained when solving for f(c). We shall solve f(c) for c=0,1,2,…,W - in this order.

(naïve) Example Note that c*=3.

Workout Note c*=3

Etc, etc, etc

Using the values of f(c) that we have already computed, we obtain Hence, f(W)=f(11)=17.

Recovery Use the sets X(c) to recover an optimal solution to the original problem, starting from c=W and using a counter x to count how many items from each pile have been selected. Initially set x=(0,0,0,0).

Soooooooo …. Initialise: C=W=11, x=(0,0,0,0) Iterate: X(W)={2,3} so we (arbitrarily) select an item from pile 2. This yields, x=(0,1,0,0) and c=c- w 1 =11-7=4. X(4)={3} so we select an item from pile 3. This yields x=(0,1,1,0) and c=c-w 3 =4-4=0. Obviously (since c=0) we stop.

Stopping Rule Stop when c < c*. When we stopped we had x=(0,1,1,0) hence the optimal solution is: select one item from pile 2 and 1 item from pile 3. Are there any other optimal solutions?