# A Methodology for the Design of Application-Specific Cyber-Physical Social Sensing Co-Simulators
## 2 State of the Art
### Selection of the Appropriate Coordination Mechanism
For every co-simulation paradigm, as can be seen, the difference in the mean simulation time due to the implementation of a parallel execution or a stop-and-wait mechanism is, basically, the difference between \(max\Big{\{}\mu_{ph},\ \mu_{so},\ \mu_{cy}\Big{\}}\) and \(\mu_{ph}+\ \mu_{so}+\ \mu_{cy}\). Both values, in general, grows up with a complexity order of \(\sigma\big{(}n^{2}\big{)}\) when increasing the number of agents in the scenario. However, the growth rate is higher for the expression \(\mu_{ph}+\ \mu_{so}+\ \mu_{cy}\) as can be seen in Figure 8, where a generic graphic of the evolution of both expressions is provided. In Figure 9 two areas may be distinguished. In the first zone, both expressions are low and not very different, as the difference between \(max\Big{\{}\mu_{ph},\ \mu_{so},\ \mu_{cy}\Big{\}}\) and \(\Big{(}\mu_{ph}+\ \mu_{so}+\ \mu_{cy}\Big{)}\) is not so remarkable. If simulations being performed are located in this area, stop-and-wait mechanism is preferable. Then, from a certain number of agents, the difference between \(max\Big{\{}\mu_{ph},\ \mu_{so},\ \mu_{cy}\Big{\}}\) and \(\Big{(}\mu_{ph}+\ \mu_{so}+\ \mu_{cy}\Big{)}\) starts growing and, in this area, parallel execution is desirable. In order to support scalability (in the limits of a certain application) it is very important to evaluate the area where the planned co-simulator will operate. In order to evaluate the relation between the required simulation time and the development time to be invested, one new function can be defined (9). It represents the number of simulations which  
\[M_{G}=\ \left\{m_{ph},m_{so},m_{cy}\right\} \tag{1}\]0 Generic graphic of the evolution of the simulation time. have to be performed in order to compensate the needed additional time to implement a parallel execution coordination mechanism. \[M_{G}=\ \left\{m_{ph},m_{so},m_{cy}\right\} \tag{1}\]1  
In (8), \(n\) represents the number of agents in the simulation, \(T_{s\&ew}^{sim,n}\) the required time to perform the simulation using a stop-and-waits mechanism, \(T_{para}^{sim,n}\) the required time to perform the simulation using parallel execution, \(T_{para}^{dce}\) the needed time to develop a co-simulator using parallel execution and \(T_{s\&ew}^{dce}\) the needed time to develop a co-simulator using a stop-and-wait mechanism. As \(T_{para}^{dce}-\ T_{s\&ew}^{dce}\) is a fixed number and \(T_{s\&ew}^{sim,n}-\ T_{para}^{sim,n}\) presents a complexity order \(\sigma\big{(}n^{2}\big{)}\), then \(S(n)\) presents a complexity order of \(\sigma\Big{(}\frac{1}{n^{2}}\Big{)}\). Figure 10 represents this new function. If simulations which are going to be performed include a great number of elements, very complex scenarios or devices extremely heterogeneous, parallel execution is the best option as \(S(n)<1\). In this area, only one simulation requires an amount of time higher than which invested in implementing the parallel execution. On the contrary, if simulations to be performed are simple, the time invested in implementing a parallel solution does not make profit, as \(S(n)\gg 1\). Finally, in the intermediate zone (when \(S(n)>1\) but \(S(n)\) is not much higher than the unit) any of the proposed mechanisms can be selected to be implemented. In that point, the utilization degree may be determinant (e.g., if many simulations are being performed). It is important to note that parallel execution does not imply to be able to parallelize various co-simulations. Domain-specific simulator may operate in parallel, but the co-simulator (as a unit) only performs one simulation each time. If parallelization capabilities are required, the adequate domain-specific simulation tools should be chosen (they must support parallel simulations) and, at implementation time, the coordination mechanism should also be able to manage various simulation at the same time. Finally, more than the three basic subsystems of CPSS could be considered.