41
1 Outline Outline Introduction Shortest Route Problems Formulation Labeling Algorithm

1 Outline Introduction Shortest Route Problems Formulation Labeling Algorithm

Embed Size (px)

Citation preview

1

OutlineOutline

Introduction

Shortest Route Problems Formulation Labeling Algorithm

2

Chapter 8Chapter 8

Network Optimization ModelNetwork Optimization Model & &

PERT/CPMPERT/CPM

3

Structure of Chapter 8Structure of Chapter 8

8.1 Network Models 網路模型 8.1.1 The Shortest Route Problem 最短路徑問題 8.1.2 The Minimum Spanning Tree Problem 最小

延展樹問題 8.1.3 The Maximal Flow Problem 最大流量問題

8.2 PERT / CPM 計劃評核術 /要徑法

4

8.1 Network Models8.1 Network Models

definitions circles: nodes ( 節點 ), vertices ( 角 ) lines: arcs, branches directed (具方向的) or not

2

1

3

4

2

1

3

4

2

1

3

4

2

1

3

4

5

Formulation of Formulation of the Shortest Route Problemthe Shortest Route Problem

6

8.1.1 The Shortest Route Problem8.1.1 The Shortest Route Problem最短路徑問題

motivation: to find the shortest route from the origin ( 起點, i.e., one location, source node) to the destination ( 終點, i.e., another location, sink node) in a network driving, production and inventory problems, etc.

what to do? formulation

solution methods ij aijxij,s.t.

i xij - i xji = sj for all j

formulation, with known parameter values aij, sj an optimizer,

a solver optimal solution

*ijx

7

FormulationFormulation the formulation for the shortest distance between node 1 and node 6:

Min z = 5(x12+x21)+8(x13+x31)+7(x14+x41)+6(x23+x32)+1(x34+x43)+13(x25+x52) +7(x35+x53)+16(x46+x64)+6(x56+x65)

s.t. (i.e., subject to):

x12+x13+x14 = 1 (source node)

x12+x32+x52 = x21+x23+x25 (node 2)

x13+x23+x43+x53 = x31+x32+x34+x35 (node 3)

x14+x34+x64 = x41+x43+x46 (node 4)

x25+x35+x65 = x52+x53+x56 (node 5)

x56+x46 = 1 (node 6)

xij = 0 or 1 for all i, j combinations

How to formulate?

只要細想,每個人都懂。

要是不知如何下手,就從簡單的問題開始。

8

Formulation (Formulation ( 建模建模 )) a one-arc, two-node problem

source node 1 sink node 2

how to formulate? either the upper or the lower route (上路還是下路?

) ; how to model mathematically? min 9U + 7L

s.t.

U + L = 1

U, L {0, 1}

7

9

1 2

數學模式 (formulation) 只是用精練(複雜?)的語言表達日常的事物,所以建模的重點在補捉事物的要素、精髓。如上述問題,

什麼是最重要的決定?

9

FormulationFormulation

a three-arc, three-node problem source node 1

sink node 3

either the upper or the lower route; how to model mathematically?

min (3+2)U + 4L

s.t.

U + L = 1

U, L {0, 1}

2

9

3

1

2

3

10

FormulationFormulation

Of course we know the shortest distance between node 1 and node 4.

What is the direction of flow in the middle arc, upward

or downward? Or any flow at all? However, in a formulation we better do not assume any

knowledge about the optimal solution.

1

2

5

6

3

1

2

4

3

How to formulate?

我們當然曉得在最短的路徑中我們會從 node 2跑去 node 3,但在 formulation 中我們不能直接引用最短路徑的結果。

11

FormulationFormulation

In our context, formulation is the process to express the dynamics a physical phenomenon mathematically in terms of variables that we define.

physical phenomenon

ij aijxij,s.t.

i xij - i xji = sj for all j

formulation, with known parameter values aij, sj

建模是邏輯問題,不是數學問題。每一條限制式都代表系統中一種實在的現象。要建模就得先掌握這些實在的現象,才能用變量表達。

12

FormulationFormulation

properties of a route from the source to the sink: each route represented by a collection of xij = 1,

with the other off-route variables = 0

source: one arc out

sink: one arc in

intermediate node: one arc in and one arc out

1

25

6

3

1

2

4

3

1

25

6

3

1

2

4

31

25

6

3

1

2

4

3

1

25

6

3

1

