Skip to content

Commit 56638e1

Browse files
committed
page in docs on simulation practice
1 parent 5e86de9 commit 56638e1

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

docs/Background/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Contents:
66
.. toctree::
77
:maxdepth: 2
88

9+
simulationpractice.rst
910
threephase.rst
1011
codestructure.rst
1112
other.rst
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.. _simulation-practice:
2+
3+
===================
4+
Simulation Practice
5+
===================
6+
7+
Ensuring good practice when simulation modelling is important to get meaningful analyses from the models. A recommended book on the subject is 'Simulation: The practice of model development and use' by Stewart Robinson. This page will briefly summarise some important aspects of carrying out simulation model analysis.
8+
9+
--------------------------------
10+
Performing Multiple Replications
11+
--------------------------------
12+
13+
Users should not rely on the results of a single run of the simulation due to the intrinsic stochastic nature of simulation. When only running one replication, users cannot know whether the behaviour of that run is typical, extreme or unusual. To counter this multiple replications must be performed, each using different random number streams. Then analyses on the distribution of results can be performed (for example taking mean values of key performance indicators).
14+
15+
In Ciw, the simplest way of implementing this is to create and run the simulation in a loop, using a different random seed every time.
16+
17+
------------
18+
Warm-up Time
19+
------------
20+
21+
Simulation models often begin in unrealistic circumstances, that is they have unrealistic initial conditions. In Ciw, the default initial condition is an empty system. Of course there may be situations where collecting all results from an empty system is required, but in other situations, for example when analysing systems in equilibrium, these initial conditions cause unwanted bias. One standard method of overcoming this is to use a warm-up time. The simulation is run for a certain amount of time (the warm-up time) to get the system in an appropriate state before results are collected.
22+
23+
In Ciw, the simplest way of implementing this is to filter out records that were created before the warm-up time.
24+
25+
The example below shows the simplest way to perform multiple replications, and use a warm up time, in Ciw. It shows how to find the average waiting time in an M/M/1 queue::
26+
27+
>>> import ciw
28+
>>> params = {'Arrival_distributions': [['Exponential', 5.0]],
29+
... 'Service_distributions': [['Exponential', 8.0]],
30+
... 'Transition_matrices': [[0.0]],
31+
... 'Number_of_servers': [1]}
32+
>>>
33+
>>> average_waits = []
34+
>>> warmup = 50
35+
>>>
36+
>>> for s in range(100):
37+
... ciw.seed(s)
38+
... N = ciw.create_network(params)
39+
... Q = ciw.Simulation(N)
40+
... Q.simulate_until_max_time(200)
41+
... recs = Q.get_all_records()
42+
... waits = [r.waiting_time for r in recs if r.arrival_date > warmup]
43+
... average_waits.append(sum(waits)/len(waits))
44+
>>>
45+
>>> average_wait = sum(average_waits)/len(average_waits)
46+
>>> print(round(average_wait, 5))
47+
0.21071
48+

0 commit comments

Comments
 (0)