0% found this document useful (0 votes)
4 views

Forward Backward Recursion

The document discusses dynamic programming techniques, specifically focusing on backward recursion for solving optimization problems. It presents multiple examples, including maximizing products under constraints and solving linear programming problems. The solutions demonstrate the application of dynamic programming principles to achieve optimal results in various scenarios.

Uploaded by

mdsopnil265
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Forward Backward Recursion

The document discusses dynamic programming techniques, specifically focusing on backward recursion for solving optimization problems. It presents multiple examples, including maximizing products under constraints and solving linear programming problems. The solutions demonstrate the application of dynamic programming principles to achieve optimal results in various scenarios.

Uploaded by

mdsopnil265
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Both the forward and backward recursion yields the same solution.

Although the forward procedure appears more logical DP literature invariably uses backward
recursion. The reason for this preference is that, in general, backward recursion may be more
efficient computationally.

we will demonstrate the use of backward recursion by applying it to example. the


demonstration will also provide the opportunity to present the DP computations in a compact
table from.

Question 1: Use dynamic programming to find the maximum value of the product
y 1 , y 2 , y 3 ,… … y a, when y 1 + y 2 + y 1+ … …+ y n=Q
Solution:
This is the optimal sub-division problem in which the given quantity Q is to be divided into n
parts in such a way that their product is maximized. The problem can be written as
Maximize ∏sjel yl
Subject to ∑iE=1 y i=Q

y i ≥0 , i=1 , 2 ,3 , … … … , n .

The problem can be tackled by dynamic programming by treating it as an n-stage problem. At


each state the mumber of alternatives is infinite as y , is continnous and may assume any non-
negative value satisfying the given constraints.
The state of the system x i at any stage i is the past of Q allocate to stages 1 through i inclusive.
i.e. x 1= y 1 + y 2 + y 3+ … …+ y 0
The recursive equation can be written as

f i ( xi ) ¿ max { y j }
y 2=x i

f i ( x i ) ¿ max { y 1 ⋅f i−1 ( x i− y i ) }
∥i xi
¿ ¿

Now for i=1

f 1 ( x 1 )=x 1

for i=2
f 2 ( x 2 )= max { y 2 ⋅ f 1 ( x 2− y 2) }
min cic 2
1

¿ max { y 2 ( x 2− y 2 ) } , [since f 1 ( x 2− y 2 )=x 2− y 2 ]


arc ⁡Ki n2
¿

Differentiating y 2 ( x 2− y 2 ) with respect to y 2 and equating to zero, we get

y 2 (−1)+ ( x 2− y 2 )=0
x2
⇒ y 2=
2

∴ f 2 ( x 2 )=
x2
2
x 2−
x2
2 ( )
2
x2
¿
4

( )
2
x2
¿
2

As x 2= y 1 + y 2
y 1=x 2− y 2
x2 x2
y 1=x 2− =
2 2
x
Or y 1= y 2= 2
2
For i=3
f 3 ( x 3 )= max { y 3 f 2 ( x 3− y 3 ) }
← ∈ LB L 4

{ }
2
( x3 − y 3 )
¿ max y 3 ,
an 4
x22
[ since f 2 ( x 2 )= ]
2
¿
2
Differentiating y 3 ( x 5− y 5 ) with respect to y 3 and equating to zero, we get
( x 5− y 3 ) (−2 y 3 + x 3− y 3 )=0
x1
∴ Either y 3=x 3 or, y 1=
3
x3
∴ Solution y 3= satisfies the sufficiency condition for a maximum.
2
( )
2
x3
x 3−
( )
3 3
x1 3 x3 x3
∴ f 3 ( x 3 )= = =
3 4 27 3

x 1= y 1 + y 2 + y 3
x
¿ y1 + y2 + 1
3
2 x1
∴ y 1+ y 2 =
3

As
x1
Further as y 1= y 2 , we have y 1= y 2= y 3= .
3
Similarly, it can be derived that for i=4

x4
y 1= y 2= y 1= y 4=
4

( )
4
x4
And f 4 ( y 4 ) =
4

And for i=n , we may nrite,

xe
y 1= y 2= y 3 =… … …= y v =
n

( )
n
xn
And f n ( y n) =
n

But x a= y 1 + y 2 + y 3 +… …+ y s=Q

( )
n
Q Q
∴ f w (Q)= and y 1= y 2= y 1=¿ .= y n= .
n n

Question. 2. Determine the values of u1 ,u 2 , u3 so as to


Maximize u1 ,u 2 , u3
Subject to u1 +u2 +u1=10
and u1 ,u 2 , u1 ≥ 0.
Solution: Let the state variables be x 1 , x 2 and x 3 such that
x3 =u1+ u2+ u3 ,
x 2=x 3−u3=u 1+u 2 ,
x 1=x 2−u2=u 1−¿ ∴ f 1 ( x 1) =u1=x 2−u 2 ,
f 2 ( x 2 )=max ⋅ {u2 ⋅ ( x 2−u2 ) } 0 ≤ u2 ≤ x 2
¿ max ⋅ {u 2 x 2−u22 } 0 ≤ u2 ≤ x 2 .

Differentiating w.r.t. u2, and equating the differential to zero,

∂ f 2 ( x2)
=x 2−2u 2=0
∂ u2
x2
or u2= .
2

( )
2
x2 x2 x2
∴ f 2 ( x 2 )= x− = .
2 2 2 4

Now

{ } { }
2
x22 ( x 3−u3 )
f 3 ( x 3 ) =max u 3− =max u3
4 4

Differentiating w.r.t. n3 and equating to zero,

