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

Dynamic Programming

Dynamic programming is a technique for solving multistage decision problems by breaking them down into smaller subproblems. The knapsack problem uses dynamic programming to determine which items to include in a knapsack to maximize total profit without exceeding weight capacity. The tutorial problem demonstrates solving the 0/1 knapsack problem by filling a table with maximum profits at each stage and weight to find the optimal selection of items with total profit of 6.

Uploaded by

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

Dynamic Programming

Dynamic programming is a technique for solving multistage decision problems by breaking them down into smaller subproblems. The knapsack problem uses dynamic programming to determine which items to include in a knapsack to maximize total profit without exceeding weight capacity. The tutorial problem demonstrates solving the 0/1 knapsack problem by filling a table with maximum profits at each stage and weight to find the optimal selection of items with total profit of 6.

Uploaded by

RESMI V
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

3.

3 DYNAMIC PROGRAMMING

Dynamic programming or Recursive Optimization is a technique for getting


solutions for multistage decision problems.The technique of Dynamic programming
was developed by Richard Bellman in the early 1950. A problem, in which the
decision has to be made at successive stages, is called a multistage decision
problem. In this case, the problem solver will take decision at every stage, so that
the total effectiveness defined over all the stages is optimal. Here the original
problem is broken down or decomposed into small problems, which are known as
sub problems or stages which is much convenient to handle and to find the optimal
stage. For example, consider the problem of a sales manager, who wants to start
from his head office and tour various branches of the company and reach the last
branch. He has to plan his tour in such a way that he has to visit more number of
branches and cover less distance as far as possible. He has to divide the network of
the route connecting all the branches into various stages and workout, which is the
best route, which will help him to cover more branches and less distance.

Knapsack Problem

Here some items and its weight and profit of selling the items are given.Knapsack
in simple terms is a bag that you carry on your shoulders.Suppose 1 bag is given and
its size or weight capacity is given and this is the maximum size to store these
above items.

Here you have to select some items from the given items and you will put those
items into this bag or container and constraint is that you select these items such
that you will get the maximum profit on selling.

Two types of Knapsack problems are there.

1) 0/1 knapsack problem- here in this problem either you can pick the item
completely or you cannot pick any item that is, 0 means you have not picked that
item and 1 means you have picked that item.

E g : item we have selected is laptop and it is having a fixed weight too.so we have
to choose the item fully and not the screen or keypad or its any components.This
problem can be solved using dynamic programming.
2) Fractional knapsack problem- here in this problem it is not compulsory to pick
the whole item and you can choose the components or fractions of items
chosen.This problem can be solved using greedy method

3.3.1 Tutorial problem

Weight (3,4,5,6)

Values( profit) (2,3,1,4)

Maximum weight of container -8

Number of items -4

Solution:

Let i be the number of items to be in the container

Pi be the profit of choosing i th


item

Wi be the weight corresponding to i th item

Note: while filling the weight Wi column always fill in ascending order

Pi Wi i ↓ w→ Weight of container

0 1 2 3 4 5 6 7 8

2 3 1

3 4 2

4 5 3

1 6 4

Here the problem is divided into 8 sub steps and solving the problem for
maximizing profit how many items need to be filled from the four items and the
constraint is maximum weight should not exceed 8.
To start filling the profit in the empty cells, first check the no of items and weight
of container both are zero that is, we are selecting a bag/ container having weight
zero so we cannot select any items.so in first stage filling all the columns zero.First
row means we have no items to select but 8 containers or bag to fill the zero
items , so first row also will be zero.

Pi Wi i ↓ w→ Weight of container

0 1 2 3 4 5 6 7 8

0 0 0 0 0 0 0 0 0 0

2 3 1 0

3 4 2 0

4 5 3 0

1 6 4 0

stage 2

To fill the next row that is you have 1 item of weight 3 and profit 2 which can be
filled in a container of capacity / weight 3 or more.so put zero profit in second row
in container of weight 1 and 2. Now you can fill any other container from 3 to 8
with the same item 1 of same weight.

