network flow problems a special case of linear programming which is faster and has wide...

24
Network Flow Problems A special case of linear programming which is faster and has wide applicability

Upload: adam-hartle

Post on 31-Mar-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Network Flow Problems

A special case of linear programming which is faster and has wide

applicability

Page 2: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Solving Discrete Problems

Linear programming solves continuous problem—problems over the reaI numbers.

For the remainder of the course we will look at how to solve problems in which variables must take discrete values—problems over the integers.

Discrete problems are harder than continuous problems.

We already saw: Finite Domain PropagationWe will look at

• Network Flow Problems• Integer Programming• Boolean Satisfiability• Local Search

Page 3: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Network Simplex

A particular form of linear integer problems can be solved in elegantly (and efficiently)with a drastic simplification of the simplex method

d3=6

d4=10d5=8

s7=15

n2

n1

s6=9

Network Flow Optimization

Page 4: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Transshipment ProblemsIntuitively, a transshipment problem (or network flow problem)consists in finding the cheapest way of shipping goods through a network of routes so that all given demands at all points of the network are satisfied. Given: • a network of routes as a graph• a set of nodes which act as sources (supplies)• a set of nodes which act as sinks (demands)• the amount of supply and demand at each node• the cost of each transport route (edge)

d3=6

d4=10

d5=8

s7=15

n2

n1

s6=9

Assumption: the total supply equals the total demand

$53

$18

$29

$60

$8$28

$37

$5

$44

$38$98

$23

$59

$14

Page 5: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Network Flow Matrix Representation

A transshipment problem can concisely be represented in matrix form.with Incidence Matrix and Demand Vector.

A=

−1 −1 −1 1 1

−1 −1 −1 −1 1 1

1 1 1

1 1 1

1 1 −1 1

−1 −1 −1 −1

1 −1 −1

⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢

⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥

The incidence matrix A contains one column a=(a1, ..., an) for each edge e=(ni, nj) in the network withak := -1 if k=i

1 if k=j0 otherwise

Page 6: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Network Flow Matrix Representation

the demand vector

contains one element for each node giving the total demand at this node. Supplies are indicated as negative demands.

The cost vector

b=

0

0

6

10

8

−9

−15

⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢

⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥

c= c13 c14 c15 c21 c23 c24 c25 c54 c61 c62 c63 c67 c72 c75[ ]

= 53 18 29 8 60 28 37 5 44 38 98 14 23 59[ ]

contains one entry for each edge e=(ni, nj) with the cost of shipping one unit along this edge.

Page 7: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Transshipment Formalization

the transshipment problem can now be formalized as:

such that A is an incidence matrix and

minimize cx= cij xij∑

subject to

Ax=b,

xij ≥0

bii=1...n∑ =0

Every problem that can be expressed in this form is a transshipment problem and can be solved by the network simplex algorithm.

Page 8: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Truncated Matrix

Note that the equations expressed in

bii=1...n∑ =0

each of these equations is the sum of the remaining n-1 equations.We can therefore arbitrarily delete one of the equations from thematrices A and b obtaining A’ and b’.

The truncated problem has the same solution as the original problem.

Ax=b

are not independent. Since

minimize cx= cijx

ij∑

subject to

′ A x= ′ b ,

xij≥0

Page 9: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Feasible Solutions = Trees

If a transhipment problem has an optimal solution then it has an optimal solution that corresponds to a feasible tree solution. Why?

Thus we need only consider feasible tree solutions.

d3=6

d4=10d5=8

s7=15

n2

n1

s6=9

9

1

6

9

15

8

Network Feasible Tree Solution

Note that the feasible tree need not be a directed tree. It is defined on underlying undirected graph.

Page 10: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Uniqueness of Feasible Solutions

d3=6

d4=10d5=8

s7=15

n2

n1

s6=9

For a given tree there is a unique assignment to the edgesin the tree that satisfies the supply and demand constraints.

This can be found using a recursive tree traversal.

What is the assignment for this tree?

Page 11: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Network Simplex

The Network Simplex works by improving the current feasible spanning tree solution. Find an initial feasible tree solution While current solution not optimal

Choose the edge to enter (choose new basic variable)Choose the edge to leave so it remains a tree

(choose variable to leave)This exactly corresponds to the Simplex method but is greatly simplified because of the form of the constraints.

9

1

6

9

15

8

Network Feasible Spanning Tree Solution

d3=6

d4=10

d5=8

s7=15

n2

n1

s6=9

$53

$18

$29

$60

$8$28

$37

$5

$44

$38$98$23

$59

$14

Page 12: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Choosing the Edge to Enter

For each edge not in the spanning tree work out the benefit (gain) of adding it and moving 1 unit along that edge.

In the case of the edge (n7,n5) the cost of moving 1 unit along the edge is

1*59-1*29+1*18-1*28-1*23 = -3.So the benefit is 3 and we will reduce the cost if we add this edge.

If no edge has a benefit > 0 then the solution is optimal.Otherwise choose some edge with positive benefit to add.

d3=6

d4=10

d5=8

s7=15

n2

n1

s6=9

$53

$18

$29

$60

$8$28

$37

$5

$44

$38$98$23

$59

$14

$18

$59

$29

$23

$28$44

$60

Page 13: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Computing the Edge Benefit

In the Simplex we compute the opportunity cost for each resource. The benefit we have just computed is exactly the opportunity cost for the edge.

For each node ni we associate a variable yi which is (sort of) the price of shipping 1 unit to that node from an arbitrary origin node. This is the negative of the Simplex multiplier.

If an edge (ni,nj) is in the tree then yj=yi+cij. This allows us to easily compute the yi’s. (We assume that for the origin node yi =0)

