zhaw-dps-sw02-exercise

Exercise 2

Exhaust gas testing

The exhaust gas testing system of an automotive workshop is to be modeled as an M/M/1 queue. The utilization rate of the plant is 80%. The average handling time of the system is 10 minutes.

ρ=λμ=0.8μ=110m=10.16=6

1.  Determine the average interarrival time (solution: 12.5 minutes),

λ=ρμ=0.86=4.8A=1λ=0.208360A=12.5 minutes

The expected number of customers in the queue (solution: 3.2 customers)

LQ=ρ21ρ=0.8210.8=3.2 customers

A customer's expected waiting time before the emissions test (solution: 40 minutes)

WQ=ρ2λ(1ρ)=0.824.8(10.8)=0.660WS=40 minutes

A customer's expected time in the system (solution: 50 minutes)

WS=ρλ(1ρ)=0.84.8(10.8)=0.8360WS=50 minutes

The probability that no more than two customers will wait (solution: 59.04%).

P0+P1+P2+P3=(1ρ)+ρ(1ρ)+ρ2(1ρ)+ρ3(1ρ)=0.2+0.16+0.128+0.1024=0.5904

2. Determine the arrival rate so that the expected time of a customer in the system is not higher than twelve minutes (solution: 1 customer per hour).

WS=0.2=λμλ(1λμ)WSλ(1λμ)=λμWSλμ(1λμ)=λWSλμWSλ2=λWSμWSλ=1λ=1WS+μ10.2+6=1 customers per hour

Bicyclebags

In a company, fashionable bicycle bags are produced. According to the mass customization principle, the customer can determine the colors, sizes and equipment of the bags via the Internet. These are then produced according to the customer's wishes. After the order has been accepted, an employee determines the parts list for each bicycle bag. The employee creates an average of 240 orders in a working day with eight hours. On average, 180 orders arrive in one day. Both arrival times and processing times are exponentially distributed.

μ=2408=30 orders/hourλ=1808=22.5 orders/hourρ=λμ=0.75

3. What part of his time can the employee spend on activities other than order acceptance? (solution: 25%).

ρ=0.751ρ=0.25

What is the average number of jobs waiting for the employee to be processed, and what is the average number of jobs in the system in total? (solution. 2.25 and 3)

LQ=ρ21ρ=0.75210.75=2.25LS=ρ1ρ=0.7510.75=3

What is the average time of an order from the arrival at the employee until the order is passed on to the parts list creation? (8 minutes)

WS=ρλ(1ρ)=0.7522.5(10.75)=0.13WS60=8 minutes

4. How do the calculated key figures change if software support could double the number of processable orders? (solution: LQ= 0.225 orders & LS= 0.6 orders & WS= 1.6 minutes/order)

μ=302=60ρ=λμ=0.375LQ=ρ21ρ=0.375210.375=0.225LS=ρ1ρ=0.37510.375=0.6WS=ρλ(1ρ)=0.37522.5(10.375)=1.6

Python

Implement the following tasks in python. Hint: You can clone the github example presented in the lecture.

5. Implement the calculations for task 1 in python. Make sure the solutions are corrected.

import numpy as np
RHO=0.8
MU=6
LAMBDA=RHO*MU
A=1/LAMBDA
LQ=np.power(RHO, 2)/(1-RHO)
WS=RHO/(LAMBDA*(1-RHO))

def P(n):
	return np.power(RHO, n)*(1-RHO)

no_more_than_two = P(0) + P(1) + P(2) + P(3)
  1. Use the data from task 1 and SimPy. How would you have to configure the service rate so that customers will not spend longer than 60 minutes for exhaust gas testing (time for wait and test) in 90% of the cases. Simulate M/M/1 waiting queues with different service rates for 1000 time units each run and calculate the 90% quantile of the individual customers’ time in the system for each simulation run (Hint: use numpy quantile function). Start your loop of simulations with the service rate MU = 0.1 customers/minute and increase MU by 0.05 customers/minute in each loop. Stop when the quantile threshold is reached. Set random.seed(42). (solution: MU=0.25)
LAMBDA = 4.8
MU = 0.1 * 60
MU_STEP = 0.05 * 60

quantiles_x = []
quantiles_simulations = []

for i in range(100):
    MU = MU + MU_STEP
    
    # Setup and start the simulation
    random.seed(42)
    times_in_system = []
    env = simpy.Environment()
    
    # Start processes and run
    server = simpy.Resource(env, capacity=1)
    env.process(source(env, server))
    env.process(monitor(env, server))
    env.run(until=SIM_TIME)
    
    quantiles_x.append(MU)
    quantile = np.quantile(times_in_system, 0.9)
    quantiles_simulations.append(quantile)

    if quantile <= 1:
        break

plt.figure(figsize=(12, 7))
plt.plot(quantiles_x, quantiles_simulations)
plt.show()