Pi Wi i ↓ w→ Weight of container

0 1 2 3 4 5 6 7 8

0 0 0 0 0 0 0 0 0 0

2 3 1 0 0 0 2 2 2 2 2 2

3 4 2 0

4 5 3 0

1 6 4 0

stage 3
To fill the next row that is you have item 1 f weight 3 and profit 2 and item 2 of
weight 4 and profit 3 which can be filled in a container of capacity / weight 3 or
more.so put zero profit in second row in container of weight 1 and 2. Now you can
fill any other container from 3 to 8 with the item 1 or item 2 maximizing profit.

Note :while filling each stage if there is a 0 to be filled check the row above and
copy that in the corresponding row

To fill in the container of weight 4 ,there two choices are there either select item
4 or not select it.if we are selecting item then provide corresponding profit in that
column that is 3

Next to fill in container of weight 5, the item 2 of weight 4 and profit 3 is chosen
balance weight is 5-4=1 and for balance weight 1 check the profit in the weight of
container 1 in previous row is zero.So taking Maximum of the sum of profits and the
profit in the row above that is Max (3+0 ,2)= 3 and that will be filled in that row.

Next to fill in container of weight 6,the item 2 of weight 4 and profit 3 is chosen
balance weight is 6-4=2 and for balance weight 2 check the profit in the weight of
container 2 in previous row is zero.So taking Maximum of the sum of profits and
the profit in the row above that is Max (3+0 ,2)= 3 and that will be filled in that
row.

Next to fill in container of weight 7,the item 2 of weight 4 and profit 3 is chosen
balance weight is 7-4=3 and for balance weight 3 check the profit in the weight of
container3 in previous row is two.So taking Maximum of the sum of profits and the
profit in the row above that is Max (3+2 ,2)= 5 and that will be filled in that row.

Next to fill in container of weight 8,the item 2 of weight 4 and profit 3 is chosen
balance weight is 8-4=4 and for balance weight 4 check the profit in the weight of
container 4 in previous row is two.So taking Maximum of the sum of profits and
the profit in the row above that is Max (3+2 ,2)= 5 and that will be filled in that
row.
stage 4
Pi Wi i ↓ w→ Weight of container

0 1 2 3 4 5 6 7 8

0 0 0 0 0 0 0 0 0 0

2 3 1 0 0 0 2 2 2 2 2 2

3 4 2 0 0 0 2 3 3 3 5 5

4 5 3 0

1 6 4 0

Similarly fill stage 4

Pi Wi i ↓ w→ Weight of container

0 1 2 3 4 5 6 7 8

stage 0 0 0 0 0 0 0 0 0 0 5

2 3 1 0 0 0 2 2 2 2 2 2

3 4 2 0 0 0 2 3 3 3 5 5

4 5 3 0 0 0 2 3 4 4 5 6

1 6 4 0

Pi Wi i ↓ w→ Weight of container

0 1 2 3 4 5 6 7 8

0 0 0 0 0 0 0 0 0 0

2 3 1 0 0 0 2 2 2 2 2 2 The final
maximum
3 4 2 0 0 0 2 3 3 3 5 5 profit
obtained
4 5 3 0 0 0 2 3 4 4 5 6
from
1 6 4 0 0 0 2 3 4 4 5 6 knapsack
problem is 6

There is a formula for filling each cell

m (i , w) = Max ( m { i -1 , w} , m { i - 1,w-w[i]} +P (i ) )

m (4,7) = Max ( m { 3,7} , m {3,7-6} +1)

= Max (5 , 0+1)

= 5

Now to select which all items chosen to get the maximized profit of 6.

We have four items and to select the items for maximized profit put the pointer ←
in maximized profit 6 and just check out above cell, if you have same value in the
above cell then you should change pointer ← to above value .

