User Documentation

advertisement
User Documentation
2011
LRT Line 2 Simulations
Photo taken by: JC Salamat, retrieved Feb. 25, 2011 from http://philippine-fleetlist.blogspot.com
Belleza, Alvin
Dapito, Aaron
Go, Earvin Rayner
Naniong, Jason Martin
M AMF 2011
CS 268 | Kardi Teknomo
Belleza · Dapito · Go · Naniong | M AMF
1
MODELING AND SIMULATION – K. TEKNOMO
TABLE OF CONTENTS
I.
Overview
1
II.
Basic Rules in Simulation
3
Excel Options
3
Input Tables
5
Control Panel
9
III. Pulse Generation
10
IV. Agent’s Barrier Behavior
13
V.
Splitting Queues
17
Two Vendors
18
Three Vendors
19
Four to Six Vendors
21
VI. Train Arrivals
25
VII. Passenger Count
27
Belleza · Dapito · Go · Naniong | M AMF
i
MODELING AND SIMULATION – K. TEKNOMO
OVERVIEW
For this project, one of the main focus is the number of ticket-selling queues, some of which
considered as human sellers, some as automatic ticket-vending machines. The difference of
the kinds of sellers will be described shortly.
Human sellers are those which have humans selling the tickets. This includes the Senior
Citizen’s assistance lane, the Persons-with-Disability assistance lane, and the Stored Value
lane, which is for the multiple-journey tickets. We assigned the interval (3, 8) to be the
possible waiting times for these kinds of ticket-sellers. The Excel function
RANDBETWEEN(3, 8) generates this. More about the aforementioned function is
explained in a later section of this paper.
Automatic ticket-vending machines are similar to the softdrinks and food vending machines
in school. Simply insert coins, or cash for rare occasions wherein a vending machine accepts
paper money, and choose the destination. The machine will eject a single-journey card,a nd
give out change as necessary. Since not all have exact amounts, it may take time, but since
it is a machine, it is expected to perform uniformly for everyone. Hence the interval (5, 7) is
assigned as waiting times for this, using the Excel function RANDBETWEEN (5, 7).
The following files are to be used for simulation:

"LRT MAS Final - 2 Queues" gives the simulation for 2 queues, one human seller
and one ticket-vending machine.

"LRT MAS Final - 3 Queues" gives the simulation for 3 queues, one human seller
and two ticket-vending machines.

"LRT MAS Final - 4 Queues" gives the simulation for 4 queues, one human seller
and three ticket-vending machines.

"LRT MAS Final - 5 Queues" gives the simulation for 5 queues, one human seller
and four ticket-vending machines.

