# Agreement Technologies for Coordination in Smart Cities
## 3 Applications
### Distributed Coordination of Emergency Medical Service for Angioplasty Patients
The patient delay defined in this way is made of the following parts, and is shown in Figure 10:The optimal patient delay time for a single patient is the lowest among the highest values of the following three times for all available ambulances and angioplasty-enabled hospitals (Figure 10):  
* The expected patient delay time to hospital (the sum of times T2, T3, and T4, in continuation represented by parameters \(t\)(\(a\),\(p\)), \(t\)(\(p\)), and \(t\)(\(p\),\(h\)), respectively);
* The expected minimal arrival time among cardiology teams to the same hospital (T5), represented by \(min_{c\in\text{C}u}\)_t_(\(c\),\(h\));
* The expected shortest waiting time until hospital \(h\) gets free for patient \(p\), \(min\)\(\rho_{h,p}\) (T6). For simplicity, we let \(t_{php}=max_{h\in\text{H}av}\) (\(t\)(\(p\),\(h\)), \(min\)\(\rho_{h,p}\)) for all patients \(p\in P\). Then, from the global point of view, considering all pending out-of-hospital patients, the problem transforms into:  
\[min\Delta t_{P}=\sum_{p\in P}\Delta t_{P}=\sum_{p\in P}t(a,p)+\sum_{p\in P}t(p)+ \sum_{p\in P}\Bigl{(}max_{h\in\text{H}av}\Bigl{(}t_{php},min_{c\in\text{C}u}t (c,h)\Bigr{)}\Bigr{)} \tag{2}\]  
subject to  
\[\Delta t_{p}\leq t_{p}^{max},\forall p\in P. \tag{3}\]  
The overall patient delay time \(\Delta t_{P}\) in Figure 10 is an additive function. Since the minimum arrival times cannot always be guaranteed for all patients due to the limited number of EMS resources, a sum of the EMA tasks' durations should be minimised for each patient individually and for the system globally considering individual constraints. This gives an underlying linear programming structure to the EMS coordination problem. Therefore, it is possible to guarantee optimal outcomes  
Figure 10: Gantt diagram of the coordination of emergency medical services (EMS) for angioplasty treatment. even when the optimisation is performed separately on individual sum components (i.e., when ambulance assignments are negotiated separately from the hospital and cardiology team assignment, e.g., [56; 57]). This fact significantly facilitates the multiagent system's distribution and enables a multilevel optimisation. Hence, we decomposed optimisation Problems (1)-(2) as follows. On the first level, we assign ambulances to patients such that the expected arrival time of ambulances to patients _t_(_a_,_p_) is minimised. Note that since _t_(_p_) in (1) is a constant for every patient \(p\), depending only on the patient's pathology and not on the assigned ambulance, we can exclude it from the optimisation. Then, on the second optimisation level, we approached the second part of (1) \(\sum_{p\in P}\Bigl{(}max_{h\in H_{av}}\Bigl{(}t_{php},min_{c\in C_{cn}}t(c,h) \Bigr{)}\Bigr{)}\), which is an NP-hard combinatorial problem. However, by approximating (1) with a sequence of problems where we first decide on the assignment of hospitals to pending patients and then assign cardiologists to patients already assigned to hospitals, we obtain two linear programs to which we can apply tractable optimal solution approaches, such as the auction algorithm [47]. By decomposing (1), as can be seen in Figure 11, and allowing for reassignment of resources based on the adaptation to contingencies in real time, we obtain a flexible EMS coordination solution. In the following, we propose a change in the centralised hierarchy-oriented organisational structure to a patient-oriented distributed organisational structure of EMS that increases the flexibility, scalability, and the responsiveness of the EMS system. The proposed decision-support system is based on the integration and coordination of all the phases EMS participants go through in the process of emergency medical assistance (EMA). The model takes into consideration the positions of ambulances, patients, hospitals, and cardiology teams for real-time assignment of patients to the EMS resources.