MS&E 211 Minimum Cost Flow LP Ashish Goel. Minimum Cost Flow (MCF) Need to ship some good from “supply” nodes to “demand” nodes over a network – Example:

Slides:



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

1 LP, extended maxflow, TRW OR: How to understand Vladimirs most recent work Ramin Zabih Cornell University.
Outline LP formulation of minimal cost flow problem
Lecture 5: Network Flow Algorithms Max-Flow Min-Cut Single-Source Shortest-Path (SSSP) Job Sequencing.
C&O 355 Lecture 23 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A A A A A A A.
Linear Programming (LP) (Chap.29)
Max Flow Problem Given network N=(V,A), two nodes s,t of V, and capacities on the arcs: uij is the capacity on arc (i,j). Find non-negative flow fij for.
Transportation Problem (TP) and Assignment Problem (AP)
Introduction to Algorithms
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
MS&E 211, Lecture 11 The dual of Min-Cost Flow Ashish Goel.
Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm.
Basic Feasible Solutions: Recap MS&E 211. WILL FOLLOW A CELEBRATED INTELLECTUAL TEACHING TRADITION.
Chapter 10: Iterative Improvement The Maximum Flow Problem The Design and Analysis of Algorithms.
1 Maximum Flow Networks Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘capacity’ u ij. Goal: Determine the maximum amount.
Totally Unimodular Matrices Lecture 11: Feb 23 Simplex Algorithm Elliposid Algorithm.
Network Optimization Models: Maximum Flow Problems In this handout: The problem statement Solving by linear programming Augmenting path algorithm.
Computer Algorithms Integer Programming ECE 665 Professor Maciej Ciesielski By DFG.
Linear Programming – Max Flow – Min Cut Orgad Keller.
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.
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 Integrality constraints Integrality constraints are often crucial when modeling optimizayion problems as linear programs. We have seen that if our linear.
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.
Max-flow/min-cut theorem Theorem: For each network with one source and one sink, the maximum flow from the source to the destination is equal to the minimal.
MS&E 211 Lecture 5: Basic Feasible Solutions; Shortest Paths Ashish Goel.
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x.
Lecture 5: Network Flow Algorithms Single-Source Shortest-Path (SSSP) (Dijkstra's Algorithm) Max Flow - Min Cut (Ford-Fulkerson) Job Sequencing.
CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications.
Linear Programming Data Structures and Algorithms A.G. Malamos References: Algorithms, 2006, S. Dasgupta, C. H. Papadimitriou, and U. V. Vazirani Introduction.
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA A A A A A A A A Image:
Chapter 4 Minimum Cost Flow Problems (MCF)
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
1 Network Models Transportation Problem (TP) Distributing any commodity from any group of supply centers, called sources, to any group of receiving.
1 WEEK 11 Graphs III Network Flow Problems A Simple Maximum-Flow Algorithm Izmir University of Economics.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
Lecture 5 – Integration of Network Flow Programming Models Topics Min-cost flow problem (general model) Mathematical formulation and problem characteristics.
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
15.082J & 6.855J & ESD.78J October 7, 2010 Introduction to Maximum Flows.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
CPSC 536N Sparse Approximations Winter 2013 Lecture 1 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAAAA.
8/14/04J. Bard and J. W. Barnes Operations Research Models and Methods Copyright All rights reserved Lecture 5 – Integration of Network Flow Programming.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
Flow in Network. Graph, oriented graph, network A graph G =(V, E) is specified by a non empty set of nodes V and a set of edges E such that each edge.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Data Structures & Algorithms Network Flow Richard Newman based on book by R. Sedgewick.
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
Approximation Algorithms Duality My T. UF.
Tuesday, March 19 The Network Simplex Method for Solving the Minimum Cost Flow Problem Handouts: Lecture Notes Warning: there is a lot to the network.
Minimum Cost Flow Algorithms and Networks. Algorithms and Networks: Minimum Cost Flow2 This lecture The minimum cost flow problem: statement and applications.
Part 3 Linear Programming
Lap Chi Lau we will only use slides 4 to 19
Maximum Flow Chapter 26.
Topics in Algorithms Lap Chi Lau.
The minimum cost flow problem
Algorithms and Networks
Lecture 5 – Integration of Network Flow Programming Models
Part 3 Linear Programming
Instructor: Shengyu Zhang
Introduction to Maximum Flows
Chapter 5 Transportation, Assignment, and Transshipment Problems
Max Flow Problem Given network N=(V,A), two nodes s,t of V, and capacities on the arcs: uij is the capacity on arc (i,j). Find non-negative flow fij for.
Algorithms (2IL15) – Lecture 7
Algorithms and Networks
Part 3 Linear Programming
EMIS The Maximum Flow Problem: Flows and Cuts Updated 6 March 2008
Lecture 12 Network Models.
Presentation transcript:

MS&E 211 Minimum Cost Flow LP Ashish Goel

Minimum Cost Flow (MCF) Need to ship some good from “supply” nodes to “demand” nodes over a network – Example: the good could be crude oil; the network could be a network of pipelines; the supply nodes could be oil fields; the demand nodes could be refineries Assumption: The good is divisible, so we can ship fractional amounts of a good over an edge Fundamental problem: generalizes shortest paths; maximum compatibility matching; max- flow; and several problems we have seen already

Modeling the Network The network is modeled as a directed graph G – V = Set of nodes; E = Set of edges – N = number of nodes; M = number of edges – c(v,w) = cost of edge (v,w) – u(v,w) = capacity of edge (v,w) Capacity of the edge: the maximum amount of flow on the edge

Modeling the Network The network is modeled as a directed graph G – V = Set of nodes; E = Set of edges – N = number of nodes; M = number of edges – c(v,w) = cost of edge (v,w) – u(v,w) = capacity of edge (v,w) Capacity of the edge: the maximum amount of flow on the edge

Modeling the Network The network is modeled as a directed graph G – V = Set of nodes; E = Set of edges – N = number of nodes; M = number of edges – c(v,w) = cost of edge (v,w) – u(v,w) = capacity of edge (v,w) Capacity of the edge: the maximum amount of flow on the edge

Modeling Demands Demand of a node: The amount of the good that a node wants to consume Supply of a node: The amount of the good that a node wants to produce Modeled as a single number, d(v), for node v – d(v) is positive for “demand nodes” – d(v) is negative for “supply nodes” – d(v) = 0 otherwise

The Linear Program CONSERVATION CONSTRAINTS

The Linear Program CAPACITY CONSTRAINTS

Can Demands be Arbitrary? For the problem to be feasible, should the sum of the demands be 1.Strictly Negative? 2.Zero 3.Strictly Positive? 4.Doesn’t matter.

Can Demands be Arbitrary? For the problem to be feasible, should the sum of the demands be 1.Strictly Negative? 2.Zero 3.Strictly Positive? 4.Doesn’t matter.

The Linear Program SUMS TO ZERO, WHEN SUMMED OVER ALL NODES

The Linear Program MUST ALSO SUM TO ZERO, WHEN SUMMED OVER ALL NODES

Reduction to MCF Very powerful tool Suppose we are reducing a problem P to MCF Must specify how to obtain – The graph G (nodes, edges) – Edge capacities u and costs c – Node demands d from the parameters of the given problem P Must specify how the solution x to MCF gives a solution to P

A Simple Reduction Reducing Shortest Paths to MCF – Use the same graph G – Set d(s) = -1, d(t) = 1, d(v) = 0 for all other nodes – Set u(v,w) = 1 for all edges (v,w) (Or, set u(v,w) = ∞ for all edges (v,w)) – The solution x(v,w) to the MCF is also a solution to the shortest path problem Hence, MCF is more general than shortest paths

A Simple Example Every edge has a cost and a capacity, written as (c, u) (6,1) (2,1) (4,1) s t p q r (1,1) (2,1) (3,1) (4,1)

A Simple Example Every node has a demand (6,1) (2,1) (4,1) s t p q r (1,1) (2,1) (3,1) (4,1) d = -1 d = 1 d = 0

A Simple Example Every node has a demand (6, ∞) (2, ∞) (4, ∞) s t p q r (1, ∞) (2, ∞) (3, ∞) (4,∞) d = -1 d = 1 d = 0

Infinite Capacities? Can handle infinite capacity edges by just removing the capacity constraint for those edges For shortest paths – Setting capacity = ∞ guarantees that there will never be an optimum solution if there is a negative cost cycle – Setting capacity = 1 guarantees that there will be an optimum solution if there is a feasible solution

Next Steps Theory: Examine Basic Feasible Solutions Reductions: See two more examples Hands On: Solve the Shortest Path Problem again – Illustrate capacity constraints – A nice trick for generating the constraint matrix A

Minimum Cost Flow – Basic Feasible Solutions Ashish Goel

Main Theorem For an instance of a Minimum Cost Flow Problem, if (a) Every demand is integral and (b) Every capacity is integral then Every Basic Feasible Solution is Integral Very useful, since in many applications (eg. Shortest paths), fractional solutions do not make sense

Proof Sketch 1.Start with any feasible fractional solution 2.Find a cycle of edges (ignoring directions) such that every edge on the cycle has fractional flow 3.Show that along this cycle, flow can be increased a little clockwise, as well as counterclockwise  The original fractional solution was an average of two other feasible solutions, and hence not a BFS

A Simple Example Labels on edges are (costs, capacities) (6,1) (2,1) (4,1) s t p q r (1,1) (2,1) (3,1) (4,1) d = -1 d = 1 d = 0

Step 1: Start With a Fractional Solution Labels on edges are flows s t p q r d = -1 d = 1 d = 0

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Start with an arbitrary fractional edge

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Start with an arbitrary fractional edge

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Since t has integer demand, there must be another edge incident on t with fractional flow

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Since t has integer demand, there must be another edge incident on t with fractional flow

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Use the same argument at r

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Use the same argument at r

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Use the same argument at q

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Use the same argument at q

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Use the same argument at s

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Use the same argument at s

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 We have our cycle

Step 2: Find a Cycle of Fractionally Used Edges Labels on edges are flows s t p q r d = -1 d = 1 d = 0 We have our cycle Strongly used the fact that demands are integer

Step 3: Find Two New Feasible Solutions Labels on edges are flows s t p q r d = -1 d = 1 d = 0 None of the edges on the cycle is at capacity

Step 3: Find Two New Feasible Solutions Labels on edges are flows s t p q r d = -1 d = 1 d = 0 None of the edges on the cycle is at capacity Strongly used the fact that capacities are integer

Step 3: Find Two New Feasible Solutions Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Each edge on the cycle has non- zero flow

Step 3: Find Two New Feasible Solutions Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Each edge on the cycle has non- zero flow Hence, can increase or decrease the flow on each edge

Step 3: Find Two New Feasible Solutions Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Send some flow (say 0.1) “clockwise”

Step 3: Find Two New Feasible Solutions Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Send some flow (say 0.1) “clockwise” Solution A

Step 3: Find Two New Feasible Solutions Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Send some flow (say 0.1) “counter- clockwise”

Step 3: Find Two New Feasible Solutions Labels on edges are flows s t p q r d = -1 d = 1 d = 0 Send some flow (say 0.1) “counter- clockwise” Solution B

Step 3: Find Two New Feasible Solutions Labels on edges are flows s t p q r d = -1 d = 1 d = 0 The average of Solutions A and B gives us the fractional solution we started with

Step 3: Find Two New Feasible Solutions Labels on edges are flows s t p q r d = -1 d = 1 d = 0 The average of Solutions A and B gives us the fractional solution we started with Hence, we did not start with a BFS

While we used a specific example, the proof is completely generalizable for any MCF with integer capacities and demands

Main Theorem For an instance of a Minimum Cost Flow Problem, if (a) Every demand is integral and (b) Every capacity is integral then Every Basic Feasible Solution is Integral Very useful, since in many applications (eg. Shortest paths), fractional solutions do not make sense

Minimum Cost Flow – Two Reductions Ashish Goel

Example: Matching Marry every man to exactly one woman, and vice-versa, while maximizing total compatibility C i,j : Compatibility of man i with woman j COMPATIBILTYHelenGloriaIris Dave100.5 Eddy Frank

Reduction to MCF DAVE EDDY FRANK HELEN GLORIA IRIS

Reduction to MCF DAVE EDDY FRANK HELEN GLORIA IRIS Cost = -compatibility Capacity = 1

Reduction to MCF DAVE EDDY FRANK HELEN GLORIA IRIS Cost = -compatibility Capacity = 1 WHAT SHOULD THE DEMAND OF DAVE BE IN THIS PROBLEM?

Reduction to MCF DAVE EDDY FRANK HELEN GLORIA IRIS Cost = -compatibility Capacity = 1 d = -1

Reduction to MCF DAVE EDDY FRANK HELEN GLORIA IRIS Cost = -compatibility Capacity = 1 d = -1 WHAT SHOULD THE DEMAND OF IRIS BE IN THIS PROBLEM?

Reduction to MCF DAVE EDDY FRANK HELEN GLORIA IRIS Cost = -compatibility Capacity = 1 d = -1 d = +1

Reduction to MCF DAVE EDDY FRANK HELEN GLORIA IRIS Cost = -compatibility Capacity = 1 d = -1 d = +1 x(v,w)  The amount of marriage between man v and woman w

Reduction to MCF DAVE EDDY FRANK HELEN GLORIA IRIS Cost = -compatibility Capacity = ∞ d = -1 d = +1 x(v,w)  The amount of marriage between man v and woman w

Basic Feasible Solutions for Matchings Any BFS for the Maximum Compatibility Matching problem written as a MCF must be an integer – Integer capacities and demands Interesting observation: The LP for the Maximum Compatibility Matching that we saw earlier is exactly the same as the LP for the corresponding MCF

(s,t) Max-Flow Problem Given a directed graph G with capacities (but no costs) on edges Given two special nodes in V: a source s and a terminus t Find the maximum amount of flow that can be sent from s to t

Example Labels on edges represent capacities, not costs Eyeballing: Optimum solution is to send 4 units of flow on top path, and 1 unit on bottom path s t p q r

LP For (s,t) Max Flow

What is the optimum objective function value for this LP on our example graph? s t q r p

LP For (s,t) Max Flow What is the optimum objective function value for this LP on our example graph? Answer: 7  Not correct LP s t q r p

LP For (s,t) Max Flow

Reduction to MCF Start with an instance of the max-flow problem – Graph G with edge capacities – Missing: edge costs; node demands – Set each edge cost to 0, each node demand to 0 Add a new edge from t to s of infinite capacity and cost -1, to obtain an instance of MCF Intuition: MCF solution will try to minimize cost by pushing as much flow as possible from t to s – Since demands are all zero, this flow must travel back from s to t using edges in the original graph G

Example Reduction to MCF Start with max-flow problem: Labels on edges are (capacities) (6) (2) (4) s t p q r (2) (3) (4) (1)

Example Reduction to MCF Make edge costs 0: Labels on edges are (cost, capacity) (0, 6) (0,2) (0,4) s t p q r (0,2) (0,3) (0, 4) (0,1)

Example Reduction to MCF Add demands of 0 (0, 6) (0,2) (0,4) s t p q r (0,2) (0,3) (0, 4) d = 0 (0,1)

Example Reduction to MCF Add new fake edge (0, 6) (0,2) (0,4) s t p q r (0,1) (0,2) (0,3) (0, 4) d = 0 (-1, ∞)

Basic Feasible Solutions If each capacity in the (s,t) max-flow problem is integral, then any BFS to the resulting MCF problem LP is integral

Conclusion MCF is a very powerful class of LPs Reducing another problem to MCF allows us to use the structure of MCF Next: Simplex and Duality!