Minimum-Cost Flow Math 482, Lecture 28 Misha Lavrov April 10, 2020 - - PowerPoint PPT Presentation

minimum cost flow
SMART_READER_LITE
LIVE PREVIEW

Minimum-Cost Flow Math 482, Lecture 28 Misha Lavrov April 10, 2020 - - PowerPoint PPT Presentation

Introduction Basic solutions Pivoting steps Finding an initial feasible solution Minimum-Cost Flow Math 482, Lecture 28 Misha Lavrov April 10, 2020 Introduction Basic solutions Pivoting steps Finding an initial feasible solution The


slide-1
SLIDE 1

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Minimum-Cost Flow

Math 482, Lecture 28 Misha Lavrov April 10, 2020

slide-2
SLIDE 2

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The min-cost flow problem

In this problem, we are given: a network (N, A) with no source or sink.

slide-3
SLIDE 3

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The min-cost flow problem

In this problem, we are given: a network (N, A) with no source or sink. A demand dk for every node (as in a supply-demand problem).

slide-4
SLIDE 4

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The min-cost flow problem

In this problem, we are given: a network (N, A) with no source or sink. A demand dk for every node (as in a supply-demand problem). Instead of a capacity cij for every arc (i, j) ∈ A, a cost cij.

slide-5
SLIDE 5

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The min-cost flow problem

In this problem, we are given: a network (N, A) with no source or sink. A demand dk for every node (as in a supply-demand problem). Instead of a capacity cij for every arc (i, j) ∈ A, a cost cij. Goal: minimize

(i,j)∈A cijxij while satisfying ∆k(x) = dk for every

node k (and x ≥ 0).

slide-6
SLIDE 6

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The min-cost flow problem

In this problem, we are given: a network (N, A) with no source or sink. A demand dk for every node (as in a supply-demand problem). Instead of a capacity cij for every arc (i, j) ∈ A, a cost cij. Goal: minimize

(i,j)∈A cijxij while satisfying ∆k(x) = dk for every

node k (and x ≥ 0). Example: 1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

$2 $4 $1 $3 $2 $1 $3 $5

slide-7
SLIDE 7

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Plan for solving min-cost flow

Unlike max-flow problems, min-cost flow problems are commonly solved using the simplex method. (There’s fewer constraints, so the basis is smaller.)

slide-8
SLIDE 8

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Plan for solving min-cost flow

Unlike max-flow problems, min-cost flow problems are commonly solved using the simplex method. (There’s fewer constraints, so the basis is smaller.) To figure out how to do this, we need to know several things: What a basic solution looks like.

slide-9
SLIDE 9

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Plan for solving min-cost flow

Unlike max-flow problems, min-cost flow problems are commonly solved using the simplex method. (There’s fewer constraints, so the basis is smaller.) To figure out how to do this, we need to know several things: What a basic solution looks like. How to do a pivoting step.

slide-10
SLIDE 10

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Plan for solving min-cost flow

Unlike max-flow problems, min-cost flow problems are commonly solved using the simplex method. (There’s fewer constraints, so the basis is smaller.) To figure out how to do this, we need to know several things: What a basic solution looks like. How to do a pivoting step. How to determine the reduced costs of an arc.

slide-11
SLIDE 11

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Number of basic variables

Our constraints are: Fx = d, where F is a |N| × |A| matrix where xij’s column has a 1 in row j and a −1 in row i. d is the vector of demands.

slide-12
SLIDE 12

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Number of basic variables

Our constraints are: Fx = d, where F is a |N| × |A| matrix where xij’s column has a 1 in row j and a −1 in row i. d is the vector of demands. Normally, a basic solution would be given by x = F −1

B d for some

choice of |N| variables B.

slide-13
SLIDE 13

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Number of basic variables

Our constraints are: Fx = d, where F is a |N| × |A| matrix where xij’s column has a 1 in row j and a −1 in row i. d is the vector of demands. Normally, a basic solution would be given by x = F −1

B d for some

choice of |N| variables B. Here, one equation is redundant: assuming

k∈N dk = 0, the

equations add up to 0 = 0. (If the sum is not 0, there is no solution.)

slide-14
SLIDE 14

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Number of basic variables

Our constraints are: Fx = d, where F is a |N| × |A| matrix where xij’s column has a 1 in row j and a −1 in row i. d is the vector of demands. Normally, a basic solution would be given by x = F −1

B d for some

choice of |N| variables B. Here, one equation is redundant: assuming

k∈N dk = 0, the

equations add up to 0 = 0. (If the sum is not 0, there is no solution.) So our basis will have |N| − 1 variables, assuming the network is connected.1

