CSC 446 CSC 546

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top

Problem 1: (15% for CSC 446, 10% for CSC 546)

Suppose a random variable X has the density function as shown the following figure. Figure 1

Write the density function f ( x ) for this random variable. What must be the value of c?

Write the CDF F ( x ) of this random variable. WhatisE(X)?

What is the variance of X ?

End of Problem 1

Problem 2 (20% for CSC 446, 10% for CSC 546)

A terminal at an airport has one queue to check-in for the Terminal 1 passengers. After the check-in, passengers join along with Terminal 2 passengers to a Security-Check as shown in the following figure.

Figure 1

The arrivals are Poisson distributed with rates λ1 and λ2 for Terminal 1 and 2 passengers, respectively. The service times are exponentially distributed with service rates μ1 ,μS for terminal 1 check-in and terminal 2 security-check, respectively.

The average arrival rates are 10 customers/hour for Terminal 1 passengers and 20 customers/hour for Terminal 2 passengers. The average service times at the Terminal 1 check-in is 2 minutes per customer. The security-check maintains a server utilization of 75 % all the time.

Answer the following questions with mathematical analysis: (1) What is the average service time at Security-Check?

1. Ans: ... 1. Ans: ... 1. Ans: ... 1. Ans: ... 1.

Ans:...

 

Ans: ...

(2) What is the the average time spent by the passengers (including both terminal 1

passengers and terminal 2 passengers) at Security-Check? Ans:...

(3) What is the average total time spent in the system by Terminal 1 passengers(Note that Terminal 1 passengers need to pass Terminal 1 and Terminal 2)?

Ans: ...

(4) What is the average total number of Terminal 1 passengers in the system (Note that

Terminal 1 passengers need to pass Terminal 1 and Terminal 2)?

Ans: ...

(5) What is the average time spent by Terminal 2 passengers in the system? Ans: ...

End of Problem 2

Problem 3 (50% for CSC 446, 50% for CSC 546)

Simulate the system in Problem 2 by extending Hritik Jaiswal's code as below.

'''

DO NOT TOUCH THIS CODE!!

Owner : Hritik Jaiswal

Topic : To simulate a Single Server Queuing System (One-operator Barbershop problem) using Python

Subject : Modeling and simulation

'''

import random # Seed

random.seed(10) # No. of Customer

size = 10

# Series of customer

customer = [i for i in range(1,size+1)]

# Inter Arrival Time

inter_arrival_time = [random.randrange(1,10) for i in range(size)]

 

# Service Time

service_time = [random.randrange(1,10) for i in range(size)] print(len(inter_arrival_time),len(service_time))

# Calculate arrival time

arrival_time = [0 for i in range(size)] # initial

arrival_time[0] = inter_arrival_time[0] for i in range(1,size):

  arrival_time[i] = inter_arrival_time[i]+arrival_time[i-1]

Time_Service_Begin = [0 for i in range(size)] Time_Customer_Waiting_in_Queue = [0 for i in range(size)] Time_Service_Ends = [0 for i in range(size)] Time_Customer_Spend_in_System = [0 for i in range(size)] System_idle = [0 for i in range(size)]

Time_Service_Begin[0] = arrival_time[0]

Time_Service_Ends[0] = service_time[0]

Time_Customer_Spend_in_System[0] = service_time[0]

Time_Service_Ends[0] = Time_Service_Begin[0] + service_time[0]

for i in range(1,size):

# Time Service Begin

Time_Service_Begin[i] = max(arrival_time[i],Time_Service_Ends[i-1])

# Time customer waiting in queue

  Time_Customer_Waiting_in_Queue[i] = Time_Service_Begin[i]-

arrival_time[i]

  # Time service ends

Time_Service_Ends[i] = Time_Service_Begin[i] + service_time[i]

# Time Customer Spend in the system

  Time_Customer_Spend_in_System[i] = Time_Service_Ends[i] -

