Identify the stages, states and arcs of the network
stages 0 to 4,source A,sink J Dynamic programming labels each state by the stage it belongs to; a route uses exactly one arc per stage from the source to the sink.
Give the sink its initial value
The route ends at J, so from J there is no further value to add.
Stage 3: optimise state H
g(H)=max{41+0}=41 The optimal value at state H combines each outgoing arc with the value already fixed at the state it leads to, and keeps the largest total.
Stage 3: optimise state I
g(I)=max{13+0}=13 The optimal value at state I combines each outgoing arc with the value already fixed at the state it leads to, and keeps the largest total.
Stage 2: optimise state E
g(E)=max{21+41,2+13}=62 The optimal value at state E combines each outgoing arc with the value already fixed at the state it leads to, and keeps the largest total.
Stage 2: optimise state F
g(F)=max{22+41,24+13}=63 The optimal value at state F combines each outgoing arc with the value already fixed at the state it leads to, and keeps the largest total.
Stage 2: optimise state G
g(G)=max{26+41,6+13}=67 The optimal value at state G combines each outgoing arc with the value already fixed at the state it leads to, and keeps the largest total.
Stage 1: optimise state B
g(B)=max{23+62,33+63,3+67}=96 The optimal value at state B combines each outgoing arc with the value already fixed at the state it leads to, and keeps the largest total.
Stage 1: optimise state C
g(C)=max{25+62,44+63,31+67}=107 The optimal value at state C combines each outgoing arc with the value already fixed at the state it leads to, and keeps the largest total.
Stage 1: optimise state D
g(D)=max{46+62,42+63,18+67}=108 The optimal value at state D combines each outgoing arc with the value already fixed at the state it leads to, and keeps the largest total.
Stage 0: optimise state A
g(A)=max{9+96,45+107,34+108}=152 The optimal value at state A combines each outgoing arc with the value already fixed at the state it leads to, and keeps the largest total.
Trace the optimal route forwards from the source
A→C→F→H→J(45+44+22+41=152) Following the optimal choice recorded at each state gives the route, whose arc values add up to the optimal total.
State Bellman's principle of optimality
optimal policy⇒optimal sub-policy Any part of an optimal route is itself optimal for the sub-problem that starts where that part begins, so each state need only be optimised once.
Record the optimal value at every state
g(A)=152,g(B)=96,g(C)=107,g(D)=108,g(E)=62,g(F)=63,g(G)=67,g(H)=41,g(I)=13 Each label is the best value obtainable on a route from that state to the sink.
Select the route of greatest total value
optimal route:A→C→F→H→J This route attains the maximum total value of 152 and no other route matches it.