# Timed Colored Petri Net-Based Event Generators for Web Systems Simulation
## 3 Systematization of the Generator Models
### Timed Models
As a result of the initialization, the token (Evt1,1,2,3600,30) is in ActiveIntv and the tokens (Evt1,2,3,3600,60), (Evt1,3,1,3600,10) are in Intvs at time 0. At this simulation time, the transition generate is executed with evt bind to Evt1 on all its input/output arcs. According to inscriptions of these arcs, the token (Evt1,1,2,3600,30) is effectively replaced by (Evt1,2,3,3600,60) in ActiveIntv. Simultaneously, the time stamp of the token inserted to ActiveIntv is delayed by the value durA of the removed token, i.e., \(d_{1,1}\) from (4) and (6). Therefore, the next token exchange related to Evt1 will happen at the simulated time \(d_{1,1}\), and this delay represents the duration of the first interval. Then, it repeats for (Evt1,2,3,3600,60), (Evt1,3,1,3600,10), again for (Evt1,1,2,3600,30), and so on. The right order is asserted by binding the colors representing \(j\) and \(n_{i,j}\) to the arc expressions. Of course, each event type is subject to this procedure independently. Note that the transition generate is fired once at the beginning of each event generation interval, but many events have to be issued during the interval. The individual events within intervals are prepared by the following function building the tokens inserted to the place Events
``` fungenerateEvent(t,dur,per,evt)=ift<durthen(1'evt@+t)++generateEvent(t+per,dur,per,evt)elseempty ```It recursively constructs a sequence of tokens representing the events delayed by \(0,p_{i,j},2p_{i,j},\ldots\), from starting time of the interval up to its completion. It is equivalent to iteration over \(h\) subject to fixed \(g\) in (5). The set \(\mathbb{T}_{i}\) in (5) is infinite, but an actual simulation generates a finite number of events. In particular, if the simulation finishes at the global clock value \(T\), there is asserted that all the \(e_{i}\) events with time stamps \(t_{i}\in\mathbb{T}_{i}\) such that \(t_{i}<T\) have been generated. For the generator configuration from Figure 9, the resulting cumulated number of generated events as a function of simulated time is shown in Figure 9(a). It is assumed that the simulation time unit corresponds to one millisecond, so the plot covers the simulated time interval [0, 15,000]. As the periods \(d_{i,j}\) are tiny compared to the simulation time-span, the events are dense so that the related points form a solid line in the plot. However, if one increases the periods 10 times, the events become distinguishable, as shown in Figure 9(b). For uniformity, we propose the stochastic variant of the timed generator very similar to the deterministic one. The difference is that periods of event generations are no longer fixed, but are defined as random variables. Namely, the event type description (6) obtains the form  
\[\left(e_{i},j,n_{i,j},d_{i,j},p_{i,j}^{\mathrm{L}},p_{i,j}^{\mathrm{U}}\right),\]  
Figure 10: Number of events as a function of time obtained from the timed deterministic model. Figure 9: Timed deterministic CPN-based event generator. where \(p_{i,j}\) is replaced by the pair \(p_{i,j}^{\rm L}\), \(p_{i,j}^{\rm U}\). The redefined period is now interpreted as the random variable  
\[\mathcal{U}_{\rm d}\Big{(}p_{i,j}^{\rm L},p_{i,j}^{\rm U}\Big{)}. \tag{8}\]  
The model of the timed stochastic generator is shown in Figure 11. Compared to the design from Figure 9, some color sets have been extended to include one new parameter and some functions have been slightly modified. There are two relevant changes. First, the function generateEvent is redefined in the form  
fun generateEvent(t,dur,perL,perU,evt) = if t<dur then (1'evt@+t)  
+++generateEvent(t+discrete(perL,perU),dur,perL,perU,evt) else empty  
Therefore, the time differences between consecutive events of the same interval are randomly generated using the discrete uniform distribution function discrete(perL,perU), being an implementation of (8). Second, whole interval times are also randomly disturbed. The disturbing component is given in the third line of the inscription on the arc from generate to ActiveIntv (Figure 11).