2

4

3

13

FormulationFormulation

min 3x12 + 6x13 + 2(x23+x32) + 5x24 + x34,

s.t.

x12 + x13 = 1 (node 1, source)

x12 + x32 = x23 + x24 (node 2)

x13 + x23 = x32 + x34 (node 3)

x24 + x34 = 1 (node 4, sink)

x12, x13, x32, x24, x34 {0, 1}

1

2

5

6

3

1

2

4

3

選最 node 1 到 node 4 最短徑,就像將一單位( 1 unit )的水從 node 1送到 node 4,水流過的 arcs就是在路徑上的 arcs.

14

Formulation - QuestionFormulation - Question

min 3x12 + 6x13 + 2(x23+x32) + 5x24 + x34,

s.t.

x12 + x13 = 1 (node 1, source)

x12 + x32 = x23 + x24 (node 2)

x13 + x23 = x32 + x34 (node 3)

x24 + x34 = 1 (node 4, sink)

x12, x13, x32, x24, x34 {0, 1}

Would both x23 and x32 be positive at minimum?

1

2

5

6

3

1

2

4

3

15

FormulationFormulation tricks in our formulation

only outflow from source node only inflow to destination node variables x21, x31, x42, and x43 set to zero in the textbook

min 3(x12+x21) + 6(x13+x31) + 2(x23+x32) + 5(x24+x42) + (x34+x43),s.t.

x12 + x13 = 1 (node 1, sosurce)

x12 + x32 + x42 = x21 + x23+x24 (node 2)

x13 + x23 + x43 = x31 + x32 + x34 (node 3)

x24 + x34 = 1 (node 4, destination)

x12, x13, x32, x24, x34 {0, 1}; x21 = x31 = x42 = x43 = 0

1

2

5

6

3

1

2

4

3

16

Formulation - QuestionFormulation - Question Would the following formulation be all right?

min 3(x12+x21) + 6(x13+x31) + 2(x23+x32) + 5(x24+x42) + (x34+x43),s.t.

x12 + x13 = 1 (node 1, sosurce)

x12 + x32 + x42 = x21 + x23+x24 (node 2)

x13 + x23 + x43 = x31 + x32 + x34 (node 3)

x24 + x34 = 1 (node 4, destination)

x12, x13, x32, x24, x34 , x21, x31, x42, x43 {0, 1}

Example 8.2 of the textbook uses the above formulation.

1

2

5

6

3

1

2

4

3

17

Example 8.2.

(a) Formulate this shortest route problem of node 1 to node 7 as a math model.

(b) Use the labeling procedure to solve this problem.

18

FormulationFormulation the formulation for the shortest distance between node 1 and node 6:

Min z = 5(x12+x21)+8(x13+x31)+7(x14+x41)+6(x23+x32)+1(x34+x43)+13(x25+x52) +7(x35+x53)+16(x46+x64)+6(x56+x65)

s.t. (i.e., subject to):

x12+x13+x14 = 1 (source node)

x12+x32+x52 = x21+x23+x25 (node 2)

x13+x23+x43+x53 = x31+x32+x34+x35 (node 3)

x14+x34+x64 = x41+x43+x46 (node 4)

x25+x35+x65 = x52+x53+x56 (node 5)

x56+x46 = 1 (node 6)

xij = 0 or 1 for all i, j combinations

Actually it is possible to drop the red variables.

19

Algorithms forAlgorithms forthe Shortest Route Problemthe Shortest Route Problem

20

Algorithms Background

how to determine the shortest route?

background: development of computers made possible computation for large networks led to step by step instructions to teach a

computer to calculate

21

Algorithms Background

Is it possible to compute the length of every route and then find the minimal?

how many routes are there from node 1 to node 9?

six, 2 R (i.e., right) and 2 D (i.e., down) in each route 21

3 4

5

6 7 9

8

22

Algorithms Background

the total number of routes increases quickly with number of nodes.

what is a quicker method?

在一個 N2 節點的網路中,路徑的總數目是 (2N!)/(N!

N!)

# of nodes # of routes

9 6

25 70

121

441

961

252

5.411011

4671017

23

The Labeling Algorithm forThe Labeling Algorithm forthe Shortest Route Problemthe Shortest Route Problem

24

The Labeling Procedure

1

4

3

5

6

7

213

18

20

22

27

30

49

18

26

24

32

33

Boundary for L and N

