Dynamic programming – Minimisation problem

Post on 30-Dec-2015

26 views 0 download

Tags:

description

Dynamic programming – Minimisation problem. Problem 1: Find the route through the network from A to H with minimal total weight. B. 5. F. 3. 3. 4. 4. 1. 2. 2. A. C. E. H. 5. 2. 3. 1. 3. 6. D. G. 5. Dynamic programming – Minimisation problem. - PowerPoint PPT Presentation

transcript

Dynamic programming – Minimisation problem

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

Problem 1: Find the route through the network from A to H with minimal total weight.

Dynamic programming – Minimisation problem

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(0, 1)

The first step is to label all the nodes with stage and state variables.The stage variable for a node is the maximum number of transitions required to get from this node to the end node, H. All nodes with the same stage variable are then given a different state variable, starting with 1 at the top of the page and working downwards.H has stage variable 0, and is given the state variable 1.

Dynamic programming – Minimisation problem

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

The first step is to label all the nodes with stage and state variables.The stage variable for a node is the maximum number of transitions required to get from this node to the end node, H. All nodes with the same stage variable are then given a different state variable, starting with 1 at the top of the page and working downwards.F and G have stage variables of 1. F is given state variable 1, and G is given state variable

2.

Dynamic programming – Minimisation problem

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

The first step is to label all the nodes with stage and state variables.The stage variable for a node is the maximum number of transitions required to get from this node to the end node, H. All nodes with the same stage variable are then given a different state variable, starting with 1 at the top of the page and working downwards.E is the only node with stage variable 2. E is given state variable 1.

You could go via G instead which also gives two transitions

Dynamic programming – Minimisation problem

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(3, 1)

The first step is to label all the nodes with stage and state variables.The stage variable for a node is the maximum number of transitions required to get from this node to the end node, H. All nodes with the same stage variable are then given a different state variable, starting with 1 at the top of the page and working downwards.C is the only node with stage variable 3. C is given state variable 1.

Dynamic programming – Minimisation problem

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

The first step is to label all the nodes with stage and state variables.The stage variable for a node is the maximum number of transitions required to get from this node to the end node, H. All nodes with the same stage variable are then given a different state variable, starting with 1 at the top of the page and working downwards.B and D have stage variables of 4. B is given state variable 1, and D is given state variable 2.

Dynamic programming – Minimisation problem

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

The first step is to label all the nodes with stage and state variables.The stage variable for a node is the maximum number of transitions required to get from this node to the end node, H. All nodes with the same stage variable are then given a different state variable, starting with 1 at the top of the page and working downwards.A has stage variable 5. A is given state variable 1.

Dynamic programming – Minimisation problem

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

The next step is to set up a table to show your working.

Dynamic programming – Minimisation problem

F (1, 1) 11

3 3

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

In Stage 1, consider nodes with stage variable 1. These are F and G.

There is only one possible action from F, which is FH.

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

This has value 3.

Current minimumStage State Action Value

The minimum value of a route starting from F is therefore 3 .

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2) 1

11

6

3 3

6A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

In Stage 1, consider nodes with stage variable 1. These are F and G.

There is only one possible action from G, which is GH.

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

This has value 6.

The minimum value of a route starting from G is therefore 6 .

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

1

1

1

1

21+3=4

6

3 3

6A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 2, consider nodes with stage variable 2. This is E only.

There are three possible actions from E.

Action 1 is EF.

The value of EF is 1. From stage 1, the minimum value of a route from F is 3.

23

So the value of this route is 4.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

1

1

12

1

21+3=4

5

6

3 3

6A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 2, consider nodes with stage variable 2. This is E only.

There are three possible actions from E.

Action 2 is EH.

The value of EH is 5.

3

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

1

1

123

1

21+3=4

53+6=9

6

3 3

6A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 2, consider nodes with stage variable 2. This is E only.

There are three possible actions from E.

Action 3 is EG.

The value of EG is 3. From stage 1, the minimum value of a route from G is 6. So the value of this route is 9.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

1

1

123

1

21+3=4

53+6=9

6

3 3

6

4 A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 2, consider nodes with stage variable 2. This is E only.

The minimum value of a route starting from E is therefore 4.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

1

1

1

1

23

1

2

34+3=7

1+3=45

3+6=9

6

3 3

6

4 A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 3, consider nodes with stage variable 3. This is C only.

There are two possible actions from C.

Action 1 is CF.

The value of CF is 4. From stage 1, the minimum value of a route from F is 3.

2

So the value of this route is 7.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

1

1

1

12

23

1

2

34+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4 A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 3, consider nodes with stage variable 3. This is C only.

There are two possible actions from C.

Action 2 is CE.

The value of CE is 2. From stage 2, the minimum value of a route from E is 4. So the value of this route is 6.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

1

1

1

12

23

1

2