1If there are two or more subnetworks with no arcs between them, we solve

the subproblems separately.

slide-15
SLIDE 15

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Spanning trees

Definition A spanning tree of (N, A) is a choice of |N| − 1 arcs forming a connected subnetwork. (For us, connectivity ignores direction.)

slide-16
SLIDE 16

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Spanning trees

Definition A spanning tree of (N, A) is a choice of |N| − 1 arcs forming a connected subnetwork. (For us, connectivity ignores direction.) 1 2 3 4 5 6 Good 1 2 3 4 5 6 Bad!

slide-17
SLIDE 17

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Spanning trees

Definition A spanning tree of (N, A) is a choice of |N| − 1 arcs forming a connected subnetwork. (For us, connectivity ignores direction.) 1 2 3 4 5 6 Good 1 2 3 4 5 6 Bad! Claim: |N| − 1 variables form a basis exactly when their arcs make a spanning tree.

slide-18
SLIDE 18

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Why spanning trees?

  • Q1. Why is being a spanning tree necessary to be a basis?
slide-19
SLIDE 19

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Why spanning trees?

  • Q1. Why is being a spanning tree necessary to be a basis?
  • A1. If there are two pieces, then not all systems Fx = d with
  • k∈N dk = 0 have solutions. We must have the dk sum to 0 on

each piece!

slide-20
SLIDE 20

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Why spanning trees?

  • Q1. Why is being a spanning tree necessary to be a basis?
  • A1. If there are two pieces, then not all systems Fx = d with
  • k∈N dk = 0 have solutions. We must have the dk sum to 0 on

each piece!

  • Q2. Why is being a spanning tree sufficient to be a basis?
slide-21
SLIDE 21

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Why spanning trees?

  • Q1. Why is being a spanning tree necessary to be a basis?
  • A1. If there are two pieces, then not all systems Fx = d with
  • k∈N dk = 0 have solutions. We must have the dk sum to 0 on

each piece!

  • Q2. Why is being a spanning tree sufficient to be a basis?
  • A2. We have an algorithm (next slide) to find a basic solution

using only arcs in a spanning tree.

slide-22
SLIDE 22

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Why spanning trees?

  • Q1. Why is being a spanning tree necessary to be a basis?
  • A1. If there are two pieces, then not all systems Fx = d with
  • k∈N dk = 0 have solutions. We must have the dk sum to 0 on

each piece!

  • Q2. Why is being a spanning tree sufficient to be a basis?
  • A2. We have an algorithm (next slide) to find a basic solution

using only arcs in a spanning tree. This will give us an x such that Fx = d, but not necessarily x ≥ 0.

slide-23
SLIDE 23

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

From a spanning tree to a basic solution

To find a basic solution, repeat the following:

1 Pick a node k with only one arc of the spanning tree with

unknown flow in/out of k.

2 Solve for that remaining flow to make ∆k(x) = dk.

slide-24
SLIDE 24

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

From a spanning tree to a basic solution

To find a basic solution, repeat the following:

1 Pick a node k with only one arc of the spanning tree with

unknown flow in/out of k.

2 Solve for that remaining flow to make ∆k(x) = dk.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

slide-25
SLIDE 25

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

From a spanning tree to a basic solution

To find a basic solution, repeat the following:

1 Pick a node k with only one arc of the spanning tree with

unknown flow in/out of k.

2 Solve for that remaining flow to make ∆k(x) = dk.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

5

Solve for x12 using node 1

slide-26
SLIDE 26

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

From a spanning tree to a basic solution

To find a basic solution, repeat the following:

1 Pick a node k with only one arc of the spanning tree with

unknown flow in/out of k.

2 Solve for that remaining flow to make ∆k(x) = dk.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

5 2

Solve for x23 using node 2

slide-27
SLIDE 27

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

From a spanning tree to a basic solution

To find a basic solution, repeat the following:

1 Pick a node k with only one arc of the spanning tree with

unknown flow in/out of k.

2 Solve for that remaining flow to make ∆k(x) = dk.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

5 2 1

Solve for x43 using node 4

slide-28
SLIDE 28

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

From a spanning tree to a basic solution

To find a basic solution, repeat the following:

1 Pick a node k with only one arc of the spanning tree with

unknown flow in/out of k.

2 Solve for that remaining flow to make ∆k(x) = dk.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

5 2 1 2

Solve for x63 using node 3

slide-29
SLIDE 29

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

From a spanning tree to a basic solution

To find a basic solution, repeat the following:

1 Pick a node k with only one arc of the spanning tree with

unknown flow in/out of k.

2 Solve for that remaining flow to make ∆k(x) = dk.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

5 2 1 2 3