L : set of nodes with shortest distance from the source known;

with permanent labels.

(0, S)*

(13, 1)*

(18, 1)*

(35, 2)*

N : set of nodes with estimated

shortest distance from the source; with temporary

labels to be modified later.

(61, 4)

(53, 4) (67, 3)In each step (i.e., iteration), one node is moved from N to L.

25

The Labeling Procedure

a simple procedure in which the effort grows slowly with the number of nodes (運算所需的功夫隨節點的數目慢慢增加)

notions defined for the execution of the labeling procedure

two sets of nodes, L (nodes with well-defined distance from source node S) and N (nodes with temporary, estimated distance from source S)

permanent label (永久標籤) (d, y)* of a node x L: the shortest route from S to x is of d units, and it passes through y before going into x

26

The Labeling Procedure

two sets of nodes, L and N, during execution of the procedure

L, set of labeled nodes

nodes with definite distance from source S

before executing the algorithm: L = {S}

after executing the algorithm: L = the set of all nodes

N, set of non-labeled nodes

nodes with temporary, estimated distance from source S

before executing the algorithm: N = all nodes except S

after executing the algorithm: N =

27

Idea of the Labeling Procedure

three-node network, node 1 as source and node 3 as destination

what is the shortest distance from node 1 to node 3?

we need an executable procedure for a computer

2

9

3

1

2

3

28

Idea of the Labeling Procedure

for sure the shortest distance from node 1 to itself is zero

L = {1}, & permanent label of node 1, PL1 = (0, S)*

N = {2, 3}, and there is no label on any of the two nodes before labeling

which is the node closest to node 1?

2

9

3

1

2

3

(0, S)*

source: node 1; destination: node 3

29

Idea of the Labeling Procedure before the iteration: L = {1}, N = {2, 3}, PL1 = (0, S)* Iteration

two nodes are connected to node 1 their distance from node 1 are put as the labels for sure node 2 is the closer to node 1 turn the label (3, 1)* of node 2 permanent

after the iteration: L = {1, 2}, N = {3}, PL1 = (0, S)* , PL2 = (3, 1)* which is the closest node to L?

(9, 1)

(3, 1)

2

9

3

1

2

3

(0, S)* (9, 1)

(3, 1)*

2

9

3

1 3

(0, S)*

30

Idea of the Labeling Procedure

before the iteration: L = {1, 2}, N = {3}, PL1 = (0, S)* , PL2 = (3, 1)*

the label of node 3 is now permanent

after the iteration: L = {1, 2, 3}, N = , PL1 = (0, S)* , PL2 = (3, 1)*, and PL3 = (5, 2)*

(9, 1)

(3, 1)*

2

9

3

1 3

(0, S)*

(5, 2)*

(9, 1)

(3, 1)*

2

9

3

1 3

(0, S)*

31

Example 8.1.

the successive graphs by applying the labeling procedure

32

Example 8.1.

(0, S )*

The temporary label of node 2 should be turned permanent, because it is the shortest among all

temporary labels.

33

Example 8.1.

4

6

*

*

(0, S )*

With the temporary label of node 2 turned permanent,

the temporary labels of nodes connected to node 2

may be revised or created.

34

Example 8.1.

6

(23, 4)

*

*

*

(0, S )*

35

Example 8.1.

*

*

*

*

(0, S )*

With the temporary label of node 3 turned permanent, the temporary label of node 5 is revised.

36

Example 8.1.

*

* *

*

*(0, S )*

37

Example 8.1.

*

*

**

*

*

(0, S )*

38

Example 8.1.

to find the shortest route and its length

Node Distance Shortest Route Alternative Shortest Route 2 5 1-2 3 8 1-3 1-4-3 4 7 1-4 5 15 1-3-5 1-4-3-5 6 21 1-3-5-6 1-4-3-5-6

***

*

*

*

39

Example 8.2.

(a) Formulate this shortest route problem of node 1 to node 7 as a math model.

(b) Use the labeling procedure to solve this problem.

40

A Remark on SPP

我們只討論了一些基本的模型、方法。想想如何 用 Excel 解 SPP ; 將演算法寫成電腦程式; 如何比較演算法的優劣 ; …

41

Assignment #3

Chapter 8 (for shortest route problems) Problem 1 (a), (b), plus (c) Formulate this problem as a mathematical

programming model.

Possibly more problems for the next topic