114 - LabAct 1
114 - LabAct 1
BSIT – 3C
FLOWCHART MODEL
Yes
Moviegoer buys Moviegoer arrives Generate a Queue
ticket; and waits in line to with Three (3)
Generate buy ticket Customers
random delay
(1-3 min)
No
Yes
ALGORITHM Calculate
average wait Display average
wait time END
1. INPUT, usertimeis prompted to enter number 6. CHOOSE, whether or not to buy food.
of Cashiers. a. BUYS FOOD, get in line to a
2. INPUT, user is prompted to enter number server.
of Servers. b. DOESN’T BUY, skip this step.
3. INPUT, user is prompted to enter number 7. GO, moviegoers find their seat.
of Ushers. 8. RECORD, total time taken is added to
4. ARRIVE, moviegoers arrive at the theater wait time list.
and get in line. 9. LIMIT, check if simulation time limit is
5. BUY, moviegoers buy ticket from the reached.
cashier. a. LIMIT NOT REACHED, add
6. CHECK, ticket is checked by an usher. new moviegoer and go back to step
5.
b. REACHED, go to next step.
IT-115: QUANTITATIVE METHODS SHANE IVAN FALLAR
BSIT – 3C
CODE
import simpy
import random
import statistics
wait_times = []
class Theater(object):
def __init__(self, env, num_cashiers, num_servers, num_ushers):
self.env = env
self.cashier = simpy.Resource(env, num_cashiers)
self.servers = simpy.Resource(env, num_servers)
self.ushers = simpy.Resource(env, num_ushers)
# Pre-Move Processes
def purchase_ticket(self, moviegoer):
yield self.env.timeout(random.randint(1, 3))
def check_ticket(self, moviegoer):
yield self.env.timeout(3 / 60)
def sell_food(self, moviegoer):
yield self.env.timeout(random.randint(1, 5))
# Moviegoer Requests
def go_to_movies(env, moviegoer, theater):
arrival_time = env.now
with theater.cashier.request() as request:
yield request
yield env.process(theater.purchase_ticket(moviegoer))
with theater.cashier.request() as request:
yield request
yield env.process(theater.check_ticket(moviegoer))
if random.choice([True, False]):
with theater.servers.request() as request:
yield request
yield env.process(theater.sell_food(moviegoer))
wait_times.append(env.now - arrival_time)
# Time Randomizers
def run_theater(env, num_cashiers, num_servers, num_ushers):
theater = Theater(env, num_cashiers, num_servers, num_ushers)
for moviegoer in range(3):
env.process(go_to_movies(env, moviegoer, theater))
IT-115: QUANTITATIVE METHODS SHANE IVAN FALLAR
BSIT – 3C
while True:
yield env.timeout(0.20)
moviegoer += 1
env.process(go_to_movies(env, moviegoer, theater))
return params
env = simpy.Environment()
env.process(run_theater(env, num_cashiers, num_servers, num_ushers))
env.run(until=90)
mins, secs = get_average_wait_time(wait_times)
print("Running simulation...", f"\nThe average wait time is {mins} minute
s and {secs} seconds.",)
if __name__ == '__main__':
main()
OUTPUTS
IT-115: QUANTITATIVE METHODS SHANE IVAN FALLAR
BSIT – 3C
RECCOMENDATIONS
From the above outputs, it is easily seen that the biggest determining factors to the wait time
are the number of cashiers and the number of serves currently working. In order to even get within the
below 10-minute requirement there must be at least ten (10) cashiers. On the other hand, the theater
must work to minimize the number of Serves as these all must be actual employees due to the nature
of the task of serving food, while ticket selling on the other hand can be automated using kiosks.
With all these taken into account the following course of action is recommended:
a. Find a set up that achieves the following requirements:
i. Minimizes total number of workers.
ii. Find a Cashier to Server ration that uses the least possible number of servers even
at the cost of adding cashiers.
b. Automate the selling of tickets as much as possible, ideally having 1 Human cashier for
every 5 Kiosks to account for possible emergencies.