Solve for x56 using node 5

slide-30
SLIDE 30

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Ideas about pivoting steps

Things we want from pivoting: We should be able to add any arc we want, and remove an existing arc to get another spanning tree.

slide-31
SLIDE 31

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Ideas about pivoting steps

Things we want from pivoting: We should be able to add any arc we want, and remove an existing arc to get another spanning tree. If we have a basic feasible solution (Fx = d, x ≥ 0) before the pivot, that should stay true after the pivot.

slide-32
SLIDE 32

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Ideas about pivoting steps

Things we want from pivoting: We should be able to add any arc we want, and remove an existing arc to get another spanning tree. If we have a basic feasible solution (Fx = d, x ≥ 0) before the pivot, that should stay true after the pivot. Vague idea: adding an arc to a spanning tree creates a cycle! We can modify the flows along that cycle to get infinitely many new solutions.

slide-33
SLIDE 33

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Ideas about pivoting steps

Things we want from pivoting: We should be able to add any arc we want, and remove an existing arc to get another spanning tree. If we have a basic feasible solution (Fx = d, x ≥ 0) before the pivot, that should stay true after the pivot. Vague idea: adding an arc to a spanning tree creates a cycle! We can modify the flows along that cycle to get infinitely many new solutions. One of those solutions will have flow xij = 0 for an existing arc (i, j).

slide-34
SLIDE 34

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The pivoting step algorithm

Once we’ve picked an arc (i, j) we’re adding to the basis:

1 Find the cycle formed by that arc and the spanning tree.

slide-35
SLIDE 35

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The pivoting step algorithm

Once we’ve picked an arc (i, j) we’re adding to the basis:

1 Find the cycle formed by that arc and the spanning tree. 2 Set xij = δ. For each arc on the cycle, add δ if it has the same

direction around the cycle as (i, j), subtract δ otherwise.

slide-36
SLIDE 36

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The pivoting step algorithm

Once we’ve picked an arc (i, j) we’re adding to the basis:

1 Find the cycle formed by that arc and the spanning tree. 2 Set xij = δ. For each arc on the cycle, add δ if it has the same

direction around the cycle as (i, j), subtract δ otherwise.

3 Find the smallest δ that sets an existing arc to 0.

slide-37
SLIDE 37

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The pivoting step algorithm

Once we’ve picked an arc (i, j) we’re adding to the basis:

1 Find the cycle formed by that arc and the spanning tree. 2 Set xij = δ. For each arc on the cycle, add δ if it has the same

direction around the cycle as (i, j), subtract δ otherwise.

3 Find the smallest δ that sets an existing arc to 0.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

5 2 1 2 3

slide-38
SLIDE 38

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The pivoting step algorithm

Once we’ve picked an arc (i, j) we’re adding to the basis:

1 Find the cycle formed by that arc and the spanning tree. 2 Set xij = δ. For each arc on the cycle, add δ if it has the same

direction around the cycle as (i, j), subtract δ otherwise.

3 Find the smallest δ that sets an existing arc to 0.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

5 2 1 2 3

slide-39
SLIDE 39

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The pivoting step algorithm

Once we’ve picked an arc (i, j) we’re adding to the basis:

1 Find the cycle formed by that arc and the spanning tree. 2 Set xij = δ. For each arc on the cycle, add δ if it has the same

direction around the cycle as (i, j), subtract δ otherwise.

3 Find the smallest δ that sets an existing arc to 0.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

5 2 1 − δ 2 + δ 3 + δ δ

slide-40
SLIDE 40

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The pivoting step algorithm

Once we’ve picked an arc (i, j) we’re adding to the basis:

1 Find the cycle formed by that arc and the spanning tree. 2 Set xij = δ. For each arc on the cycle, add δ if it has the same

direction around the cycle as (i, j), subtract δ otherwise.

3 Find the smallest δ that sets an existing arc to 0.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

5 2 3 4 1

slide-41
SLIDE 41

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

The pivoting step algorithm

Once we’ve picked an arc (i, j) we’re adding to the basis:

1 Find the cycle formed by that arc and the spanning tree. 2 Set xij = δ. For each arc on the cycle, add δ if it has the same

direction around the cycle as (i, j), subtract δ otherwise.

3 Find the smallest δ that sets an existing arc to 0.

1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

5 2 3 4 1

slide-42
SLIDE 42

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Reduced costs

  • Q. How can we compute the reduced cost of an arc we’re adding?
slide-43
SLIDE 43

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Reduced costs

  • Q. How can we compute the reduced cost of an arc we’re adding?
  • A. Look at the ±δ changes and multiply them by the costs of the

arcs.