"LRT MAS Final - 6 Queues" gives the simulation for 6 queues, two human sellers
and four ticket-vending machines.
Belleza · Dapito · Go · Naniong | M AMF
1
MODELING AND SIMULATION – K. TEKNOMO
We are looking for the following data in the simulations to be done:
1. The number of time steps it takes for one queue to become "full queue". The basis
here is the counter. More will be explained in a later section of this paper.
2. The number of passengers that are able to enter the 12 trains (there are 12 lines
given for storing data)
For purposes of generating results for the project, the group decided to take on the extreme
case of having the density equal to one, signifying that a person will enter for every time
interval. This mimics the amount of people that are supposedly riding the LRT, during
lunch time or break hours, since the group chose the starting time to be 11:30.
More details about the actual simulations are discussed in the accompanying Project
Overview paper, which contains the scope of the study, as well as the results, analyses and
recommendations regarding the project. See the accompanying paper for details of the
project.
This document is meant to be a guide for future programmers attempting to further this
project and making it more relevant to the time and realistic. As such, this document will
cover aspects of the program, from the very basic rules, to the Mathematics and
programming behind the simulation.
Belleza · Dapito · Go · Naniong | M AMF
2
MODELING AND SIMULATION – K. TEKNOMO
BASIC RULES IN SIMULATION
The aim of this document is to provide any user with detailed information on running the
accompanying program. Note that we have several programs, for different number of
queues. Please use the main program first, that with 4 queues for the ticket-selling. That
particular program aims to simulate the actual happenings in the Katipunan Station.
The next sections will give a short run-through as to how to run the simulations. After
which, sections will be included to explain how the simulations actually work. Hence, this
document does not only give the user the methods of using the files, but also gives the user
the chance to understand for himself the logic behind the programs.
Additional information about the project, the background of the company, and the actual
problem can be found in a separate document.
1. Excel Options. Before any simulation begins, the user should make sure that certain
Excel settings should be made to ensure that the simulation will run smoothly. The
screenshots below will show the process on how this will work.
1. Click on the Microsoft Office Button
, to reveal the drop-down menu. This
drop-down menu includes all basic functions in opening, saving, loading and
closing files.
2. Click on the button Excel Options
to be found on the bottom-
right corner of the drop-down menu, next to the Exit Excel button. This will
reveal a new message box. This Excel Options button gives the user the ability to
change aspects of the Excel and how it functions.
Belleza · Dapito · Go · Naniong | M AMF
3
MODELING AND SIMULATION – K. TEKNOMO
3. On the choices on the left, click on Formulas, in orange in the screenshot above.
4. Change the “Maximum Iterations” to 1 so that each counter will only give 1
iteration per push of the F9 key.
5. Check the box beside “Enable Iterative Calculation” so no error will result when
the user hits the F9 key once s/he is starting the simulation.
6. When a dialog box with the words “Circular Reference Warning”, similar to the
one below pops-up, it means that the user did not do as instructed in steps 1-5.
Repeat steps 1-5 until the user gets it correctly.
Belleza · Dapito · Go · Naniong | M AMF
4
MODELING AND SIMULATION – K. TEKNOMO
2. INPUT TABLES. A separate worksheet includes an input table which the user can
change, depending on data s/he gathered or conceptualized. The table includes data on
time intervals, the interarrival times, and the maximum density, which will be explain
in a later section of the paper. The following table summarizes the data input by the
group for purposes of simulation:
Time Range
Frequency
Density
5:00
7:00
6
0.5
7:00
9:00
5
0.666667
9:00
11:30
4
0.833333
11:30
14:00
3
1
14:00
16:00
5
0.666667
16:00
18:00
4
0.833333
18:00
20:00
7
0.333333
20:00
22:00
8
0.166667
The time intervals will be used as basis for the getting the frequency of trains.
Frequency here is taken to be in minutes. Hence, 6 above for 5:00 to 7:00 means the
interarrival time between trains in that time period is 6 minutes.
An assumption here is that once the arrival time of the next train depends on the time
the train arrived now. It doesn’t matter whether the next train arrives at the next time
range. For example, if the train now arrived at 11:27, then from the table above, the
next train will arrive 4 minutes later, that is, at 11:31, which means that it is already in
the next time range of 11:30 – 14:00, which has a different frequency altogether.
The details of the use of this table will be explained in a later section of this paper.
Three input tables are present below the simulation area, as seen in the screenshot
below:
Belleza · Dapito · Go · Naniong | M AMF
5
MODELING AND SIMULATION – K. TEKNOMO
Encircled in red is the table which needs an input from the user. The user has to define
two things
1. Efficiency of the guards at the checkpoint. This signifies how the guards
whether the guards will finish the waiting time at checkpoint or will only make
the people wait
2. Starting Time. The user has to specify a time at which the simulation will
start, Time allowed is from 05:00 to 22:00. Use military timing in inputting data.
Note that the starting time will mean what time the LRT station will open.
These manual inputs should be done before starting the counter.
Aside from these manual inputs, the screenshot above shows two other tables. The one
below the Manual Inputs Table is the Automatically-Generated Variables table which
includes the following:
1. Waiting time at Checkpoint. This tab randomly generates waiting times for
people queuing for the guard checkpoints. It randomly generates the integer
numbers from 5 to 20 as waiting times, which will signify the time it will take
before a person leaves. The maximum cap is set at 20 so that people can surely
leave the checkpoint. Also, the randomness of it shows the different behaviors of
guards, from being too relaxed to being too strict, esp. during Christmas season.
Belleza · Dapito · Go · Naniong | M AMF
6
MODELING AND SIMULATION – K. TEKNOMO
The following code is used to generate the random numbers:
RANDBETWEEN(5,20)
The RANDBETWEEN(a,b) function gives random integer from the interval
specified. In the case of the Waiting time at checkpoint, it generates a random
number from 5 to 20.
2. Density of People. This value is made in inverse proportion with the waiting
times per person. For each time interval, a certain number of minutes is
allocated as the interarrival times of trains in that time period. It should also be
noted that instead of just a value for the density, the group employed the use of a
random number on a certain interval. The interval for each interarrival time is
shown in the table below:
Interarrival
Minimum
Maximum
Time
Density
Density
8
0
1/6
7
1/6
1/3
6
1/3
1/2
5
1/2
2/3
4
2/3
5/6
3
5/6
1
Notice that what we did here is we divided the density into 6 intervals, equally
spaced. The highest possible interval of (5/6, 1) is assigned to the shortest
interarrival time. There is a simple function which can help in getting the
density from this table. Since this table is in a different worksheet entitled “LRT
Time”, the following function is placed in the “Density” box:
Belleza · Dapito · Go · Naniong | M AMF
7
MODELING AND SIMULATION – K. TEKNOMO
=IF($G$2="",RAND()*(LOOKUP(C5,'LRT Time'!A2:A9,'LRT
Time'!D2:D9)-(LOOKUP(C5,'LRT Time'!A2:A9,'LRT Time'!D2:D9)1/6))+LOOKUP(C5,'LRT Time'!A2:A9,'LRT Time'!D2:D9)-1/6,0)
This function basically looks-up the current time from the first column of the
time range. It should be noted that the values in the first column should be
arranged in order. The reason for this is that the look-up value searches from top
to bottom of the list, and finds the largest value less than or equal to the
reference value, which in our case is the current time.
Once the said value is found, the look-up function above searches the same row,
for the column specified. In our case, the look-up function looks for the maximum
density value.
The long Rand() formula above is simply this Rand() * (b – a) + a, where [a, b] is
the time interval. In our case, this is simply the value generated by the look-up
function minus 1/6 until the value generated by the look-up function. The long
function above will then generate a random number in that interval.
To be specific, supposing the time now is 11:42. That falls under the time range
11:30 – 14:00. Using the look-up function, it will generate the density value of 1.
Hence, the range of the density is (1 – 1/6, 1) or simply [5/6, 1]. The density will
then be a random number in that time interval, inclusive of the end points.
3. Seller Counters. Part of our simulation is to have different number of ticketselling machines. Hence, we have different programs which simulate the
different number of queues. The reason for this is that there is a different
formula per queue depending on their number. What remains constant however
is that there is always 1 human seller, and the rest are made as machines. This
is in-line with Katipunan Station having ticket-vending machines, and only one
human seller for the multiple-journey tickets. Note however that we are not
differentiating between single-journey tickets and multiple-journey tickets in our
simulation.
Belleza · Dapito · Go · Naniong | M AMF
8
MODELING AND SIMULATION – K. TEKNOMO
To get the time for each Machine Seller, which are numbered 1 through 3 for the
main program (that with 4 queues for tickets), random integers are generated
between one and 2 using the following formula:
ROUND(RANDBETWEEN(1,2),0)
Similar to number 1, this function generates random integers, which could only
be either 1 or 2 as the interval specifies.
To get the time for the Human Seller, the same function is used except that the
interval is now [3, 4], which means that it will only generate a number which
could either be 3 or 4. The following shows the code used:
ROUND(RANDBETWEEN(3,4),0)
These cells should not at all be changed unless the user deemed it best to just manually
input these variables as well. Note that for our queuing analysis, we manually changed
the density of people to 1 so we can take into account the worst case scenario, which is
that of having a huge demand of people, all of which keep entering Katipunan Station.
3. CONTROL PANEL. The Upper left hand corner
of the simulation space is reserved for the
control panel. This control panel included the
control button, the counter and the Current
Time, as seen in the screenshot below:
1. Control. Simply put, when the control
is erased, the counter begins.
2. The counter adds one to itself for every push of the F9 button.
3. The current time starts from the input on Starting Time, as explained earlier.
This time moves as the counter moves. Each tick of the counter is equivalent to 1
tick in the number of seconds. Since Excel has a built-in time function, once the
number of seconds reaches 60, it automatically adds 1 to the number of minutes
and resets the number of seconds to 0.
Belleza · Dapito · Go · Naniong | M AMF
9
MODELING AND SIMULATION – K. TEKNOMO
PULSE GENERATION
In this tutorial we will show how, using MS Excel, we can generate pulses and simulate
behavior of agents when faced with a barrier. In this way we can better simulate the
behavior of queueing people in our LRT system.
First, what is a pulse? In our previous lessons, it’s an input stimulus that gradually
changes the behavior of the entire system. Picture a series of bits that are initially set to 0.
When the pulse starts at the front of the line and becomes 1, this 1 will travel gradually
through the line, while all the rest remain at 0, until a new pulse is generated.
The screenshot below shows how our pulse is represented in MS Excel. Our main system is
row 5; we used conditional formatting to make the circle yellow if it’s a 0 (no pulse) and
green if it’s 1 (pulse/person on that spot).
The first cell on that row (E5) is the pulse generator. It blinks 1 if a generated random
number is between [0, 0.2), and 0 if it’s between [0.2, 1]. The rest of the rows will then react
to this stimulus. We can change the “frequency” of the pulses by just changing the value of
cell B4 to higher or lower.
Belleza · Dapito · Go · Naniong | M AMF
10
MODELING AND SIMULATION – K. TEKNOMO
Basically the main idea is to copy the value in the previous cell, that way the pulse can
travel throughout the line. Roughly:
In cell F5: IF(E5=1, 1, 0)
However, if you do this, it will just result in a row of zeros or a row of one’s every time. This
is because every time you update the counter, all the cells will be updated simultaneously.
This is kind of like 1D CA in that there is parallel processing – each cell will be affected
by the behavior of its immediate neighbor, and get updated simultaneously.
The trick is to represent the value of the previous cell somehow before it gets updated. This
is the purpose of the bottom row (row 6).
Basically what we do is look at the counter (we’ve shown how to iterate counters in a
previous tutorial).
If the counter is odd (MOD(E2,2)=1), we update the bottom row by copying the value
above it. This will represent the value of the cell before it’s updated. Otherwise just retain
current value of cell.
If the counter is even (MOD(E2,2)=0) we update the top row by copying the value of the
cell to its bottom left (the previous value of the cell to its left before it was updated).
Otherwise just retain current value of cell. This is shown in the screenshot below.
Belleza · Dapito · Go · Naniong | M AMF
11
MODELING AND SIMULATION – K. TEKNOMO
This simple solution is all we need to generate pulses that will travel throughout the line.
In the Formulas tab in Excel Options, we can set Maximum Iterations = 2 to make the
pulse travel faster (i.e. counter will always be even, and the bottom row will updated
automatically).
Belleza · Dapito · Go · Naniong | M AMF
12
MODELING AND SIMULATION – K. TEKNOMO
AGENT’S BARRIER BEHAVIOR
In order for agents to act realistically, they have to behave realistically when faced with a
barrier. They can’t just pass through because something is blocking their way – either the
barrier, or the agent in front that’s already in front of them.
The LRT security guard in this case will behave as our barrier since sometimes they take a
long time to check the bags and it becomes inconvenient to the passengers.
Here the flag represents our security guard, which has two values: 0 (green flag) and 1 (red
flag). If the flag is green, the agents can just pass through to the other side of the barrier. If
the flag is red, the agents have to wait a certain number of counter iterations before they
can pass through the other side.
Here we set the number of iterations to 20 (cell B8), and the probability that the flag is red
to be 0.5 (cell B6). Of course we can modify these numbers.
Belleza · Dapito · Go · Naniong | M AMF
13
MODELING AND SIMULATION – K. TEKNOMO
Next we look at the guard counter. The default value of the counter is zero. The screenshot
above displays the formula: if the flag is red and the cell before the barrier is occupied by
an agent (IF (Y5*Z5=1), meaning both have value 1) then the counter will be set, until it
reaches 20 (cell B8). Otherwise, it’s just zero.
Note that the flag doesn’t have to be red all the time for the counter to keep increasing. It
just has to be red at the start. This is the meaning of
IF (Z4>0, increase counter until Z4 reaches 20, else (meaning Z4=0) increase only
if flag is red and an agent occupies cell before flag)
meaning if the counter already has a nonzero value , this implies that the flag was red at
some point before and we just need to keep increasing it until it becomes 20.
Belleza · Dapito · Go · Naniong | M AMF
14
MODELING AND SIMULATION – K. TEKNOMO
Next we look at the behavior of the agents to the left of the barrier. This is a modified
version of our “pulse generation” earlier, taking into account the existence of the barrier.
The first check is this:
IF(PRODUCT(W5:$Y$5)=1, -------, V6)
This means that if all the cells from the current one to the one before the barrier are
occupied by agents (meaning they’re all 1), we go into our inner loop. Otherwise, there’s still
room to move forward, and we just copy the value of the bottom left cell and proceed as
before.
The inner loop is this:
IF(AND($Z$4>0,$Z$4<=$B$8),W5,V6)
This is the key to our agent’s barrier behavior. If the counter in cell Z4 is between 0 and 20,
this means the counter is running and the agents are stuck in their current position. Until
the counter reaches 20, we just copy the value in the current cell W5. Otherwise, the
counter has been reset to zero, which means the line is full but it’s already moving, and the
agents are already going past the barrier.
Belleza · Dapito · Go · Naniong | M AMF
15
MODELING AND SIMULATION – K. TEKNOMO
The final bit of code is the behavior of the agents just after the barrier. It’s simply this:
IF(AND($Z$4>0,$Z$4<=$B$8),0,Y6)
If the counter is still running, nobody can get through the barrier! That’s why it would be
zero. If the counter has stopped running, we just copy the value of the preceding cell
(careful: here it’s cell Y6, because cell Z6 is the value of the barrier) and proceed as
planned.
The behavior to the right (from columns AB onwards) would be normal agent behavior, and
if there’s an upcoming barrier, we just do the PRODUCT(W5:$Y$5)=1 thing again until
the next barrier is reached.
Belleza · Dapito · Go · Naniong | M AMF
16
MODELING AND SIMULATION – K. TEKNOMO
SPLITTING QUEUES
This is our screenshot of our MS Excel Interface until the customers have gone past the
guards’ checkpoint.
The next step to simulate would be the queues which would correspond to the selling of
tickets through the automatic vending machine or the manual sellers. However, we cannot
just continue the two queues as before, since the number of machines or personnel selling
tickets varies. In fact this would be the source of our decision-making process later on,
wherein we determine what is the optimal number of ticket sellers to maximize the number
of passengers that get on a train.
Thus we come to our next problem, which is how to split the 2 passenger queues into n
queues corresponding to the n ticket vendors.
We undertook this problem for n = 2, 3, 4, 5, and 6 ticket vendors.
Belleza · Dapito · Go · Naniong | M AMF
17
MODELING AND SIMULATION – K. TEKNOMO
Two Vendors
The screenshot below shows the interface when there are just two ticket sellers, the
automatic ticket seller and the human vendor.
In this case, we cannot just continue the queue until they reach the ticketing
machine/personnel (which just has a counter similar to our guard counter before), because
the automatic seller and the human seller have different service times. Thus we need to
randomize where the two passengers go. This is shown by the Random Queue in the
screenshot above, which has the following formula:
X=ROUNDDOWN(2*rand(),0)
which gives an output of 0 if the random number generated is in [0,0.5), and 1 if the
random number is in the interval [0.5,1).
The code for the first cell in the automatic seller row is as follows:
IF X=0, get value of first lane, else IF X=1, get value of second lane
and the code for the first cell of the ticket seller row is as follows:
IF X=0, get value of second lane, else IF X=1, get value of first lane
In simple terms, if X = 0, the customers just go on their merry way; else if it is 1, they
switch paths.
This random number is generated for each iteration of the counter so that customers will
really end up in a random queue.
Belleza · Dapito · Go · Naniong | M AMF
18
MODELING AND SIMULATION – K. TEKNOMO
Three Vendors
For three vendors, the screenshot is shown below, where we just add another row to
indicate the addition of another automated vending machine:
Here the process is not so simple because there are two lanes but they diverge into three
lanes, so one lane would always be empty.
To solve this, we use the concept of permutations, specifically, nPr, which means the
number of ways you can select r objects from n objects, where order is important. Here we
want 3P2, the number of ways you can put 2 customers into 3 lanes, where the customers
are distinct. The answer is 6, as demonstrated by the table below (customer A is the first
lane, customer B is the second lane):
Number of Ways
Automated Seller
Automated Seller
1
2
0
Put customer A here
Put customer B here
No customer
1
Put customer A here
No customer
Put customer B here
2
No customer
Put customer A here
Put customer B here
3
Put customer B here
Put customer A here
No customer
4
Put customer B here
No customer
Put customer A here
5
No customer
Put customer B here
Put customer A here
Belleza · Dapito · Go · Naniong | M AMF
Human Seller
19
MODELING AND SIMULATION – K. TEKNOMO
Thus we need to generate 6 random numbers, by the formula:
X=ROUNDDOWN(6*rand(),0)
The code for the first cell of the first lane (automated seller 1) is as follows:
IF X=0 or 1, get value of first lane, else IF X=3 or 4, get value of second lane, else
it’s 0 (no customer)
For the second lane (automated seller 2):
IF X=2 or 3, get value of first lane, else IF X=0 or 5, get value of second lane, else
it’s 0 (no customer)
For the third lane (human seller):
IF X=4 or 5, get value of first lane, else IF X=1 or 2, get value of second lane, else
it’s 0 (no customer)
This ensures that the customers will be put randomly (but with equal probability) in the 3
lanes.
Belleza · Dapito · Go · Naniong | M AMF
20
MODELING AND SIMULATION – K. TEKNOMO
Four to Six Vendors
The process just continues for greater number of sellers. For 4 sellers, we add another row,
and we generate 4P2 = 12 random numbers
X=ROUNDDOWN(12*rand(),0)
corresponding to the 12 possibilities for placing customers A and B:
Number Automated Automated Automated Human
of Ways
1
2
3
Vendor
0
-
-
A
B
1
B
-
A
-
2
B
-
-
A
3
B
A
-
-
4
-
A
-
B
5
-
A
B
-
6
-
-
B
A
7
A
-
B
-
8
A
-
-
B
9
A
B
-
-
10
-
B
-
A
11
-
B
A
-
The screenshot for 4 sellers is below:
Belleza · Dapito · Go · Naniong | M AMF
21
MODELING AND SIMULATION – K. TEKNOMO
For 5 sellers, we generate 5P2 = 20 random numbers, with the following 20 possibilities:
Number Automated Automated Automated Automated Human
of Ways
1
2
3
4
Vendor
0
-
-
A
B
-
1
B
-
A
-
-
2
B
-
-
A
-
3
B
A
-
-
-
4
-
A
-
B
-
5
-
A
B
-
-
6
-
-
B
A
-
7
A
-
B
-
-
8
A
-
-
B
-
9
A
B
-
-
-
10
-
B
-
A
-
11
-
B
A
-
-
12
B
-
-
-
A
13
-
B
-
-
A
14
-
-
B
-
A
15
-
-
-
B
A
16
A
-
-
-
B
17
-
A
-
-
B
18
-
-
A
-
B
19
-
-
-
A
B
Notice that the first 12 rows correspond to our matrix for the 4 seller-queue, where we just
added a 5th column where no customers come in. The 13-19th rows just have a simple
pattern to generate the extra possibilities. Thus we don’t need to throw out our old code, we
just add a few conditions here and there. (For example, for the first lane, just add the
possibility that X=16 to get the value of the first lane customer A, and add X=12 for
customer B.)
Belleza · Dapito · Go · Naniong | M AMF
22
MODELING AND SIMULATION – K. TEKNOMO
The screenshot for 5 sellers is below:
For 6 sellers, we generate 6P2 = 30 random numbers. This corresponds to the 30
possibilities below:
Number Automated Automated Automated Automated Human Human
of Ways
1
2
3
4
Vendor Vendor
1
2
0
-
-
A
B
-
-
1
B
-
A
-
-
-
2
B
-
-
A
-
-
3
B
A
-
-
-
-
4
-
A
-
B
-
-
5
-
A
B
-
-
-
6
-
-
B
A
-
-
7
A
-
B
-
-
-
8
A
-
-
B
-
-
9
A
B
-
-
-
-
10
-
B
-
A
-
-
11
-
B
A
-
-
-
12
B
-
-
-
A
-
13
-
B
-
-
A
-
14
-
-
B
-
A
-
Belleza · Dapito · Go · Naniong | M AMF
23
MODELING AND SIMULATION – K. TEKNOMO
Number Automated
Automated
Automated
Automated
Human
Human
of Ways
2
3
4
Vendor
Vendor
1
2
1
15
-
-
-
B
A
-
16
A
-
-
-
B
-
17
-
A
-
-
B
-
18
-
-
A
-
B
-
19
-
-
-
A
B
-
20
B
-
-
-
-
A
21
-
B
-
-
-
A
22
-
-
B
-
-
A
23
-
-
-
B
-
A
24
-
-
-
-
B
A
25
A
-
-
-
-
B
26
-
A
-
-
-
B
27
-
-
A
-
-
B
28
-
-
-
A
-
B
29
-
-
-
-
A
B
The screenshot for 6 sellers is below:
Thus we can see that the code is easily replicable and one can easily extend this to an
arbitrary number of pre-splitting lanes and post-splitting lanes. (For example, split 5 lanes
into 16 lanes. This just corresponds to 16P5 random numbers.)
Belleza · Dapito · Go · Naniong | M AMF
24
MODELING AND SIMULATION – K. TEKNOMO
TRAIN ARRIVALS
As mentioned in an earlier section, the time column depends on the “Starting Time” and the
main counter. The screenshot below shows the important aspects of the Train Arrivals set:
1. Seconds to Arrive. An important factor is the “Seconds to Arrive” column which
basically gives the amount of time from start or when the previous train leaves until
the next train arrives. The formula for the cells in this column is:
=IF($G$2="",LOOKUP(BL10,'LRT Time'!$A$2:$A$9,'LRT Time'!$C$2:$C$9)*60,0)
The lookup function looks for the time at which the previous time arrived, which in
the case of the first train is at 11:30 given that the starting time is 11:30, since no
train has arrived befre the first train. The basic function of this formula is that from
the accompanying LRT Times table, the time of arrival of the previous train is
searched from the lower bound of the time ranges, and the corresponding
interarrival time is then generated as the “Seconds to Arrive” cell.
The accompanying table of the excel files gives a table of time ranges, density and
interarrival times, denoted in minutes, as shown in the table below
Belleza · Dapito · Go · Naniong | M AMF
25
MODELING AND SIMULATION – K. TEKNOMO
Time Range
Frequency
Density
5:00
7:00
6
0.5
7:00
9:00
5
0.666667
9:00
11:30
4
0.833333
11:30
14:00
3
1
14:00
16:00
5
0.666667
16:00
18:00
4
0.833333
18:00
20:00
7
0.333333
20:00
22:00
8
0.166667
To be specific, suppose the starting time is 11:30. From the time ranges, the
interarrival time for 11:30 is 3 minutes, or 180 seconds. Then the “Seconds to Arrive”
column will show this interarrival time, in seconds.
2. Time. The time column shows the time of arrival of the trains, from the very first
train up to the 12th train. The group deduced that since this is only for simulations
purposes, having 12 trains is enough. The formula for the Time of Arrival of trains is
as follows:
=IF($G$2="",TIME(HOUR(BL10), MINUTE(BL10), SECOND(BL10)+BO12), 0)
The formula simply adds the number of seconds for the next train to arrive to the
time at which the last train left. In the case of the first train in our case above, the
time of arrival is simply 11:30 + 180 seconds, which is 11:33. 11:33 then is the time
at which the first train will arrive.
3. Cumulative Time. This column is made hidden for most of the time. For the
purposes of explanations, it is shown in the screenshot in the previous page. This
cumulative time basically adds the number of seconds it takes for the nth train to
arrive. For example, the third entry in the column adds the first three “Seconds to
Arrive” entries. This signified the number of seconds it will take for the third train
to arrive at the station. The use of this is for the compilation of number of
passengers.
Belleza · Dapito · Go · Naniong | M AMF
26
MODELING AND SIMULATION – K. TEKNOMO
PASSENGER COUNT
After the passengers move from the seller counters, instead of converging into one queue,
the seller queues are maintained, and at the end of it, a passenger count is retained. This
serves as the waiting area, and adds people to it everytime a green circle is present beside
the counter, as seen in the second and last queues in the screenshot below:
The formula used in counting passengers is as follows:
=IF($G$2="",IF(G3=LOOKUP(G3,BR8:BR27),0,IF(MOD($G$3,2)=1,IF(AX10=1,AY
10+1,AY10),AY10)),0)
The function basically states that the counter adds one to itself once a green color is present
beside the counter, as explained above. It then resets to zero once the train arrives. The
arrival of trains is explained in an earlier section.
This is where the “Cumulative Time” is used. Since the interarrival times of the trains can
differ depending on the time range at which the current time falls in, then the modulo
function cannot be used to simply reset the time to zero whnever the counter becomes a
multiple of the time of arrival.
Hence, the function above simply states that whenever the counter is equal to the
Cumulative Time, then the passenger counter should be reset to zero.
Belleza · Dapito · Go · Naniong | M AMF
27
Download