Network Flow & Linear Programming

Slides:



Advertisements
Similar presentations
Maximum flow Main goals of the lecture:
Advertisements

Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
The Maximum Network Flow Problem. CSE Network Flows.
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
1 The Max Flow Problem. 2 Flow networks Flow networks are the problem instances of the max flow problem. A flow network is given by 1) a directed graph.
1 Optimization Spring 2007 (Third Quarter). 2 Some practical remarks Homepage: Exam: Written, 3 hours. There.
The max flow problem
Maximum Flows Lecture 4: Jan 19. Network transmission Given a directed graph G A source node s A sink node t Goal: To send as much information from s.
Flows sourcesink s t Flows sourcesink edge-weights = capacities.
1 Network Flow & Linear Programming Jeff Edmonds York University COSC 3101 Lecture 5 Optimization Problems Network Flow Def nNetwork Flow Def n Simple.
1 Linear Programming Jeff Edmonds York University COSC 3101 Lecture 5 Def and Hot Dog Example Network Flow Def nNetwork Flow Def n Matrix View of Linear.
Linear Programming – Max Flow – Min Cut Orgad Keller.
Network Flow & Linear Programming Jeff Edmonds York University Adapted from NetworkFlow.ppt.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
1 The Min Cost Flow Problem. 2 Flow Networks with Costs Flow networks with costs are the problem instances of the min cost flow problem. A flow network.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
1 Ford-Fulkerson method Ford-Fulkerson(G) f = 0 while( 9 simple path p from s to t in G f ) f := f + f p output f Runs in time O(|f max | |E|) where f.
1 The Min Cost Flow Problem. 2 The Min Cost Flow problem We want to talk about multi-source, multi-sink flows than just “flows from s to t”. We want to.
Theory of Computing Lecture 13 MAS 714 Hartmut Klauck.
1 Algorithmic Paradigms Jeff Edmonds York University COSC 2011 Lecture 9 Brute Force: Optimazation Problem Greedy Algorithm: Minimal Spanning Tree Dual.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
Algorithm Design and Analysis (ADA)
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
A directed graph G consists of a set V of vertices and a set E of arcs where each arc in E is associated with an ordered pair of vertices from V. V={0,
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method.
1 Network Flow & Linear Programming Jeff Edmonds York University COSC 3101 Lecture 5 Optimization Problems Network Flow Def n Network Flow Def n Simple.
Instructor Neelima Gupta Edited by Divya Gaur(39, MCS '09) Thanks to: Bhavya(9), Deepika(10), Deepika Bisht(11) (MCS '09)
The Maximum Network Flow Problem
Network Flow & Linear Programming Jeff Edmonds York University COSC 6111 Lecture 3 Network Flow Linear Programming.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Network Flow.
The Maximum Network Flow Problem
Max-flow, Min-cut Network flow.
Maximum Flow Chapter 26.
The Steepest Ascent Hill Climbing Algorithm
Finding a Path With Largest Smallest Edge
UNIT II OPTIMISATION ALGORITHMS
CS4234 Optimiz(s)ation Algorithms
Richard Anderson Lecture 23 Network Flow
Algorithms and Networks
Lecture 22 Network Flow, Part 2
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
Network Flow.
Max-flow, Min-cut Network flow.
Network Flow 2016/04/12.
Flow Networks Topics Flow Networks Residual networks
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Flow Networks General Characteristics Applications
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
Network Flow CSE 373 Data Structures.
EE5900 Advanced Embedded System For Smart Infrastructure
Algorithms and Networks
Network Flow.
Lecture 21 Network Flow, Part 1
MAXIMUM flow by Eric Wengert.
Richard Anderson Lecture 22 Network Flow
Lecture 21 Network Flow, Part 1
Maximum Flow Neil Tang 4/8/2008
Lecture 22 Network Flow, Part 2
Network Flow.
Advanced Graph Homer Lee 2013/10/31.
Maximum Flow Problems in 2005.
Presentation transcript:

Network Flow & Linear Programming Grad Algorithms Network Flow & Linear Programming Network Flow Linear Programming Jeff Edmonds York University Lecture 3 COSC 6111

Optimization Problems Ingredients: Instances: The possible inputs to the problem. Solutions for Instance: Each instance has an exponentially large set of solutions. Cost of Solution: Each solution has an easy to compute cost or value. Specification Preconditions: The input is one instance. Postconditions: An valid solution with optimal cost. (minimum or maximum)

Network Flow Instance: A Network is a directed graph G Edges represent pipes that carry flow Each edge <u,v> has a maximum capacity c<u,v> A source node s out of which flow leaves A sink node t into which flow arrives Goal: Max Flow

Network Flow Instance: A Network is a directed graph G Edges represent pipes that carry flow Each edge <u,v> has a maximum capacity c<u,v> A source node s out of which flow leaves A sink node t into which flow arrives

Network Flow For some edges/pipes, it is not clear which direction the flow should go in order to maximize the flow from s to t. Hence we allow flow in both directions.

Network Flow Flow F<u,v> can't exceed capacity c<u,v>. Solution: The amount of flow F<u,v> through each edge. Flow F<u,v> can't exceed capacity c<u,v>. No leaks, no extra flow. For each node v: flow in = flow out u F<u,v> = w F<v,w>

Network Flow - v F<v,s> Goal: Max Flow Value of Solution: Flow from s into the network minus flow from the network back into s. rate(F) = u F<s,u> - v F<v,s> Goal: Max Flow

Min Cut cap(C) = how much can flow from U to V = uU,vV c<u,v> Value Solution C=<U,V>: cap(C) = how much can flow from U to V = uU,vV c<u,v> Goal: Min Cut U V s u v t

Max Flow = Min Cut Prove:  F,C rate(F)  cap(C) Theorem: For all Networks MaxF rate(F) = MinC cap(C) Prove:  F,C rate(F)  cap(C) Prove:  flow F, alg either finds a better flow F or finds cut C such that rate(F) = cap(C) Alg stops with an F and C for which rate(F) = cap(C) F witnesses that the optimal flow can't be less C witnesses that it can't be more. U V u v

Network Flow w Walking c<v,u> F<u,v> c<u,v> Flow Graph Augmentation Graph f<u,v>+w f<u,v>/c<u,v> c<u,v>-F<u,v> u v u v F<u,v>+c<v,u> 0/c<v,u>

Network Flow w Walking c<u,v> F<u,v> c<u,v> Flow Graph Augmentation Graph F<u,v>-w F<u,v>/c<u,v> c<u,v>-F<u,v> u v u v F<u,v>+c<v,u> 0/c<v.u>

Max Flow = Min Cut Given Flow F Construct Augmenting Graph GF Find path P Let w be the max amount flow can increase along path P. Increase flow along path P by w. i.e newF = oldF + w × P

Max Flow = Min Cut Given Flow F Construct Augmenting Graph GF Find path P Let w be the max amount flow can increase along path P. Increase flow along path P by w. i.e newF = oldF + w × P

Max Flow = Min Cut Given Flow F Construct Augmenting Graph GF Find path P using BFS, DFS, or generic search algorithm No path

Max Flow = Min Cut Let Falg be this final flow. Let cut Calg=<U,V>, where U are the nodes reachable from s in the augmented graph and V not. Claim: rate(Falg) = cap(Calg)

An Application: Matching Sam Mary Bob Beth John Sue Fred Ann 3 matches Can we do better? 4 matches Who loves whom. Who should be matched with whom so as many as possible matched and nobody matched twice?

An Application: Matching s t 1 1 u v c<s,u> = 1 Total flow out of u = flow into u  1 Boy u matched to at most one girl. c<v,t> = 1 Total flow into v = flow out of v  1 Girl v matched to at most one boy.

An Application: Matching s t New Flow Flow s t s t Augmentation Graph Augmentation Path Alternates adding edge removing edge Extra edge added

An Application: Matching Sam Mary Bob Beth John Sue Fred Ann 3 matches Can we do better? 4 matches Who loves whom. Who should be matched with whom so as many as possible matched and nobody matched twice?

Hill Climbing Problems: Can our Network Flow Algorithm get stuck in a local maximum? Local Max Global Max No!

Hill Climbing Problems: Running time? If you take small step, could be exponential time.

Network Flow

Network Flow Add flow 1

Network Flow Add flow 1

Hill Climbing Problems: Running time? If each iteration you take the biggest step possible, Alg is poly time in number of nodes and number of bits in capacities. If each iteration you take path with the fewest edges

Taking the biggest step possible

Taking the biggest step possible m = # edges l = # bits to specify capacities. The flow Ft must increase from 0 to up to To be poly time, we could have Ft double each iteration. But it does not  m2l FT = m2l T = log(m) + l F0 = 0

Taking the biggest step possible Rt = How much the flow can increase by = MaxFlow - Ft To be poly time, we could have Rt half each iteration. Or decrease by a (1-1/m) factor RT = 0 R0 = m2l = 0

Taking the biggest step possible Rt = How much the flow can increase by = MaxFlow - Ft Choose any cut C = U,V. Rt ≤ eC augmente s t U V u v

Taking the biggest step possible Let wt = amount Ft increases = the min augment in augmenting path Let Cut = U,V where nodes uU are reachable from s with edges with augment amount > wt, i.e. the last graph in previous algorithm for which s is not reachable from t. eC augmente ≤ eC wt ≤ m wt (where m = # edges in graph) s t U V u v

Taking the biggest step possible Rt = MaxFlow – Ft ≤ eC augmente ≤ m wt ≤ m  amount Ft increases ≤ m  amount Rt decreases Rt+1 = Rt - amount Rt decreases ≤ Rt – 1/m Rt = (1– 1/m) Rt Decreasing by an mth! Does this stop after m iterations? No because as decreases, the decrease decreases.

Taking the biggest step possible Rt = How much the flow can increase by = MaxFlow - Ft To be poly time, we could have Rt decrease by a (1-1/m) factor each iteration Rt+1 ≤ (1– 1/m) Rt RT = 0 End game: 1/2, 1/4, 1/8, 1/16, …. ? All flows are integers. Hence, decreasing RT < 1 is good enough. R0 = m2l = 0

Taking the biggest step possible Rt+1 ≤ (1– 1/m) Rt RT ≤ (1– 1/m)T R0 < 1

Taking the biggest step possible (1– 1/m)T R0 < 1 (e-1/m)T R0

Taking the biggest step possible (1– 1/m)T R0 < 1 (e-1/m)T R0 (e-T/m) R0 -T/m + ln(R0) = ln(1) = 0 T = m ln(R0) = m ln(m2l) = m (l + ln m) m = # edges l = # bits to specify capacities.

Linear Programming

A Hotdog A combination of pork, grain, and sawdust, … Constraints: Amount of moisture Amount of protein, …

The Hotdog Problem Given today’s prices, what is a fast algorithm to find the cheapest hotdog?

There are deep ideas within the simplicity. Abstraction There are deep ideas within the simplicity. = Goal: Understand and think about complex things in simple ways. There are deep ideas within the simplicity. Rudich www.discretemath.com

Abstract Out Essential Details Amount to add: x1, x2, x3, x4 pork grain water sawdust Cost: 29, 8, 1, 2 29x1 + 8x2 + 1x3 + 2x4 Cost of Hotdog: 3x1 + 4x2 – 7x3 + 8x4 ³ 12 2x1 - 8x2 + 4x3 - 3x4 ³ 24 -8x1 + 2x2 – 3x3 - 9x4 ³ 8 x1 + 2x2 + 9x3 - 3x4 ³ 31 Constraints: moisture protean, …

Abstract Out Essential Details Minimize: 29x1 + 8x2 + 1x3 + 2x4 Subject to: 3x1 + 4x2 – 7x3 + 8x4 ³ 12 2x1 - 8x2 + 4x3 - 3x4 ³ 24 -8x1 + 2x2 – 3x3 - 9x4 ³ 8 x1 + 2x2 + 9x3 - 3x4 ³ 31

A Fast Algorithm For decades people thought that there was no fast algorithm. » Then one was found! 3x1 + 4x2 – 7x3 + 8x4 ³ 12 2x1 - 8x2 + 4x3 - 3x4 ³ 24 -8x1 + 2x2 – 3x3 - 9x4 ³ 8 x1 + 2x2 + 9x3 - 3x4 ³ 31 29x1 + 8x2 + 1x3 + 2x4 Subject to: Minimize: Theoretical Computer Science finds new algorithms every day.

Dual Primal

End