This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################## | |
#### CHECK-IN QUEUES ##### | |
########################## | |
class CheckInQueue: | |
""" Class used to model a check-in line Queue | |
""" | |
def __init__(self): | |
self.queue = q.Queue() | |
self.customers_added = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################### | |
##### AIRPORT SERVERS ##### | |
########################### | |
class CheckInServer: | |
""" Class used to model a server at the Check-in terminal | |
""" | |
def __init__(self): | |
""" Initialize the class variables | |
""" | |
self.service_time = 0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gen_number_of_carry_on_items__for_COMMUTER_passenger(): | |
""" | |
Number of bags a passenger carries is determined using a GEOMETRIC DISTIBUTION | |
BERNOULLI TRIAL with success bias %p = chance of passenger bringing bags | |
Bernoulli with 80% chance | |
P = 0.80 for international | |
:return: Number of bags a commuter passenger has carried on | |
""" | |
# Count number of iterations until a success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_lcg( num_iterations ): | |
""" | |
LCG - generates as many random numbers as requested by user, using a Linear Congruential Generator | |
LCG uses the formula: X_(i+1) = (aX_i + c) mod m | |
:param num_iterations: int - the number of random numbers requested | |
:return: void | |
""" | |
# Initialize variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PROCEDURE, From ROSS: Simulation (5th Edition) Page 78 | |
# Step 1: Generate Y1, an exponential random variable with rate 1 | |
Y1 = gen_exponential_distro_rand_variable() | |
# Step 2: Generate Y2, an exponential random variable with rate 2 | |
Y2 = gen_exponential_distro_rand_variable() | |
# Step 3: If Y2 - (Y1 - 1)^2/2 > 0, set Y = Y2 - (Y1 - 1)^2/2, and go to Step 4 (accept) | |
# Otherwise, go to Step 1 (reject) | |
subtraction_value = ( math.pow( ( Y1 - 1 ), 2 ) ) / 2 | |
critical_value = Y2 - subtraction_value | |
if critical_value > 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
quicksort :: (Ord a) => [a] -> [a] | |
quicksort [] = [] | |
quicksort (x:xs) = | |
let smallerSorted = quicksort [a | a <- xs, a <= x] | |
biggerSorted = quicksort [a | a <- xs, a > x] | |
in smallerSorted ++ [x] ++ biggerSorted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data BinaryTree a = | |
Leaf | |
| Node (BinaryTree a) a (BinaryTree a) | |
deriving (Eq, Ord, Show) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Do Tree Traversals and Built a Visitation List for each | |
preorder :: BinaryTree a -> [a] | |
preorder Leaf = [] | |
preorder (Node left root right) = root : preorder left ++ preorder right | |
-- NOTE: Need to use the ++ so each list gets built separately and then concatenated | |
-- after it hits bottom | |
inorder :: BinaryTree a -> [a] | |
inorder Leaf = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ energy_matrix ] = energy_image( image_matrix_input ) | |
%ENERGY_IMAGE Computes the energy at each pixel in a matrix nxmx3 matrix | |
% Outputs a 2D-matrix containing energy equation outputs, of datatype DBL | |
% convert image to grayscale first | |
G = rgb2gray(image_matrix_input); | |
% convert to double | |
G2 = im2double(G); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first value in state tuple | |
height_category = 0 | |
dist_to_pipe_bottom = pipe_bottom - bird.y | |
if dist_to_pipe_bottom < 8: # very close | |
height_category = 0 | |
elif dist_to_pipe_bottom < 20: # close | |
height_category = 1 | |
elif dist_to_pipe_bottom < 125: #mid | |
height_category = 2 | |
elif dist_to_pipe_bottom < 250: # far |
OlderNewer