Download presentation
Presentation is loading. Please wait.
1
MAT 4830 Mathematical Modeling
07 Servicing Requests II
2
HW Individual HW
3
HW HW 4 – well done One of you earned bonus points for your next exam.
4
HW HW 5 – I hope your MCM paper is explained better than this HW.
Last night, I started this HW at 8pm and hoped that I would be home for dinner by 9:30pm. Describing how the codes works is not the same as explaining the idea of the solutions.
5
Preview Look at Server-Customer Systems with Queues Maple:
The function nature of proc Use of user-defined proc Strings Handling
6
Server-Customer System with Queues
Suppose requests cannot be rejects Requests will be assigned to the (first) server with the shortest wait One queue, multi-server (Post Office) We want to know the average waiting time of customers
7
Server-Customer System with Queues
8
Example 1: Suppose we have 1 server to handle requests.
9
Idea Generate 𝑛 customers
If the server is busy, record the waiting time of the customer Compute the average waiting time
10
Tool: Clocks System Clock t: Indicate the current time
Server Clock s: Indicate the completion time for the last customer being served
11
Tool: Clocks System Clock t: Indicate the current time
Server Clock s: Indicate the completion time for the last customer being served if s<t, the server is idle
12
Tool: Clocks System Clock t: Indicate the current time
Server Clock s: Indicate the completion time for the last customer being served if s≥t, the server is busy
13
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66
14
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66 First customer comes in at t=7 s<t? Idle?
15
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66 The server will be busy until t=7+12=19
16
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66 Next customer comes in 11 min. after the first customer. s<t? Idle?
17
Idea n T t S s W 1 7 12 19 2 11 18 15 33 3 8 26 40 4 41 48 5 6 47 10 58 9 57 66 Update the Wait counter with W=0+1
18
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66 The server will be busy until t=19+14=33
19
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66 Next customer comes in 8 min. after the last customer. s<t? Idle?
20
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66 Update the Wait counter with W=1+(33-26)=8
21
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66 The server will be busy until t=33+7=40
22
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66 Next customer comes in 15 min. after the last customer. s<t? Idle?
23
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66 The server will be busy until t=41+7=48
24
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66
25
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66
26
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66
27
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66
28
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66
29
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66
30
Idea n T t S s W 1 7 12 19 2 11 18 14 33 3 8 26 40 4 15 41 48 5 6 47 10 58 9 57 66
31
Example 2: Suppose we have 2 servers to handle requests
Requests will be assigned to the server with the shortest wait
32
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
33
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
34
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
35
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
36
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
37
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
38
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
39
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
40
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
41
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
42
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
43
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
44
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
45
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
46
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
47
Idea n T t S s1 s2 W 1 7 12 19 2 11 18 14 32 3 8 26 33 4 29 39 5 6 35 10 45 36 47
48
Example 3: Suppose we have 𝑚 servers to handle requests
Requests will be assigned to the server with the shortest wait
49
Example 3: 𝒎 Servers 𝑠[1], 𝑠[2],…, 𝑠[𝑚] are the server clocks
Find the (first) server with the minimum value Find 𝑘 such that
50
Maple Let us switch to Maple
51
The Function nature of proc
Maple returns the result of the last executable statement in a procedure. We can also use return() to return the output. return() can be placed anywhere in the program. The output can be assigned to a variable Useful when called within another procedure
52
Example 4a Write a program to compute the function value of
Of course, there are easier ways to do this. We only want to demo the point. Example 4b below does not represent the best programming practices
53
Example 4a
54
Example 4b
55
Example 4c Write a function(procedure) to
Generate a normally generated random number 𝑥 with 𝑚𝑒𝑎𝑛=0 and 𝑠𝑡𝑑=1. Compute the square root of the cut off of 𝑥. Output this as the function value for the procedure. Call the cut off function from example 4b.
56
Example 4c
57
Maple: Strings Handling
58
Maple: Strings Handling
Assignments
59
Maple: Strings Handling
Subscripting
60
Maple: Strings Handling
Subscripting
61
Maple: Strings Handling
Subscripting
62
Maple: Strings Handling
Counting
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.