The opportunity cost cij for an edge (ni,nj) not in the tree iscij=yj-yi-cij.

$18

$59

$23

$28$44

$60

We can compute the edge benefit more efficiently than this by thinking about the Simplex. (See Winston Chap 8 for justification).

Y7=0

Y2=

Y1=

Y6=

Y3=

Y4=

Y5=$29

Page 14: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Entering EdgesAn edge with positive benefit is now added to the spanning tree.It is therefore called the “entering edge”.

Strategy: If there are several possible choices for entering edges,choose the one with maximum benefit.

Note: large scale computer implementations use different strategies

Page 15: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Network PivotThe pivot step improves the solution by shipping some quantity t along the entering edge. As in the Simplex we try to exploit theentering edge maximally by maximizing t until constraints are tight.

9

1+t

6

9-t

15-t

8-t

t units

The obvious adjustments are obtained by traversing the cycle introduced by the entering edge (in its direction) and labelling each edge a along the cycle with (xij+t) if a has the same direction on the cycle as the entering edge(xij-t) if a has the opposite direction on the cycle.

With the resulting adjustments we have to satisfy:t ≥ 0, 8-t ≥ 0, 9-t ≥ 0, 15-t ≥ 0, 1+t ≥ 0

This leads to t=8 which removes all shipments from the dotted edge. This edge is referred to as the “leaving edge”.

9

9

6

1

7

8

9

1

6

9

15

8

Page 16: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Summary: Network Simplex

(1) construct a basic feasible tree.

(2) compute the benefit for each edge for this tree.

(3a) find an entering edge that can improve the solution

(3b) if no such edge can be found, the solution is optimal

(4) adjust the quantities shipped

(5) re-iterate from step (2)

As the Simplex algorithm, network simplex only works with feasible solutions.

The obvious problem is how to find an initial basic feasible tree!

Page 17: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Basic Feasible Tree Construction

In general, finding a basic feasible tree is not simple.

However, we can perform a “trick” similar to Simplex phase 0.

The basic idea is to add “artificial arcs” that guarantee a trivialbasic feasible tree.

We then use a phase 0 optimization on the augmented graph thatpenalizes these arcs so that they are not used in the optimum solution to phase 0.

The result of phase 0 with the (unused) artificial arcs removedis then a basic feasible solution for the original problem.

Page 18: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Auxiliary Problem & Graph• Select an arbitrary fixed node w• Add an artificial edge from w to each node

• set xwj=bj

The set of artificial edges forms a feasible spanning tree for the auxiliary graph

• Solve the following auxiliary problem • set penalty pij=1 for each artificial edge• set penalty pij=0 for each original edge

minimize cx= pij xij∑

subject to

Ax=b,

xij ≥0

Page 19: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Solving the Auxiliary Problem

The auxiliary problem can simply be optimized by network simplex. Three outcomes for the spanning tree T of the solution of phase 0 are possible:

• T contains no artificial edge-> use T as a start for phase I optimization of original

problem• T contains an artificial edge aij with xij>0

-> the original problem is infeasible• T contains artificial arcs aij with xij=0

-> the original problem may have a solution, but not a tree solution (eg network not sufficiently

connected)• Decompose the original problem into two networks.

Let a=(ni, nj) be the artificial edge with xij=0- Network A contains all nodes that precede ni in T- Network B contains all nodes that follow ni in T

• A and B can now be solved independently

Page 20: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Integrality Theorem

Let b be a vector of integers.The transshipment problem

(a) is feasible if and only if it has an integer-valued solution vector x.(b) has an optimal solution if and only if

it has an integer-valued optimal solution.

This can be proved by analyzing the pivot operation of the network simplex:Whenever it starts from an integer-valued solution the subsequent solution is also integer-valued.

minimize cx= cij xij∑

subject to

Ax=b,

xij ≥0

Page 21: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Complexity

• Linear Programming: • Interior point methods

worst case: polynomial• Simplex algorithm

worst case: exponential in size of LPin practice: well-behaved

• Integer Linear Programming: NP-complete

• Network Simplexworst case: exponential in node size

(proven for largest merit selection ‘73)

in practice: roughly linear in node sizeHowever, there are versions of Network Simplex with polynomial worst case behaviour (proved in 1997!)

Page 22: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Generalization to Inequalities

The assumption bii=1...n∑ =0(supply matches demand) is often unrealistic

We need to generalize to supplies that exceed the demand.

• Introduce “virtual dump” (new node) for exceeding supply

The new “dummy node” must be connected to each source by a new “dummy edge” of zero cost.

d3=6

d4=10d5=8

s7=15+y

n2

n1

dvd=x+y

s6=9+x

Page 23: Network Flow Problems A special case of linear programming which is faster and has wide applicability

Caterer Problem (aircraft overhaul scheduling)

A caterer needs to plan (and optimize) his napkin provisions over n days• dj: number of napkins needed on day j (known in advance)Napkins can be • bought: a cents per piece• laundered:

b cents per napkin (fast service takes q days)c cents per piece (slow service takes p days)

“buy”“quick laundry”

“keep” “slow”

Shop

Dump

exceeding supply in shop

“q days”

“at start of day”“at end of day”

-d1

-dn

+dn

+d1

“p days”

Page 24: Network Flow Problems A special case of linear programming which is faster and has wide applicability

We have looked at• Transhipment problems (network flow)• Network simplex

Gives an efficient way of solving some IP problems

Can be generalized to handle an upper bound on the flow along an edge

Summary

• Read Winston Chap 8• Solve the example using network simplex• Do the assignment!

Homework