Now go to the upper row and in upper row you have 5, in that case we will select
item 3. Now item 3 profit is 4 and maximum profit is 6 remaining 2.

Now check the above row if there is 2. Now pointer ← is here.Now check the
above row if there is 2 and shift the pointer to that 2.the above row is zero so final
pointer is in item 1 of profit 2

Pi Wi i ↓ w→ Weight of container

0 1 2 3 4 5 6 7 8

0 0 0 0 0 0 0 0 0 0

2 3 1 0 0 0 2 2 2 2 2 2

3 4 2 0 0 0 2 3 3 3 5 5

4 5 3 0 0 0 2 3 4 4 5 6←

1 6 4 0 0 0 2 3 4 4 5 6←

So selected items are item 1 of profit 2 and item 4 of profit 4 making total profit 6
Pi Wi i ↓ w→ Weight of container

0 1 2 3 4 5 6 7 8

0 0 0 0 0 0 0 0 0 0 3.2.2 Assignment
Question
2 3 1 0 0 0 2 2 2 2 2 2
← A vessel is to be
loaded with stocks of
3 4 2 0 0 0 2 3 3 3 5 5
3 items. Each item ‘i’
4 5 3 0 0 0 2 3 4 4 5 6← has a weight of wi and
a value of vi. The
1 6 4 0 0 0 2 3 4 4 5 6
maximum cargo
weight the vessel can take is 5 and the details of the three items are as
follows.Develop the recursive equation for the above case and find the most
valuable cargo load without exceeding the maximum cargo weight by using
dynamic programming.

i wi vi

1 1 30

2 3 80

3 2 65

Product allocation problem

3.2.3 Tutorial problem

A company has 8 salesmen, who have to be allocated to four marketing zones. The
return of profit from each zone depends upon the number of salesmen working that
zone. The expected returns for different number of salesmen in different zones, as
estimated from the past records, are given below. Determine the optimal
allocation policy.

SALES MARKETING IN ZONES Rs. X 000


No of salesman Zone 1 Zone 2 Zone 3 Zone 4

0 45 30 35 42

1 58 45 45 54

2 70 60 52 60

3 82 70 64 70

4 93 79 72 82

5 101 90 82 95

6 108 98 93 102

7 113 105 98 110

8 118 110 100 110

Solution:
The problem here is how many salesmen are to be allocated to each zone to
maximize the total return. In this problem each zone can be considered as a stage,
number of salesmen in each stage as decision variables. Number of salesmen
available for allocation at a stage is the state variable of the problem. Here let us
consider the first stage (zone 1) and add to it the second stage (zone 2) and see
what will be the optimal return and optimal allocation. Remember, that allocation
of salesmen for each zone may be 0, 1, 2, …and 8. See the table below to
understand how we can allocate salesmen between zones 1 and 2.

Zone 1 0 1 2 3 4 5 6 7 8
Procedure:
Salesmen If we want
to allocate
zero
Return 45 58 70 82 93 101 108 113 118 salesmen,
then zero
to zone 1
Zone 2 Return
and zero to

Salesmen zone 2 and


the total
0 30 75 88 100 112 123 131 138 143 148 outcome is
30 + 45 =
1 45 90 103 115 127 138 146 153 158
Rs. 75 ×
2 60 105 118 130 142 153 161 168 1000. This
is written
3 70 115 128 140 152 163 171
in the
4 79 124 137 149 161 172 table
where
5 90 135 148 160 172
lines from

6 98 143 156 168 zero from


zone 1 and
7 105 150 163 zone 2
intersect.
8 110 155
As this is
the only entry in the diagonal line it is made bold.
When company wants to allocate 1 salesman to two zones, the allocation is zero to
zone 1 and 1 to zone 2 or 1 to zone 1 and zero to zone 2. The outcomes are
entered where the horizontals from zone 2 and verticals from zone 1 intersect.
Higher number is written in bold numbers. In this example, the outcomes are 90
and 88, 90 is written in bold. Similarly we have to allocate 8 salesmen and write
the

