ENGR 3157-Operations Research-Lecture 08-NetworkProblems

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Operations Research

ENGR 3157
Lecture 08 – Network Problems

Eugene Ben-Awuah, PhD, PEng


Bharti School of Engineering
Laurentian University

Office: F220
Tel: 705-675-1151 ext. 2195
Email: [email protected]

2
Networks

• A network (or graph) is an abstract mathematical entity


composed of a set of nodes (or vertices) and a set of arcs
(or edges) connecting pairs of vertices:
– An arc is said to join the two nodes it connects, and those nodes are
its end nodes
– An arc is incident on its end nodes and they are incident on it
– Two nodes are adjacent if they are connected by an arc
– Two arcs are adjacent if they share an end node

1
3
Networks (2)

• An edge whose vertices are an ordered pair is a directed


edge and is drawn with an arrowhead at the destination
– One vertex is the origin, the other is the destination or terminus
– A network with at least one directed edge is a directed network
– A network with no directed edges is an undirected network

• The number of edges incident on a vertex v is called its


degree and is denoted by dv
– The average degree of all vertices in a network is its average degree
(or average nodal degree in telecom networks)

• A path is a connected sequence of distinct edges.


– If all vertices are also distinct (except possibly the origin and terminus
vertices) the path is called a simple path.
– A cycle is a path whose origin and terminus are the same node.

4
Networks (3)

• A graph whose edges each have a number, we, associated


with it is called a weighted graph,
– That number, we, is the weight of the edge
– An edge’s weight can correspond to capacity, length, cost, etc.

• Networks are used to transport commodities.


– Commodities could be liquids, manufactured products, electricity,
communications, etc.

• The field of network optimization involves solving


optimization problems on networks.
– Networks could include communication networks, road and railway
networks, air-traffic networks, power grids, etc.
– Abstract networks include organizational charts or precedence
diagrams in project management applications.

2
5
Uses of Graph Theory

• Graph theory originated from Leonhard Euler’s 1736 solution


to the Königsberg bridges problem:
– Is it possible to cross all seven bridges only once and end up where
you started?

6
Uses of Graph Theory (2)

• Euler conceptualized the problem as a network:


– Each land-mass is a node and each bridge is an arc.
– The path sought is actually a cycle since it returns to the origin.

Euler showed that


a cycle can’t pass A
through each arc
in a connected
network unless Such a cycle
B
each node has an D has come to be
even degree. known as an
Eulerian cycle.
C

3
7
Uses of Graph Theory (3)

• Where else can Eulerian cycles have practical applications?


– Mail carrier routes, garbage pick-up, etc.

• A related cycle is called a Hamiltonian cycle.


– A Hamiltonian cycle passes through every node exactly once.
– Any network with N nodes where every node has degree > N/2
contains a Hamiltonian cycle.
– The most well-known Hamiltonian cycle problem is the travelling
salesman problem:
• What is the shortest path through all nodes that returns you to the origin
node?
– The knight’s tour problem is an interesting special case of the
Hamiltonian cycle problem.
• Can a knight (in chess) start at some square and visit all 63 others
exactly once before returning to the start?

8
Shortest Path Problem

• In a weighted network, if edge weights correspond to lengths


or costs, it is a common goal to find the shortest path from
one node to another… this is the shortest path problem.
– For example, what is the shortest path from node A to node H in the
following network?

3 3
B E H
3
2
7 2
A 4 C G
1 5
2 3
D F
4

4
9
Shortest Path Problem (2)

• Finding the shortest path from node A to node H is


equivalent to a min-cost transhipment problem where
– node A is a supply point with total supply of one unit, and
– node H is a demand point with total demand of one unit:
3 4 2 M M M M
1 sA = 1
0 M M 3 M M M
1 sB = 1
M 0 M 2 5 7 M
1 sC = 1
M 1 0 M 4 M M
1 sD = 1
M M M 0 M M 3
1 sE = 1
Optimal/shortest path M M M M 0 3 M
…….... 1 sF = 1
M M M M M 0 2
Optimal solution, z = 1 sG = 1
……….
dB=1 dC=1 dD=1 dE=1 dF=1 dG=1 dH=1

10
Dijkstra’s Algorithm

• If all arc lengths or costs are non-negative, then an


