Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

ENTERPRISE SIMULATION AND OPTIMIZATION

LABORATORY
FACULTY OF INDUSTRIAL ENGINEERING

DEL INSTITUTE OF TECHNOLOGY

Module 2
Dynamic Programming
Shortest Path Problem and Maximum Flow Problem

2017
Dynamic Programming
1. Introduction
This module emphasized the wide applicability of dynamic
programming. We continue to broaden our horizons in this chapter by
discussing particularly important (and related) 2 types of dynamic
programming problems. Type number one called the Shortest Path problem,
received this name because many of its applications involve determining how
to optimally cost base on travel distance. Type number two called the
maximum flow problem, received this name because many of its applications
involve determining how to optimally flow problem. This module discuss how
to solve dynamic programming by using software application called Solver.
Solver is part of a suite of commands sometimes called what-if analysis
tools. With Solver, you can find an optimal (maximum or minimum) value for
a formula in one cell - called the objective cell - subject to constraints, or
limits, on the values of other formula cells on a worksheet. Solver works with
a group of cells, called decision variables or simply variable cells, that
participate in computing the formulas in the objective and constraint cells.
Solver adjusts the values in the decision variable cells to satisfy the limits on
constraint cells and produce the result you want for the objective cell.

2. Theoretical Basic
There are numerous references about engineering economic analysis focusing
on the main analysis method listed above. The following are listed to help you
start dig into the subject more :
1. Winston W.L, (2004), Operation Research Application and Algorithms 4th
ed. Brooks/Cole, Cengage Learning, USA.
2. Taha H.A, (2011), Operation Research an Introduction 9th ed. Prentice Hall,
New York.

3. Purpose
To explain solver application of linear programming on assignment problem,
Capital Investment and transportation problem.
A. Shortest Path Problem
1. Tutorial Case Study
You need to take a trip by car to another town that you have never visited
before. Therefore, you are studying a map to determine the shortest route to
your destination. Depending on which route you choose, there are five other
towns (call them A, B, C, D, and E) that you might pass through on the way.
The map shows the mileage along each road that directly connects two towns
without any intervening towns.

2. Problem Model
Use the solver in Excel to find the shortest path from node S to node T in an
undirected network. Points in a network are called nodes (S, A, B, C, D, E and
T). Lines in a network are called arcs (SA, SB, SC, AC, etc). The model we
are going to solve looks as follows in Excel.
3. Analytic Process
1. To formulate this transportation problem, answer the following three
questions.
a. What are the decisions to be made? For this problem, we need Excel
to find out if an arc is on the shortest path or not (Yes=1, No=0). For
example, if SB is part of the shortest path, cell F5 equals 1. If not, cell
F5 equals 0.
b. What are the constraints on these decisions? The Net Flow (Flow Out
- Flow In) of each node should be equal to Supply/Demand. Node S
should only have one outgoing arc (Net Flow = 1). Node T should only
have one ingoing arc (Net Flow = -1). All other nodes should have one
outgoing arc and one ingoing arc if the node is on the shortest path
(Net Flow = 0) or no flow (Net Flow = 0).
c. What is the overall measure of performance for these decisions? The
overall measure of performance is the total distance of the shortest
path, so the objective is to minimize this quantity.

2. To make the model easier to understand, name the following ranges.


Range Name Cells
From B4:B21
To C4:C21
Distance D4:D21
Go F4:F21
Net Flow I4:I10
Supply Demand K4:K10
Total Distance F23

3. Insert the following functions.


Explanation: The SUMIF functions calculate the Net Flow of each node. For
node S, the SUMIF function sums the values in the Go column with an "S" in
the From column. As a result, only cell F4, F5 or F6 can be 1 (one outgoing
arc). For node T, the SUMIF function sums the values in the Go column with
a "T" in the To column. As a result, only cell F15, F18 or F21 can be 1 (one
ingoing arc). For all other nodes, Excel looks in the From and To column.
Total Distance equals the sumproduct of Distance and Go.
With this formulation, it becomes easy to analyze any trial solution. For
example, the path SBET has a total distance of 16.
It is not necessary to use trial and error. We shall describe next how the Excel
Solver can be used to quickly find the optimal solution.

4. Solve The Model


To find the optimal solution, execute the following steps.
1. On the data tab, click solver.

Note: can’t find the solver button? Click here to load the Solver add-in.
Enter the solver parameters (read-on). The result should be consistent with the
picture below.
You have the choice of typing the range names or clicking on the cells in the
spreadsheet.
2. Enter Total Distance for the objective.
3. Click Min.
4. Enter Go for the changing variable Cells.
5. Click Add to enter the following constraint.