slide-44
SLIDE 44

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Reduced costs

  • Q. How can we compute the reduced cost of an arc we’re adding?
  • A. Look at the ±δ changes and multiply them by the costs of the

arcs. 1 2 3 4 5 6

−δ +δ +δ +δ

slide-45
SLIDE 45

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Reduced costs

  • Q. How can we compute the reduced cost of an arc we’re adding?
  • A. Look at the ±δ changes and multiply them by the costs of the

arcs. 1 2 3 4 5 6

−δ × $1 +δ × $1 +δ × $3 +δ × $2

slide-46
SLIDE 46

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Reduced costs

  • Q. How can we compute the reduced cost of an arc we’re adding?
  • A. Look at the ±δ changes and multiply them by the costs of the

arcs. 1 2 3 4 5 6

−δ × $1 +δ × $1 +δ × $3 +δ × $2

Total change in cost: δ × (2 + 3 + 1 − 1) = 5δ, so the reduced cost

  • f x45 is 5.
slide-47
SLIDE 47

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

A two-phase method for min-cost flow

We now know how to find the min-cost flow once we have a starting basic feasible flow. But how can we get that starting point?

slide-48
SLIDE 48

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

A two-phase method for min-cost flow

We now know how to find the min-cost flow once we have a starting basic feasible flow. But how can we get that starting point? The two-phase simplex method:

1 Add artificial variables to each constraint, so that we get a

basic feasible solution using only artificial variables.

2 Add an artificial objective function that tries to force out

those variables.

slide-49
SLIDE 49

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

A two-phase method for min-cost flow

We now know how to find the min-cost flow once we have a starting basic feasible flow. But how can we get that starting point? The two-phase simplex method:

1 Add artificial variables to each constraint, so that we get a

basic feasible solution using only artificial variables. Add an artificial node a. For each node k: if dk > 0, add arc (a, k) with xak = dk; if dk < 0, add arc (k, a) with xka = |dk|.

2 Add an artificial objective function that tries to force out

those variables.

slide-50
SLIDE 50

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

A two-phase method for min-cost flow

We now know how to find the min-cost flow once we have a starting basic feasible flow. But how can we get that starting point? The two-phase simplex method:

1 Add artificial variables to each constraint, so that we get a

basic feasible solution using only artificial variables. Add an artificial node a. For each node k: if dk > 0, add arc (a, k) with xak = dk; if dk < 0, add arc (k, a) with xka = |dk|.

2 Add an artificial objective function that tries to force out

those variables. Set the cost to $1 for artificial arcs, $0 for original arcs.

slide-51
SLIDE 51

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Example of the first phase

Original min-cost flow problem: 1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

$2 $4 $1 $3 $2 $1 $3 $5

slide-52
SLIDE 52

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Example of the first phase

Original min-cost flow problem: 1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1]

$2 $4 $1 $3 $2 $1 $3 $5

Initial spanning tree for the phase-one problem: 1[−5] 2[3] 3[5] 4[−1] 5[−3] 6[1] a[0]

5 3 5 1 3 1

slide-53
SLIDE 53

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Moving from first to second phase

In the usual simplex method, it’s typical that we’ll be able to drive

  • ut all artificial variables.
slide-54
SLIDE 54

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Moving from first to second phase

In the usual simplex method, it’s typical that we’ll be able to drive

  • ut all artificial variables.

Here: Any spanning tree with the artificial node a in it must include some arc in or out of a, to be connected.

slide-55
SLIDE 55

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Moving from first to second phase

In the usual simplex method, it’s typical that we’ll be able to drive

  • ut all artificial variables.

Here: Any spanning tree with the artificial node a in it must include some arc in or out of a, to be connected. We stop when there is only one arc in or out of a left in the spanning tree.

slide-56
SLIDE 56

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Moving from first to second phase

In the usual simplex method, it’s typical that we’ll be able to drive

  • ut all artificial variables.

Here: Any spanning tree with the artificial node a in it must include some arc in or out of a, to be connected. We stop when there is only one arc in or out of a left in the spanning tree. Because we want ∆a(x) = da = 0, that arc must have flow 0.

slide-57
SLIDE 57

Introduction Basic solutions Pivoting steps Finding an initial feasible solution

Moving from first to second phase

In the usual simplex method, it’s typical that we’ll be able to drive

  • ut all artificial variables.

Here: Any spanning tree with the artificial node a in it must include some arc in or out of a, to be connected. We stop when there is only one arc in or out of a left in the spanning tree. Because we want ∆a(x) = da = 0, that arc must have flow 0. Once we delete the artificial node and artificial arcs, we’re left with a basic feasible solution to the original problem.