arrival_time[i]

# Time when system remains idle

if (arrival_time[i]>Time_Service_Ends[i-1]): System_idle[i] = arrival_time[i]-Time_Service_Ends[i-1]

else:

System_idle[i] = 0

 

from prettytable import PrettyTable x = PrettyTable()

column_names =

['Customer','IAT','AT','ST','TSB','TCWQ','TSE','TCSS','System Idle']

data = [customer,inter_arrival_time,arrival_time,service_time,

Time_Service_Begin, Time_Customer_Waiting_in_Queue, Time_Service_Ends,

Time_Customer_Spend_in_System, System_idle]

length = len(column_names) for i in range(length):

  x.add_column(column_names[i],data[i])

print(x)

10 10 +----------+-----+----+----+-----+------+-----+------+-------------+ | Customer | IAT | AT | ST | TSB | TCWQ | TSE | TCSS | System Idle | +----------+-----+----+----+-----+------+-----+------+-------------+ |1 |1|1|9|1|0|10|9| 0 | |2 |7|8|8|10|2|18|10| 0 | |3 |8|16|6|18|2|24|8| 0 | |4 |1|17|2|24|7|26|9| 0 | |5 |4|21|4|26|5|30|9| 0 | |6 |8|29|6|30|1|36|7| 0 | |7 |8|37|1|37|0|38|1| 1 | |8 |5|42|7|42|0|49|7| 4 | |9 |3|45|3|49|4|52|7| 0 | | 10 |1|46|6|52|6 |58|12| 0 | +----------+-----+----+----+-----+------+-----+------+-------------+

Your extended code should be written below:

'''

MODIFY THE FOLLOWING CODE!

YOU SHOULD USE THE FOLLOWING FORMAT IN THE OUTPUT TABLE:

+------------+------------+-----+----+----+-----+------+-----+------ +---------------+

| Customer # | Terminal # | IAT | AT | ST | TSB | TCWQ | TSE | TCSS | Terminal Idle | +------------+------------+-----+----+----+-----+------+-----+------ +---------------+

NOTE: (1) ASSUME THAT EVERY CUSTOMER HAS A UNIQUE ID IN THE WHOLE SYSTEM.

(2) YOUR FINAL PERFORMANCE MEASURE SHOULD ANSWER THE QUESTIONS RAISED

 

IN PROBLEM 2

'''

import random # Seed

random.seed(10) # No. of Customer

size = 10

# Series of customer

customer = [i for i in range(1,size+1)] # Inter Arrival Time

inter_arrival_time = [random.randrange(1,10) for i in range(size)] # Service Time

service_time = [random.randrange(1,10) for i in range(size)] print(len(inter_arrival_time),len(service_time))

# Calculate arrival time

arrival_time = [0 for i in range(size)] # initial

arrival_time[0] = inter_arrival_time[0] for i in range(1,size):

  arrival_time[i] = inter_arrival_time[i]+arrival_time[i-1]

Time_Service_Begin = [0 for i in range(size)] Time_Customer_Waiting_in_Queue = [0 for i in range(size)] Time_Service_Ends = [0 for i in range(size)] Time_Customer_Spend_in_System = [0 for i in range(size)] System_idle = [0 for i in range(size)]

Time_Service_Begin[0] = arrival_time[0] Time_Service_Ends[0] = service_time[0] Time_Customer_Spend_in_System[0] = service_time[0] for i in range(1,size):

  # Time Service Begin

  Time_Service_Begin[i] = max(arrival_time[i],Time_Service_Ends[i-1])

# Time customer waiting in queue

  Time_Customer_Waiting_in_Queue[i] = Time_Service_Begin[i]-

arrival_time[i]

 

  # Time service ends

Time_Service_Ends[i] = Time_Service_Begin[i] + service_time[i]

# Time Customer Spend in the system

  Time_Customer_Spend_in_System[i] = Time_Service_Ends[i] -

