|
49 | 49 | + :code:`TimeDependent` |
50 | 50 | + 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]`. |
51 | 51 | + 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 | + |
0 commit comments