Section3 2-Mod
Section3 2-Mod
Section3 2-Mod
c
�2006 Pearson Ed., Inc. 0-13-142917-5
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 1/1
Section 3.2: Multi-Stream Lehmer RNGs
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 2/1
Example 3.2.1: ssq2 Arrival and Service Processes
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 3/1
Example 3.2.2: ssq2 Arrival and Service Processes
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 4/1
The Modified Arrival and Service Processes
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 5/1
Stream Considerations
It must
.. .
. .
. .
.
. .
. .
be some 54321
. .
. .
. •.
. .
. .
criterion
. .
. .
. .
. .
. .
. .
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 6/1
Jump Multipliers
Theorem (3.2.1)
Given g (x) = ax mod m and integer j(1 < j < m − 1)
Jump function : g j (x) = (aj mod m)x mod m
Jump multiplier : aj mod m
If g (·) generates x0 , x1 , x2 , . . . then g j (·) generates x0 , xj , x2j , . . .
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 7/1
Example 3.2.4: An Example Jump Function
aj mod m = 36 mod 31 = 16
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 8/1
Using the Jump Function
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 9/1
An Example 4-Stream Sequence
x0
.... •
.......
..
.. ..
.. ..
.. . ..
.. .
. .
. .
.
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
x .
3j •.. (a, m) = (48271, 231 − 1)
.
•.. xj
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
..
. ..
.. .
.. ..
... ..
...... .....
•
x2j
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 10/1
Example 3.2.5: An Appropriate Jump Multiplier
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 11/1
Maximal Modulus-Compatible Jump Multipliers
jump multiplier
# of streams s ⌊m/s⌋ jump size j aj mod m
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 12/1
Library rngs
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 13/1
Example 3.2.7: ssq2 Revisited
(Single Serve Queue) ssq3.c
Use rngs functions for GetArrival, GetService
GetArrival Method
double GetArrival(void) {
static double arrival = START;
SelectStream(0);
arrival += Exponential(2.0);
return (arrival);
}
GetService Method
double GetService(void) {
SelectStream(2);
return (Uniform(1.0, 2.0));
}
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 15/1
Single-Server Service Node with Multiple Job Types
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 16/1
Example 3.2.8: Arrival Process
Arrival Process
double GetArrival(int *j)
/* Index j corresponds to job type */
{
const double mean[2] = {4.0, 6.0};
static double arrival[2] = {START, START};
static int init = 1;
double temp;
if (init) {
SelectStream(0);
arrival[0] += Exponential(mean[0]);
SelectStream(1);
arrival[1] += Exponential(mean[1]);
init = 0;
}
if (arrival[0] <= arrival[1])
*j = 0;
else
*j = 1;
temp = arrival[*j];
SelectStream(*j);
arrival[*j] += Exponential(mean[*j]);
return (temp);
}
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 17/1
Example 3.2.8: Service Process
Service Process
double GetService(int j)
{
const double min[2] = {1.0, 0.0};
const double max[2] = {3.0, 4.0};
SelectStream(j + 2);
return (Uniform(min[j], max[j]));
}
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 18/1
Consistency Checks
r̄ w̄ d̄ s̄ l̄ q̄ x̄
2.40 7.92 5.92 2.00 3.30 2.47 0.83
Discrete-Event Simulation: A First Course Section 3.2: Multi–Stream Lehmer RNGs 19/1