34+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 3, consider nodes with stage variable 3. This is C only.

The minimum value of a route starting from C is therefore 6.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

1

1

1

1

12

2

2

3

1

2

3

4

5+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 4, consider nodes with stage variable 4. These are B and D.

There are two possible actions from B.

Action 1 is BF.

The value of BF is 5. From stage 1, the minimum value of a route from F is 3. So the value of this route is 8.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

1

1

1

1

12

2

2

3

1

2

3

4

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 4, consider nodes with stage variable 4. These are B and D.

There are two possible actions from B.

Action 2 is BC.

The value of BC is 3. From stage 3, the minimum value of a route from C is 6. So the value of this route is 9.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

1

1

1

1

12

2

2

3

1

2

3

4

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

8

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 4, consider nodes with stage variable 4. These are B and D.

The minimum value of a route starting from B is therefore 8.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

D (4, 2)

1

1

1

1

1

1

2

2

2

2

3

3

1

2

3

4 3+6=9

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

8

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 4, consider nodes with stage variable 4. These are B and D.

There are three possible actions from D.

Action 1 is DC.

So the value of this route is 9.

The value of DC is 3. From stage 3, the minimum value of a route from C is 6.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

D (4, 2)

1

1

1

1

1

1

2

2

2

2

3

3

1

2

3

4 3+6=92+4=6

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

8

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 4, consider nodes with stage variable 4. These are B and D.

There are three possible actions from D.

Action 2 is DE.

The value of DE is 2. From stage 2, the minimum value of a route from E is 4. So the value of this route is 6.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

D (4, 2)

1

1

1

1

1

1

2

2

2

2

3

3

1

2

3

4 3+6=92+4=6

5+6=11

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

8

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 4, consider nodes with stage variable 4. These are B and D.

There are three possible actions from D.

Action 3 is DG.

The value of DG is 5. From stage 1, the minimum value of a route from G is 6. So the value of this route is 11.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

D (4, 2)

1

1

1

1

1

1

2

2

2

2

3

3

1

2

3

4 3+6=92+4=6

5+6=11

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

8

6

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 4, consider nodes with stage variable 4. These are B and D.

The minimum value of a route starting from D is therefore 6.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

D (4, 2)

A (5, 1)

1

1

1

1

1

1

2

2

2

2

23

3

3

1 4+8=12

1

2

3

4

5

3+6=92+4=6

5+6=11

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

8

6

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 5, consider nodes with stage variable 5. This is A only.

There are three possible actions from A.

Action 1 is AB.

The value of AB is 4. From stage 4, the minimum value of a route from B is 8. So the value of this route is 12.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

D (4, 2)

A (5, 1)

1

1

1

1

1

1

2

2

2

2

23

3

3

1 4+8=12

1

2

3

4

5 2+6=8

3+6=92+4=6

5+6=11

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

8

6

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 5, consider nodes with stage variable 5. This is A only.

There are three possible actions from A.

Action 2 is AC.

The value of AC is 2. From stage 3, the minimum value of a route from C is 6. So the value of this route is 8.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

D (4, 2)

A (5, 1)

1

1

1

1

1

1

2

2

2

2

23

3

3

1 4+8=12

1

2

3

4

5 2+6=81+6=7

3+6=92+4=6

5+6=11

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

8

6

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 5, consider nodes with stage variable 5. This is A only.

There are three possible actions from A.

Action 3 is AD.

The value of AD is 1. From stage 4, the minimum value of a route from D is 6. So the value of this route is 7.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

D (4, 2)

A (5, 1)

1

1

1

1

1

1

2

2

2

2

23

3

3

1 4+8=12

1

2

3

4

5 2+6=81+6=7

3+6=92+4=6

5+6=11

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

8

6

7

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

In Stage 5, consider nodes with stage variable 5. This is A only.

The minimum value of a route starting from A is therefore 7.

Dynamic programming – Minimisation problem

Stage State Action ValueCurrent

minimumF (1, 1)

G (1, 2)

E (2, 1)

C (3, 1)

B (4, 1)

D (4, 2)

A (5, 1)

1

1

1

1

1

1

2

2

2

2

23

3

3

1 4+8=12

1

2

3

4

5 2+6=81+6=7

3+6=92+4=6

5+6=11

3+6=95+3=8

4+3=72+4=6

1+3=45

3+6=9

6

3 3

6

4

6

8

6

7

A H

F

G

E C

B

D

4

1

2

5

3

2

2

5

3 3

3

5

6

4 1

(1, 1)

(0, 1)

(1, 2)

(2, 1)

(4, 2)

(3, 1)

(4, 1)

(5, 1)

From the completed table, the minimum weight for a route from A to H is 7.

The table shows that you need to take the third action from A, which is AD,then the second action out of D, which is DE,then the first action out of E, which is EF,and finally the action FH.

So the minimum weight route is ADEFH.