# Multi-formalism Models for Performance Engineering
## 4 Multi-Formalism QN/PN Techniques
### Batching in IoT-Based Healthcare
#### 4.2.2 The Model  
Multi-formalism models allow the exploitation of queueing networks and Petri net primitives to represent each concept with the most appropriate technique. To describe the dynamic behavior of the batching algorithm, we used the PN primitives while the QN primitives were used to represent the other components of the e-Health infrastructure. The layout of the model is shown in Figure 20.  
The workload consists of two classes: _signals_ detected by sensors (referred to as requests) and a _token_, needed to model the periodic/triggered management of the requests. The key feature of the model is the algorithm that manages the transmission requests batch. To ensure that the model and the presentation of the algorithm remain as simple as possible, we adopted several assumptions that have a minimal impact on the performance but that greatly simplify the description of other parts of the model. The set of physiological signals detected by each patient is the same, and each edge system monitors several patients. The computational power of the hospital servers has been oversized compared to the processing time required by signals. In the model, we do not explicitly represent the fog systems since their processing time per request is negligible compared to the service time required by the Edge nodes. Moreover, they were considered as small increases in the service times of the Edge nodes. The global arrival rate \(\lambda\) of data generated by sensors is modeled by all the source Sensors as a single aggregated Poisson process of rate \(\lambda\). This flow is evenly distributed among the edge systems modeled with Edge queuing nodes. The times required to process the data of a signal, i.e., the service time of a visit by an edge node, are exponentially distributed with mean \(D_{Edge}=200\) ms. At the end of this processing phase, the requests are buffered, i.e., routed to the place Buffer, and ready to be transmitted. They are transmitted to the hospital servers (or the cloud servers) that must perform their complete analysis requiring a service time exponentially distributed with mean \(D_{server}=500\) ms. Requests follow two paths: one for Regular requests and one for Urgent requests. The requests in the buffer are managed according to two different policies:  
* The buffer is emptied (i.e., the requests that are in the buffer are transmitted) periodically with a period defined according to the number and type of signals detected by all sensors. Requests are assumed to belong to patients under Regular conditions and are sent at the end of the period. * The buffer is emptied when the number of requests in the buffer reaches a threshold value \(\beta\), i.e., the maximum batch size. In this case, requests with such a high arrival rate are assumed to indicate the presence of a critical condition for one or more patients. Therefore, requests in the buffer are considered Urgent and must be sent immediately without waiting for the end of the emptying period. The periodic transmission of Regular requests is modeled by the loop between places and transitions Waiting, Periodic, Transmitting, and Reset. The deterministic firing time of transition Periodic represents the duration of the clock for the transmissions of the requests arrived in Buffer. This value is computed by analyzing the detection rate of the sensors in normal operating conditions. According to the configuration analyzed, we considered 15 s as constant firing time of the transition Periodic (i.e., as periodic empty cycle time). As soon as the empty cycle expires, a token is transferred to place Transmitting where two alternatives are possible. If there are requests in the buffer, the immediate transition Regular will be enabled and will transfer them to the transmission channel. When the buffer is empty, either because all requests have been transferred or because no requests arrived in the periodic time frame, the immediate transition Reset fires, due to an Inhibitor arc that connects it to the Buffer, and restarts the timer.