algorithmic approach called Dijkstra’s algorithm will solve
the shortest path problem very efficiently.

• Starting at the origin node:


– “Scan” adjacent nodes and give them a temporary label indicating
total distance and predecessor node.
– Change the temporary label with the smallest total distance into a
permanent label.
– Scan adjacent nodes from the last permanently labelled node and
give them temporary labels.
– Change the temporary label with the smallest total distance or lowest
cost into a permanent label.
– Repeat…

5
11
Dijkstra’s Algorithm (2)

Step 1: scan nodes B, C, and D Labels:


Step 2: permanently label node D A → 0, -
B → 3, A
C → 4, A
D → 2, A

3, A
3 3
B E H
3
2
4, A 2
Origin 4 7
A C G
1 5
2 3
lowest-cost label D F
4
2, A

12
Dijkstra’s Algorithm (3)

Step 1: scan nodes B, C, and D Labels: Labels:


Step 2: permanently label node D A → 0, - E → ∞, -
Step 3: scan nodes C and F B → 3, AA F → 6, D
Step 4: permanently label node B C → 3,
4, A
D G → ∞, -
D → 2, A H → ∞, -
lowest-cost label
C’s label is updated
3, A
label is updated 3 3
B E H
3
2
4, A
3, D 2
Origin 4 7
A C G
1 5
2 3
D F
4 6, D
2, A

6
13
Dijkstra’s Algorithm (4)

Step 1: scan nodes B, C, and D Labels: Labels:


Step 2: permanently label node D A → 0, - E → ∞,
6, B
-
Step 3: scan nodes C and F B → 3, A F → 6, D
Step 4: permanently label node B C → 3, D G → ∞, -
Step 5: scan node E
D → 2, A H → ∞, -
Step 6: permanently label node C
3, A 6, B
3 3
lowest-cost label B E H
3
2
3, D 2
Origin 4 7
A C G
1 5
2 3
D F
4 6, D
2, A

14
Dijkstra’s Algorithm (5)

Step 7: scan nodes E, F, and G Labels: Labels:


Step 8: permanently label node E A → 0, - 6, C
E → 5, B
B → 3, A F → 6, D
C → 3, D G → ∞,
10,- C
D → 2, A H → ∞, -
lowest-cost label

3, A 6,
5, B
C
3 3
B E H
3
2
3, D 2
Origin 4 7
A C G
1
10, C
2 5 3
D F label not updated
4 6, D
2, A

7
15
Dijkstra’s Algorithm (6)

Step 7: scan nodes E, F, and G Labels: Labels:


Step 8: permanently label node E A → 0, - E → 5, C
Step 9: scan node H B → 3, A F → 6, D
Step 10: permanently label node F C → 3, D G → 10, C
D → 2, A H → 8,
∞, E
-

3, A 5, C 8, E
3 3
B E H
3
2
3, D 2
Origin 4 7
A C G
1
10, C
2 5 3
D F lowest-cost label
4 6, D
2, A

16
Dijkstra’s Algorithm (7)

Step 7: scan nodes E, F, and G Labels: Labels:


Step 8: permanently label node E A → 0, - E → 5, C
Step 9: scan node H B → 3, A F → 6, D
Step 10: permanently label node F C → 3, D G → 9,
10,FC
Step 11: scan node G
D → 2, A H → 8, E
Step 12: permanently label node H
3, A 5, C 8, E
3 3
B E H
3
2
3, D 2 lowest-cost label
Origin 4 7
A C G
1
10,FC
9,
2 5 3
D F
4 6, D label is updated
2, A

8
17
Dijkstra’s Algorithm (8)

Shortest Path: Labels: Labels:


A-D-C-E-H at a cost of 8 A → 0, - E → 5, C
B → 3, A F → 6, D
C → 3, D G → 9, F
D → 2, A H → 8, E

3, A 5, C 8, E
3 3
B E H
3
2
3, D 2
Origin 4 7
A C G
1
9, F
2 5 3
D F
4 6, D
2, A

18
In-Class Problem – Dijkstra’s Algorithm #1

• What is the shortest path from node A to all other nodes in


the following network?

2 1 4
B E H K

3 3 2 5
3 3
4 2 3
A C G J L
2
1 4
1 7
5
D F I
2 2

9
19
In-Class Problem – Dijkstra’s Algorithm #2

