In: Advanced Math
Solve the following problem by Dynamic
Programming:
Maximize z = (y1 + 2)^2 + y2 * y3 + (y4 - 5)^2
subject to
y1 + y2 + y3 + y4 <= 5
yi >= 0 and integer, i = 1, 2, 3, 4
problem
becomes
Max
subject to
for which we get
problem
becomes
Max
subject to
for which we get
problem
becomes
Max
subject to
Which has max value
problem
becomes
Max
subject to
Which has max value for
problem
becomes
Max
subject to
If
then
If
problem becomes
Max
subject to
Which has max value for
If
problem becomes
subject to
for which max value is 32 again for 
If
problem becomes
subject to
for which max value is 41 for 
If
problem becomes
subject to
for which max value is 36 for 
makes our problem
Max
subject to
Which has max value
makes our problem
Max
subject to
Which has max value
Thus, the overall maximum value is attained when
And the value is 

Hope this was helpful. Please do leave a positive rating if you liked this answer. Thanks and have a good day!