outcomes and bold the highest outcome in the diagonal. Sometimes, it may happen
that there may be two or more same numbers indicating highest outcome. All these
are written in bold letter.

(Note: Instead on writing highest in bold letter, we can encircle the element or
enclose it in a square or superscribe with a star.)

Number 0 1 2 3 4 5 6 7 8
of
salesmen.

Zone 1 0 0 0 1 2 3 4 4 4 3

Zone 2 0 1 2 2 2 2 2 3 4 5

Outcome 75 90 105 118 130 142 153 163 172 172


in Rs. ×
1000

Now in the second stage, let us combine zone 3 and zone 4 and get the total
market returns.

Zone 3 0 1 2 3 4 5 6 7 8

Salesmen

Return 35 45 52 64 72 82 93 98 100
Zone 4 Return Now the
table
Salesmen below
shows the
0 42 77 87 94 106 114 124 140 142 allocation
135 and the
outcomes
for zone 3
1 54 89 99 106 118 126 136 147 152 and zone 4.

2 60 95 112 124 132 142 153


105

3 70 105 134 142 152


115 122

4 82 117 134 146


127 154

5 95 130 140 147 159

6 102 137 147 154

7 110 145 155

8 110 145

Number 0 1 2 3 4 5 6 7 8
of
salesmen.

Zone 3 0 0 1 3 2 3 0 1 6 2 1 3

Zone 4 0 1 1 0 1 1 5 5 1 5 6 5
Outcome 89 99 106 106 118 130 140 147 147 147 159
in Rs. × 77
1000

In third stage we combine both zones 1 & 2 outcomes and zones 3 and 4 outcomes.

Zones 1 and 2 and zones 3 and 4 combined.

Total no of salesman 0 1 2 3 4 5 6 7 8

No of Zone 1 0 0 0 1 2 3 4 4 4 3
salesman in
each zone
Zone 2 0 1 2 2 2 2 2 3 4 5

Return 75 90 105 118 130 142 153 163 172 172


Total no of
salesman

No of salesman in
each zone

zone 3 zone
4

0 0 0 77 152 167 182 195 207 219 230 240 249

1 0 1 89 164 179 194 207 219 231 242 252

2 1 1 99 174 189 204 217 229 241 252

2 1 106 196 211 224 236 248

3 181
3 0 106

4 3 1 118 193 208 223 236 248

5 0 5 130 205 220 235 248

6 1 5 140 215 230 245

6 1 147

7 2 5 147 222 237

1 6 147

8 3 5 159 234
Optimal allocation table

Salesmen 0 1 2 3 4 5 6 7 8

zone 1 0 0 0 1 2 1 3 2 3 4 4 4

zone 2 0 2 2 2 2 2 2 2 2 2 3 2

zone 3 0 0 0 0 0 0 0 0 0 0 0 1

zone 4 0 0 0 0 1 0 0 1 1 1 1 1

Total return in
152 167 182 195 207 219 231 242 252
Rs. × 1000

The above table shows that how salesmen are allocated to various zones and the
optimal outcome for the allocation. Maximum outcome is Rs. 252 × 1000.

Inventory control problem

3.2.4 Tutorial problem

A manufacturing firm has a contract to supply lathe chucks as per the following
schedule. The product made during a month will be supplied at the end of the
month. The setup cost is Rs. 1000/-while the inventory carrying cost is Re. 1/- per
piece per month. In which month should the batches be produced and of what size,
so that the total of setup and inventory carrying cost are minimized?

months Number of items

January 100

February 200

March 300

April 400

May 400
June 300

Solution:

This problem is considered as six-stage problem and scheduling of inventory is done


in 6 stages by using dynamic programming technique, we can start from the last
month.