Note: binary variables are either 0 or 1.

6. Check 'Make Unconstrained Variables Non-Negative' and select 'Simplex


LP'.
7. Finally, click Solve.

5. Result
The Optimal Solution:

6. Conclusion
SADCT is the shortest path with a total distance of 11.

7. Case Study
You need to take a trip by car to another town that you have never visited before.
Therefore, you are studying a map to determine the shortest route to your destination.
Depending on which route you choose, there are nine other towns (call them A, B, C,
D, E, F, G, H and I) that you might pass through on the way. The map shows the
mileage along each road that directly connects two towns without any intervening
towns. These numbers are summarized in the following table, where a dash indicates
that there is no road directly connecting these two towns without going through any
other towns.

Town Miles Between Adjacent Towns


A B C D E F G H I Destination
Origin 40 60 45 -- -- -- -- -- -- --
A -- -- -- 50 70 75 -- -- -- --
B -- -- 46 30 50 -- -- -- --
C -- 60 62 67 -- -- -- --
D -- -- -- 67 54 -- --
E -- 45 68 -- --
F -- 69 68 -- --
G -- -- 55 --
H -- 58 --
I -- 77
B. Maximum Flow Problem

1. Tutorial Case Study


City water manager wants to determine a flow plan that will maximize the
flow of water from city A to city G. The water must distribute to every city on
the water network. Figure 1 will shown the network and the capacity of the
arc. Help the manager to find the maximum flow of the water

2. Problem
Use the solver in Excel to find the maximum flow from node S to node T in a
directed network. Points in a network are called nodes ( A, B, C, D, E, F and
G). Lines in a network are called arcs (AB, AC, AD, BD, etc). The model we
are going to solve looks as follows in Excel.

3. Analytic Process
1. To formulate this maximum flow problem, answer the following three
questions.
a. What are the decisions to be made? For this problem, we need Excel
to find the flow on each arc. For example, if the flow on AB is 5, cell
D5 equals 5.
b. What are the constraints on these decisions? The Net Flow (Flow Out
- Flow In) of node A, B, C, D,F and E should be equal to 0. In other
words, Flow Out = Flow In. Also, each arc has a fixed capacity. The
flow on each arc should be less than this capacity.
c. What is the overall measure of performance for these decisions? The
overall measure of performance is the maximum flow, so the objective
is to maximize this quantity. The maximum flow equals the Flow Out
of node A.

2. To make the model easier to understand, name the following ranges.


Range Name Cells
From B5:B22
To C5:C22
Flow Capacity D5:D22
Supply Demand J5:J10
Maximum Flow F25

3. Insert the following functions.

Explanation: The SUMIF functions calculate the Net Flow of each node. For
node B, the first SUMIF function sums the values in the Flow column with an
"B" in the From column (Flow Out). The second SUMIF function sums the
values in the Flow column with an "A" in the To column (Flow In). Maximum
Flow equals the value in cell F25, which is the flow out of node A. Because
node B, C, D, E, F and G have a Net Flow of 0, Flow Out of node A will equal
Flow In of node G.
With this formulation, it becomes easy to analyze any trial solution. For
example, the path ADG with a flow of 5. The path ADEG with a flow of 2.
The path ACFG with a flow of 3. These paths give a total flow of 10.

It is not necessary to use trial and error. We shall describe next how the Excel
Solver can be used to quickly find the optimal solution.

4. Solve The Model


To find the optimal solution, execute the following steps.
8. On the data tab, click solver.

Note: can’t find the solver button? Click here to load the Solver add-in.
Enter the solver parameters (read-on). The result should be consistent with the
picture below.

You have the choice of typing the range names or clicking on the cells in the
spreadsheet.
9. Enter TotalDistance for the objective.
10. Click Min.
11. Enter Go for the changing variable Cells.
12. Click Add to enter the following constraint.
13. Click Add to enter the following constraint.
14. Finally, click Solve.

5. Result

The Optimal Solution:


6. Conclusion
Conclusion: the path ADG with a flow of 5. The path ADEG with a flow of 2.
The path ACFG with a flow of 3. These paths give a maximum flow of 10.

7. Case Study
City water manager wants to determine a flow plan that will maximize the
flow of water from city 1 to city 9. The water must distribute to every city on
the water network. Figure 1 will shown the network and the capacity of the
arc. Help the manager to find the maximum flow of the water!

You might also like