# 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  
Some of the proposed co-simulation paradigms do not require any additional decision, as the paradigm determines the entire structure of the new co-simulator. In generic designs, issues such as the data format or the communication protocols to be employed in the coordination process must be selected. If a choreographed paradigm is selected all simulators involved must be totally compatible, so no action about the data format or protocols is required (all of them should implement the same). Again, orchestrated co-simulation requires the orchestrator to implement all the protocols, interfaces, etc. employed by the rest of tools, so no action about the data format or protocols is required as well. In federated co-simulation, the key topic is the coordination of the different domain-specific tools which compose the global co-simulator. Thus, only decisions about the mechanism to synchronize the execution of the domain-specific simulators must be taken. The third step of the proposed methodology is focused on this point. In particular, two different mechanisms could be implemented (see Table 8). The coordination mechanism is, probably, the most critical step in the proposed methodology. Although the design process can be simple (see Table 8), at implementation time, programming these policies forces to face various crucial problems. For instance, the event ordination if various discrete time domain-specific simulators are employed, or the definition of a common time representation when each tool employs a different data format (and accuracy). The selected solutions for these challenges depend on the chosen co-simulation paradigm at the first step, but (in general) an initial synchronization process must be performed (and configured) in order to homogenize time characteristics and variables (see Figure 8a). Then, simulation may be executed normally--evaluating the system state after each event or time step--(Figure 8b). \begin{table}
\begin{tabular}{c c c} \hline \hline
**Coordination Mechanism** & **Co-Simulation Paradigm** & **Implementation** \\ \hline \multirow{3}{*}{Parallel execution} & \multirow{3}{*}{All} & Every tool executes in a separate host, processor or thread. Simulation calculations are performed in parallel and results are shared with the rest of simulators immediately (using the orchestrator element if necessary). \\ \hline \multirow{5}{*}{S stops and waits execution} & \multirow{3}{*}{Choreographed} & In a certain order, every simulator makes its calculations. When all tools have performed their execution, all of them share the results with the others. \\ \cline{3-3}  & & \\ \cline{2-3}  & \multirow{3}{*}{Orchestrated by a third-party engine} & In a certain order, the engine order every simulator to execute the calculations. When each simulator finishes, it sends the results to the engine and it sends the information to the other tools. \\ \cline{3-3}  & & First, the orchestrator simulator performs its calculations and shares the results with the other tools. Then, in a certain order, it does every simulator to execute its calculations. When each simulator finishes, it sends the results to the orchestrator and it sends the information to the other tools \\ \hline \hline \end{tabular}
\end{table} 
Table 8: Coordination mechanisms. In order to select the most adequate coordination mechanism two factors should be considered: the difficulty of implementing the mechanism and the time required to perform a simulation when using a certain mechanism. This second criterion is directly related with the scalability requirements acquired from final users in the initial phase (Section 3.1). In general, implementing a parallel execution is much costlier than a stop-and-wait model. However, the time required to finish a certain simulation in smaller if parallel execution is considered. In order to evaluate these temporal factors, a theoretical analysis is provided below.