• You’ve purchased a new car (at time 0) for $12,000. To


avoid the high maintenance costs, we may trade in the car
for a new one. The car’s annual maintenance cost and its
trade-in value depend on its age:
Age (Start of Year) Annual Maint. Trade-in Price
0 - -
1 $ 2,000 $ 7,000
2 $ 4,000 $ 6,000
3 $ 5,000 $ 2,000
4 $ 9,000 $ 1,000
5 $ 12,000 $ 0

• What trade-in schedule will minimize costs over 5 years?


– To simplify the computations we assume that at any time it costs
$12,000 to purchase a new car.

20
Maximum Flow Problems

• If the edge weights of a network correspond to some sort of


capacity that limits the quantity of a commodity that can be
transported through the arc, we are often interested in
determining the maximum flow of the commodity from a
source node to a sink node.
• For example:
– What is the maximum possible amount of oil per hour from node A to
node E using the following pipeline system (capacities shown)?

4 D 1

2 3 2
A B C E

10
21
Maximum Flow Problems (2)

• LP formulation:

maximize: z = xAB + xAC

subject to: xAB ≤ 2 xAC ≤ 3


xBC ≤ 3 xBD ≤ 4
xCE ≤ 2 xDE ≤ 1

xAB = xBC + xBD


xAC + xBC = xCE
xBD = xDE

xAB, xAC, xBC, xBD, xCE, xDE ≥ 0 (non-negativity)

22
Ford-Fulkerson Method

• Another method for solving maximum flow network problems


is the Ford-Fulkerson method:
– Find the shortest path from A to E.
• Route as much as possible on that path.
• Update edge weights to account for used capacity.
– Find the shortest path from A to E, allowing reverse-direction arcs
with the same capacities as used in the forward direction.
• Route as much as possible on that path.
– Repeat…

11
23
Ford-Fulkerson Method (2)

Start:
0/4 D 0/1

0/2 0/3 0/2


A B C E

0/3

Step 1: shortest path:


0/4 D 0/1 A-B-C-E,
2 units
0/2
2/2 0/3
2/3 0/2
2/2
A B C E

0/3

24
Ford-Fulkerson Method (3)

Step 2: shortest path:


0/4
1/4 D 0/1
1/1 A-C-B-D-E,
1 unit
2/2 2/3
1/3 2/2
A B C E

0/3
1/3

Solution: 3 units total:


1/4 D 1/1 1 x A-B-C-E
1 x A-B-D-E
2/2 1/3 2/2 1 x A-C-E
A B C E

1/3

12
25
Min-Cut Max-Flow

• A cut is a set of edges that if removed would partition the


network into two parts, with the source and sink nodes in
separate parts.
– A cut’s capacity is the sum of the capacities of the edges in the cut.

• The min-cut max-flow theorem says that the minimum-


capacity cut for a pair of nodes is also the maximum flow
between that pair of nodes.

26
Min-Cut Max-Flow (2)

• Some cuts of this network:


– Identify the max flow node/edge(s) in the network

3 3
B E H
3
2
7 2
A 4 C G
1 cap. = 5
2 5 3
D F
4
cap. = 13
cap. = 21
cap. = 12
cap. = 9
minimum-capacity cut
= maximum flow

13
27
Minimum-Cost Network Flow Problems

• The transportation, assignment, transhipment, shortest path,


and maximum flow (and other) problems are all special
cases of the minimum-cost network flow problem
(MCNFP).

• A MCNFP can be generalized as:

Min: ∑c
∀i , j
ij ⋅ xij

Sub. to: ∑x −∑x


∀j
ij
∀j
ji = bi , ∀i ∈ nodes

Lij ≤ xij ≤ U ij , ∀ij ∈ arcs

28
Example – MCNFP

• Each hour, 900 cars enter at node 1 of the road network


shown below, and seek to exit from node 6. With travel times
shown in the table and road capacities indicated on the
network, formulate the MCNFP that minimizes the total
travel time for all cars.

Arc Time (min)


600 1,2 10
2 4
800 400 1,3 50
100 2,4 30
600 2,5 70
1 6
3,4 10
300 3,5 60
600 600 4,5 30
3 5 4,6 60
400
5,6 30

14
Example 2
Write the linear program for this transshipment problem to
minimize travel cost.

15

You might also like