6th Stage: Month of June: To save the carrying cost, nothing should have been left
at the end of the month of May and also nothing should be left at the end of 6th
month, i.e. June, as this is the last month. Produce 300 units for which the setup
cost is Rs. 1000/- and no inventory carrying cost. Hence the total cost is Rs. 1000/-.

5th stage: Month of May: There are two alternatives. First alternative: Produce 700
units in 5th month and send 400 units and 300 parts will remain as inventory for
one month. Hence the total cost = Set up cost + inventory carrying cost for one
month =

Rs. 1000 + Rs. 300/- = Rs. 1300/-

Second alternative : Produce 400 units in 5th month and 300 units in 6th month
when the total cost is and send the goods in the respective month so that there will
be no inventory carrying cost. We have only two setup costs i.e. Rs. 1000 + Rs.
1000 = Rs. 2000/-

The first alternative is cheaper, hence instead of producing 400 units in 5th month
and 300 units in 6th month produce 700 units in 5th month and send 400 units to
market and maintain an inventory of 300 units.

Stage 4: 4th month: There are three alternatives.

(a) Produce 1100 units in 4th month and send 400 units in April to market and
maintain an inventory of 700 units for one month and another 300 units for a period
of 2 months. For which total cost is Setup cost for 1100 units + 2 months’ inventory
carrying cost for 300 units + 1 month inventory cost for 400 units = Rs. 1000 + Rs.
700 + Rs. 300 = Rs. 2000.

(b) Produce 300 units in 6th month and 800 units in 4th month at a cost of setup
cost of 6th month and setup cost of 4th month + inventory of 400 units for one
month. = Rs. 1000 + Rs. 1000 + Rs. 400 = Rs. 2400.
(c) Produce 700 units in 5th month and 400 units in 4th month at a cost of setup
cost of 5th and 4th months and inventory carrying cost for one month for 300 units
for 6th month. = Rs. 1000/- + Rs. 1000/- + Rs. 300/- = Rs. 2300/-

Out of all the three decisions, the first decision (a) is optimal. The firm has to
produce 1100 units in the 4th month at the cost of Rs. 2000/- .

Stage 3: 3rd month: There are four alternatives.

(a) Produce 1400 units in the third month at a cost of Setup cost of Rs. 1000/- +
Inventory carrying charges of Rs. 1100/- + 700/- + 300/- = Rs. 3100/-.

(b) Produce 300 units in 6th month and 1100 units in 3rd month at a cost of Setup
cost of Rs. 1000 + Rs. 1000/-) + inventory carrying cost of Rs. 800/- + Rs. 400/- =
Total Rs. 3200/-

(c) Produce 700 units in 5th month and 700 units in 3rd month at cost of Setup cost
of Rs. 1000 + Rs. 1000) + (inventory carrying cost of RS. 300/- + RS. 400/-) = Total
Rs. 2700/ -.