arrival_time[i]

# Time when system remains idle

if (arrival_time[i]>Time_Service_Ends[i-1]): System_idle[i] = arrival_time[i]-Time_Service_Ends[i-1]

else:

System_idle[i] = 0

from prettytable import PrettyTable x = PrettyTable()

column_names =

['Customer','IAT','AT','ST','TSB','TCWQ','TSE','TCSS','System Idle']

data = [customer,inter_arrival_time,arrival_time,service_time,

Time_Service_Begin, Time_Customer_Waiting_in_Queue, Time_Service_Ends,

Time_Customer_Spend_in_System, System_idle]

length = len(column_names) for i in range(length):

  x.add_column(column_names[i],data[i])

print(x)

10 10 +----------+-----+----+----+-----+------+-----+------+-------------+ | Customer | IAT | AT | ST | TSB | TCWQ | TSE | TCSS | System Idle | +----------+-----+----+----+-----+------+-----+------+-------------+ |1|1|1|9|1|0|9|9|0| |2 |7|8|8|9|1|17|9| 0 | |3 |8|16|6|17|1|23|7| 0 | |4 |1|17|2|23|6|25|8| 0 | |5 |4|21|4|25|4|29|8| 0 | |6 |8|29|6|29|0|35|6| 0 | |7 |8|37|1|37|0|38|1| 2 | |8 |5|42|7|42|0|49|7| 4 | |9 |3|45|3|49|4|52|7| 0 | | 10 |1|46|6|52|6 |58|12| 0 | +----------+-----+----+----+-----+------+-----+------+-------------+

 

Simulate 30 customers in total. Compare the theoretical results calculated in Problem 2 and the simulation results obtained in Problem 3. Use a table to show the comparison results.

Ans:

Metric

avg. service time at Security-Check

avg. time spent by the passengers

avg. total time in the system (T1 passengers) avg. total number of T1 passengers in the system avg. time spent by T2 passengers in the system

Analytical result

Simulation Result

 Increasing the number of simulated customers to 100 , 000. Run your simulation five times, each run with a different random seed. Record the simulation result of each run and take the average over the five runs as the final simulation result. (Important: to avoid bloating your output screen, you should disable the output table when you simulate 100 , 000 customers.)

Ans:

|Metric|Run1|Run2|Run3|Run4|Run5|FinalResult| |:---------------------------------------------------| :----: | :---: |:----: | :--:--|:----: | :---------: |

| avg. service time at Security-Check | | | | | | |

| avg. time spent by the passengers | | | | | | | | avg. total time in the system (T1 passengers) | |||||||avg.totalnumberofT1passengersinthesystem||||||||avg.timespentbyT2 passengersinthesystem|||||||

End of Problem 3

Problem 4 (15% for CSC 446, 10% for CSC 546)

Let W and W Q denote the total waiting time of a packet in the system and the queueing time of the packet, respectively.

1. Is W the same in an M/M/1 model having arrivals at rate λ and service at rate 2μ as it is in a two-server M/M/2 model with arrivals at rate λ and with each server at rate μ? Prove your claim.

Ans:

1. Is W Q the same in an M/M/1 model having arrivals at rate λ and service at rate 2μ as it is in a two-server M/M/2 model with arrivals at rate λ and with each server at rate μ? Prove your claim.

 

Ans:

End of Problem 4

Problem 5 (CSC 546 Only, 20% )

Patients arrive for a physical examination according to a Poisson process at the rate 1 per hour. The physical examination requires three stages, each one independently exponentially distributed with a mean service time of 15 minutes. A patient must go through all the three stages before the next patient is admitted to the treatment facility.

1. What is the mean and variance of the total examination time? Ans:

1. Is the total examination time an exponential distribution? Ans:

1. Compute the average number of delayed patients, LQ for this system. Ans:

1. Compute the total mean time a customer spends in the system. Ans:

End of Problem 5

 

 


51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468