Skip to content

Commit 0b1ed5a

Browse files
committed
Add docs for time dependent batching
1 parent 0016ae4 commit 0b1ed5a

2 files changed

Lines changed: 39 additions & 7 deletions

File tree

docs/Guides/batching.rst

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,41 @@ Note:
4949
+ :code:`TimeDependent`
5050
+ If the keyword :code:`Batching_distributions` is omitted, then no batching is assumed. That is only one customer arrives at a time. Equivalent to :code:`['Deterministic', 1]`.
5151
+ If some nodes/customer classes require no batching, but others do, please use :code:`['Deterministic', 1]`.
52-
+ Batch arrivals may lead to :ref:`simultaneous events <simultaneous_events>`, please take care.
52+
+ Batch arrivals may lead to :ref:`simultaneous events <simultaneous_events>`, please take care.
53+
54+
55+
---------------------------------
56+
How to Set Time Dependent Batches
57+
---------------------------------
58+
59+
Ciw allows batching distributions to be time dependent.
60+
That is the batch size, the number of customers arriving simultaneously, is sampled from a distribution that varies with time.
61+
62+
Let's show an example, we wish to have batch sizes of 2 for the first 10 time units, but batch sizes of 1 thereafter.
63+
Define a time dependent batching distribution::
64+
65+
>>> def time_dependent_batches(t):
66+
... if t < 10.0:
67+
... return 2
68+
... return 1
69+
70+
Now use this when defining a network:
71+
72+
>>> import ciw
73+
>>> N = ciw.create_network(
74+
... Arrival_distributions=[['Deterministic', 3.0]],
75+
... Service_distributions=[['Deterministic', 0.5]],
76+
... Batching_distributions=[['TimeDependent', time_dependent_batches]],
77+
... Number_of_servers=[1]
78+
... )
79+
80+
We'll simulate this for 16 time units.
81+
Now at times 3, 6, and 9 we would expect 2 customers arriving (a total of 6).
82+
And at times 12 and 15 we would expect 1 customer arriving (a total of 2).
83+
So 8 customers in total should finish service::
84+
85+
>>> Q = ciw.Simulation(N)
86+
>>> Q.simulate_until_max_time(16.0)
87+
>>> len(Q.nodes[-1].all_individuals)
88+
8
89+

docs/Guides/time_dependent.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
How to Define Time Dependent Distributions
55
==========================================
66

7-
In Ciw we can get a time dependent distribution, that is a service time or inter-arrival time distribution that changes as the simulation time progresses.
7+
In Ciw we can get a time dependent distribution, that is a service time, inter-arrival time, or batching distribution that changes as the simulation time progresses.
88
In order to do this a time dependent function, that returns a sampled time, must be defined.
99
This must take in a time variable `t`.
1010

@@ -54,8 +54,3 @@ Therefore a total of 42 customers passed through the system::
5454

5555
>>> len(Q.nodes[-1].all_individuals)
5656
42
57-
58-
Time dependent function can be used for batching distributions too.
59-
In this case the time dependent function must return the number of individuals that must enter the simulation at the given time.
60-
Note that the function must return a float number, but the result will then be rounded to the nearest integer.
61-
The function may return zero, if no individuals are expected to enter the simulation at the given time.

0 commit comments

Comments
 (0)