[
∂ ( u3 x 3+u 3−2 u3 x 3 )
]
2 3 2

=0
∂ u1 4

or x 25 +3 u23−4 u3 x 5=0
or x 23−3 u3 x3 +3 u23 −n3 x3 =0
or x 3 ( x 1−3 u3 ) −u3 ( x 3−3 u3 )=0
or ( x 1−u1 ) ( x 3−3 u3 ) =0.
∴ Either u3=x 5 mhich is trivial since, x 5=u1 +u2 +u3 ;
x 10
or u3= 3 = −∵ : x 3=x 1 +α 2+ α 4=10 ∣
3 3
10 20 x
∴ x 2=10− = ,|x x2= x3 −x1|and u2= 2 = 10
3 3 2 3
10
Hence w 1= [ ∵ u1 m x 2−a2 mu 1 ]
3
10
∴ u1=u2 =u1=
3

1,000
The maximum product u1 ⋅u2 ⋅u 3= .
27

Question. 3. Solve by using the dynamic programming technique


Maxinize Z= y 21 + y 22+ y 21
Subject to y 1 + y 2 + y 3 ≥ 15
and y 1 , y 2 , y 3 ≥ 0.

Solution: Let the state variables be x 1 , x 2 and x 3 such that

x 3= y 1+ y 2+ y 3 ,
x 2=x 3− y 3= y 1+ y 2 ,
x 1=x 2− y 2= y 1 .

The recursive equations are

f 5 ( x 1 )=max { y 21 +f 2 ( x 2 ) }
h

f 2 ( x 2 )=max { y 22 + f 1 ( x 1 ) } and
n

f 1 ( x1 ) =max { y 1 }= y 1
2 2

2
Since x 1=x 2− y 2 and f 1 ( x 1 )= y1

∴ f 2 ( x 2 )=max { y 22 + ( x 2− y 2 )2 } .
x2

Differentiating { y 2+ ( x2− y 2 ) } ॠ. r. t. y 2 and equating to zero, we get,


2 2

2 y 2 +2 ( x 2− y 2 ) (−1)=0
x2
⇒ y 2= .
2

( )( )
2 2 2
x2 x2 x2
∴ f 2 ( x 2 )= + x 2− =
2 2 2

Now f 5 ( x 5 ) =max y { y 3 + f 2 ( x 2 ) }
2
1

2
x2
Since x 2=x 5− y 3 and f 2 ( x 2 )=
2
{ }
2
2 ( x 1− y 3 )
∴ f 3 ( x 1 )=max y + 3
n 2

{ }
2
(x −y )
Differentiating y + 1 3 w.r. t. y 3 and equating to zero, we get,
2
5
2

x3
y3 ¿
3

( )
2
x3
x 3−
( )
2 2
x3 3 x3
∴ f 3( x1) ¿ + =
3 2 3

Since x 3= y 1 + y 2 + y 3 ≥ 15
for maximization of f 3 ( x 3 ) , y 1+ y 2+ y 3=15

∴ f 5 ( x 1 )=¿ ¿

x3
and y 5= =5
3

x 2 x 3− y 3 15−5
y 2= = = =5
2 2 2
y1 =x2 − y 2=10−5=5

∴ The maximum value of y 21 + y 22 + y 23 is 75 with y 1= y 2= y 3=5.

Question 4: solve the following Linear programming problem by the dynamic programming
technique:
Maximize Z=8 y 1+ 7 y 2
Subject to 2 y 1+ y 2 ≤ 8

5 y 1 +2 y 2 ≤ 15
and y 1 , y 2 ≥ 0

Solution:
There are two variables, and bence it is a two stage problem Since there are two resources, the
state of the system is described by two variables.
Let the state at stage j be ( B1 , , B 2 ) and the objective fumction is f 1 ( B1 , , B2 j ).
Starting with stage 2 , i.e. j=2
max
f 2 ( B12 , B22 )=0 ≤ y 2 ≤ B 12 [ C 2 y 2 ]
0 ≤ y 2 ≤ B22
max
¿ 0≤ y 2 ≤ B12 [ 7 y 2 ]
0 ≤ y 2 ≤ B21
¿

Now y 2=min B12 , [ B22


2 ]
[
f 2 ( B12 , B22 )=7 min B12 ,
B22
2 ]
(
B22
And y ¿2=min B12 ,
2 )
Proceeding backwards to stage 1 , i.e. j=1

f 1 ( B11 , B 21) =¿ max a n y j ≤ B μ [ C 11 y1 + f 2 ( B11 −a 11 y1 , B 21−a21 y 1 ) ]


0
max
¿
[ (
0 ≤ 2 y 1 ≤ 8 8 y 1+ 7 min B11 −2 y 1 ,
2 )]
B21−5 y 1
¿0≤

The two coustraints are satisfied when y 1 ≤3

[ (
∴ f 1 ( 8 ,15)= max 8 y 1+7 min 8−2 y 1 ,
0 ≤ y 1 ≤3
15−5 y 1
2 )]
15−5 y 1
Minimum of ( 8−2 y 1 ) and for 0 ≤ y 1 ≤ 3 is obtained for y 1=3
2

15−5 y 1
When 8−2 y1 =2 and =0
2
¿
∴ y 1=3
¿
f 1 (8 , 15)=[8 ×3+7 × 0]=24

(
y ¿2=min B12 ,
B32
2 )
[ B 21−5 y 1
¿ min B11 −2 y 1 ,
2 ]
¿ min 8−6 , [
15−15
2
=0 ]
Hence the optimal solution is y 1=3 , y 2=0 and Z max =24 .

You might also like