(d) Produce 1100 units in 5th month and 300 units in the 3rd month at cost of
(Setup cost of Rs. 1000/- + Rs. 1000/- + Inventory carrying charges of Rs. 700/- + Rs.
300/- = Rs. 3000/-.

The optimal decision at this stage is to produce 700 units in 5th month and the cost
of production and inventory maintenance is Rs. 2700/-.

Stage 2: At 2nd month. There are 5 alternatives and they are:

(a) Produce 1600 units in 2nd month at a cost of Setup cost of Rs. 1000/- +
inventory carrying charges of Rs. 1400 + 1100 + 700 + 300 = Total Rs. 4500/-.

(b) Produce 300 in 6th month and 1300 units in 2nd month at cost of Rs. 1000 +
1000+ 1100 + 800 + 400 = Total Rs. 4300/-.

(c) Produce 700 units in 5th month and 900 units in 2nd month at cost of Rs. 1300 +
1000 + 700 + 400 = Rs. 3400/-.

(d) Produce 1100 units in 4th month, 500 units in 2nd month at cost of Rs. 2000/-
+1000 + 300 = Rs. 3300/-.
(e) Produce 700 units in 3rd month, 700 in 5th month and 200 in 2nd month at cost
of Rs. 3000/- + Rs. 700/- = Total Rs. 3700/-.

The optimal decision rule is Produce 500 units in 2nd month and 1100 units in 4th
month at cost of Rs. 3300/-

1st stage: Month 1: There are 6 alternatives. They are:

(a) Produce 1700 units at cost of Rs.1000/- 1600 + 1400 + 1100 + 700 + 300 = Rs.
6100/-.

(b) Produce 300 units in 6th month and 1400 units in 1st month and the cost is: Rs.
100/- + 1000/- + Rs. 1300/- + 1100/- + 800/- + 400/- = Total Rs. 5600/-

(c) Produce 700 units in 5th month and 1000 units in the 1st month and the cost is
Rs. 1300 + 1000/- + 900/- + 700 + 400 = Total Rs. 4300/-.

(e) Produce 1100 units in 4th month and 600 units in 1st month and the cost is : Rs.
2000/- + 1000 + 500 + 300 = Total Rs. 3800/-

(f) Produce 700 units in 3rd month, and 700 in 5th month and 300 units in the 1st
month at a cost of Rs. 2700/- + 1000 + 200 = Rs. 3900/-.

(g) Produce 500 units in the 2nd month and 1100 units in the 4th month and 100
units in the 1st month at a cost of Rs. 3300/- + Rs. 1000/- = Total Rs. 4300/-

The optimal decision rule is to Produce 600 units in 1st month and 1100 units in 4th
month at a total cost of Rs. 3800/-.

Hence the minimum cost policy is to produce a batch of 600 units in January and a
batch of 1100 units in April, which gives a minimum of setup and inventory carrying
cost of Rs. 3800/-

3.2.4 Tutorial problem

A company has to supply the following number of items at the end of each month
Production during a month is available for supply at the end of the month. The
stock holding cost per month is Re. 1 per item. The setup cost is Rs. 900 per setup
and Rs. 2 per item. Find the optimal policy so that total cost may be minimum.

Solution:
The production cost Rs. 2 per item is always incurred, whether items are produced
in the beginning or at any other time.
Fixed cost = 1000 X 2 = Rs. 2000

Case I - April

Requirement = 400
Cost = Rs. 900 (setup cost)

Case II - March

We have the following alternatives.

1. Produce 700 (demand for March & April) items in the beginning of March.
Cost = 900 + (400 X 1) = Rs. 1300

2. Produce 300 items in March & 400 in April.


Cost = 900 + 900 = Rs. 1800

Hence, the optimal sub-policy for March is: Produce 700 items in March.

Case III - February

We have the following alternatives.

1. Produce 900 items in the beginning of February.


Cost = 900 + 700 X 1 + 400 X 1 = Rs. 2000

2. Produce 500 items now & 400 in April.


Cost = 900 + 300 X 1 + 900 = Rs. 2100

3. Produce 200 items now & 700 in March.


Cost = 900 + 1300 = Rs. 2200

The optimal sub-policy for March was to produce 700 items. Therefore, in February
we have not considered the following case: Produce 200 items now, 300 items in
March & 400 in April.
Hence, the optimal sub-policy for February is: Produce 900 items in February.

Case IV - January

We have the following alternatives.


1. Produce 1000 items in the starting of January.
Cost = 900 + (900 X 1 + 700 X 1 + 400 X 1) = Rs. 2900
2. Produce 600 items now & 400 in April.
Cost = 900 + 500 X 1 + 300 X 1+ 900 = Rs. 2600

3. Produce 300 items now & 700 in March.


Cost = 900 + 200 X 1 + 1300 = Rs. 2400

4. Produce 100 items now & 900 in February.


Cost = 900 + 2000 = Rs. 2900

The minimum cost is Rs. 2400. Hence, the best policy is: Produce 300 items in
January & 700 in March.

Shortest route problems

3.2.5 Tutorial problem

The inspection team wants to visit the following construction sites. Consider the
following diagram where circles denote sites, and lines between two such circles
represent highways connecting the sites. The numbers inside the circles represent
site numbers, and those given beside the lines denote the distances between the
sites connected by the lines. The problem is to find the shortest route from site 1 -

10

For a systematic approach to dynamic programming problem, consider the


following notations.

n = number of stages.
s = site variable.
dsj = immediate distance from entering site s to existing site j.
fn(s) = the overall optimal objective function with n more stages to go when he is in
site s.
jn(s) = a decision yielding fn(s).
The entire trip from site 1 to site 10 requires four stages (highways), regardless of
the particular routing. Now, the problem is to select these four highways so that
the total distance covered is least. The first highway has to be chosen from 1-2, 1-
3, or 1-4, as 1 is the starting state. Likewise, the second highway has to be chosen
from 2, 3, or 4, the third from 5, 6, or 7 and the fourth from 8 or 9.

There is one table for each possible stage n, namely, n = 1, 2, 3, and 4. We start
calculating distances between pair of states from stage 4 backwards. At the
beginning of stage 4, we can be in either 8 or 9 (states). We note that state 10 is
the only destination from both states 8 & 9. We summarize this information in the
format below.

Stage 4( n=1)

State(s) Decision j Best decision J1(s) Best distance F1(s)

10

8 8+0 10 9

9 6+0 10 6

Stage 3(n=2)

State(s) Decision j Best decision J1(s) Best distance F1(s)

8 9

5 6+9=15 8+6=14 9 14

6 4+9=13 9+6=15 8 13

7 3+9=12 7+6=13 8 12

The entries in second & third column are the sum of the immediate distance dsj to
go from state s to state j. In each row, we examine the sums to find the smallest.
Observe that f1(8) = 9 is added to each ds8 in the j = 8 column and f1(9) = 6 is
added to each ds9 in the j = 9 column. The above table shows that with two stages
left it is optimal to go to state 9 from state 5, and state 8 from states 6 & 7.

The analysis for n = 3 appears in the following table.

Stage 2( n=3)

State(s) Decision j Best decision Best distance


J1(s) F1(s)

5 6 7

2 6+14=20 8+13=21 9+12=21 5 20

3 5+14=19 4+13=17 6+12=18 6 17

4 5+14=19 5+13=18 7+12=19 6 18

Stage 1(n=4)

State(s) Decision j Best decision Best distance


J1(s) F1(s)

2 3 4

1 4+20=24 6+17=23 6+18=24 3 23

The computations terminate in the above table with n = 4. The shortest route from
state 1 to state 10 is given by 1-3-6-8-10, and the distance to be covered is 23.

3.2.6 Assignment problem

A Trucking company has to deliver a shipment of goods from city A to city D as


shown below. The numbers on the arcs represent the estimated driving times in
hours between adjacent cities. The company wants to determine the route
requiring the shortest travel time.Solve the problem and find the minimum time
and its associated optimal route.
3.2.7 Assignment Problem

Mr. Banerjee, a sales manager, has decided to travel from city 1 to city 10. He
wants to plan for minimum distance programme and visit maximum number of
branch offices as possible on the route. The route map of the various ways of
reaching city 10 from city 1 is shown below. The numbers on the arrow indicates
the distance in km. (× 100). Suggest a feasible minimum path plan to Mr. Banerjee.

Workforce size model

Labor needs in construction projects can be met through hiring and firing of
workers .Both activities incur cost.The goal is to minimize the total cost of labor
needed for the project.DP recurrsive equation is given by

F n+1 (x n) =0

fi(xi-1) =min xi≧ bi {c1(xi-bi) + c2 (xi-xi-1) + f i+1 (xi+1 (xi) }

Computations start at stage n and ends at stage 1 i=1,2,3,4,...n

3.2.8 Tutorial problem


A contractor estimates that the size of the work force needed over the next 5 years
is 5,7,8,4 and 6 workers respectively.Excess labor kept on the force will cost $ 300
per week and hiring new worker in any week will incur a fixed cost of $ 400 plus
$ 200 per worker per week.Calculate the optimized total cost.

weeks week week week week week


1 2 3 4 5

Min 5 7 8 4 6
requirement of
workforce as
per contractor

States in 4
workforce
5 5
(Assumption :try
to have more
6 6 6
employees than
needed )

7 7 7 7

8 8 8 8 8

Solution:Stage 5
C1=cost function for excess labor kept on force in week
C2 =cost function for new hiring of labor in a week kept on force
f5 = C1( x5- 6) +C2 (x5-x4)

Stage (possible Decision Best Optimized cost


employees in decision f5
previous week) (best end
state)
(6 workers needed) f5 =
C1( x5- 6) +C2 (x5-x4)

current week work force

X5 =6
4 300(0)+400+200(2) = 800 4 800

5 300(0)+400+200(1) = 600 5 600

6 300(0)+0 = 0 6 0

Stage 4
C1=cost function for excess labor kept on force in week
C2 =cost function for new hiring of labor in a week kept on force
f4 = C1( x4- 4) +C2 (x4-x3) +f5(x4)

Stage Decision Best Optimized


decision cost f4
(4 workers needed)

f4 = C1( x4- 4) +C2 (x4-x3) +f5(x4)

X3 x4 =4 x4 =5 x4=6

8 300(0) +0 + 300(1)+0+600 300(2)+0+0 6 600


800 =800 =900 =600

Stage 3
C1=cost function for excess labor kept on force in week
C2 =cost function for new hiring of labor in a week kept on force
f3 = C1( x3- 8) +C2 (x3-x2) +f4(x3)

Stage Decision Best Optimized


decision cost
(8 workers needed) f3
X3 =8

f3 = C1( x3- 8) +C2 (x3-x2)


+f4(x3)

previous week current week work


workforce force
X2 X3 =8

7 300(0)+400+200(1) 7 1200
+600= 1200

8 300(0)+0+ +600 8 600


= 600

Stage 2
C1=cost function for excess labor kept on force in week
C2 =cost function for new hiring of labor in a week kept on force
f2= C1( x2- 7) +C2 (x2-x1) +f3(x2)

Stage 1
C1=cost function for
Stage Decision Best Optimized
excess labor kept on
decision cost f4
(7 workers needed) force in week
C2 =cost function for
f2= C1( x2- 7) +C2 (x2-x1) +f3(x2) new hiring of labor in
a week kept on force
X1 x2 =7 x2=8
f1= C1( x1- 5) +C2 (x1-x0)
5 300(0) +400 + 300(1)+400+200(3) 8 1900 +f2(x1)
200(2)+1200 +600 =1900
=2000

6 300(0) +400 + 300(1)+400+200(2) 8 1700


200(1)+1200 +600 =1700
=1800

7 300(0) +0 + 300(1)+400+200(1) 7 1200


+1200 =1200 +600 =1500

8 300(0) +0 + 300(1)+0+ 8 900


+1200 =1200 +600 = 900

Sta Decision Best Optimi


ge decisi zed
(5 workers needed) on cost
f1
f1= C1( x1- 5) +C2 (x1-x0) +f2(x1)

X0 x1 x1 =6 x1=7 x1=8
=5
0 300(0) 300(1)+400 300(2)+400+200( 300(2)+400+200( 5 3300
+400 + +200 (6) 7)+1200 =3600 8)+900 =3500
200 (5) +1700
+1900=3 =3600
300

Week Minimum Actual Decision cost


labor labor
force force

1 5 5 Hire 5 400+200(5) =1400


workers

2 7 8 Hire 3 400+200(3)+300(1)=1300
workers

3 8 8 No 0
change

4 4 6 fire 2 300(2) =600


workers

5 6 6 No 0
change

Total cost 3300

You might also like