# Agreement Technologies for Coordination in Smart Cities
## 3 Applications
### Coordination of Transportation Fleets of Autonomous Drivers
#### Dynamic Reassignment with Compensations  
The idea of coordinating the assignments of transportation tasks to (autonomous) drivers is similar to the one proposed in Section 3.3.1: we want to reduce globally the total travel distance (and proportionally time) towards the origin points of the requested services. However, due to the rules of the system, a driver will usually not accept a \"worse\" task than the one he is already assigned to. We assumed drivers to be economically rational, that is, they want to maximise their net income and minimise the time spent on their trips. In particular, we made the following assumptions:  
* A driver would always prefer a task with the same net income but that requires less time (e.g., less travel distance). * A driver would always accept extra distance \(d\) if he would get extra net earnings of \(d\)-\((\textit{fare}-\textit{vcost})\). This is actually the current rate a driver earns when accomplishing a service and, thus, he would always be willing to provide his service for this rate. Let us consider that a driver \(v\) is currently assigned to a service \(s_{k}\) and the mediator wants the driver to do other services \(s_{j}\) instead of \(s_{k}\). Furthermore, let \(td(v,s)=d(s_{k})+d(v,s_{k})\) denote the total distance driver \(v\) has to accomplish in order to provide service \(s\). In order to convince the driver, we define a compensation \(c\) that is applied if a driver accepts the reassignment. This compensation is calculated as follows:  
Case 1: If \(td(v,s_{k})<td(v,s_{j})\): \(c=[\textit{Earn}(v,s_{k})+(td(v,s_{j})-td(v,s_{k}))\)-\(\textit{fare}-\textit{vcost})]-\textit{Earn}(v,s_{j})\)  
In this case, the effective income of the driver when accepting the reassignment and receiving the compensation \(c\) would be \(\textit{Earn}(v,s_{k})+(td(v,s_{j})-td(v,s_{k}))\)-\(\textit{fare}-\textit{vcost})\). That is, the driver receives the same income as before, plus the normal fare for the extra distance. Case 2: If \(td(v,s_{k})\geq td(v,s_{j})\): \(c=\textit{Earn}(v,s_{k})-\textit{Earn}(v,s_{j})\)  
In this case, the effective new income of the driver with the compensation is \(\textit{Earn}(v,s_{k})\). Thus, the driver would have the same earnings as before, but for less distance (and less time). It is clear that, with the assumptions mentioned above, an economically rational driver would accept any reassignment with the defined compensations. It should be noted that compensations may be positive or negative (e.g., a driver may get extra money for accepting a new service or s/he may have to pay some amount to the mediator). For instance, if a driver is offered a reassignment from a service \(s_{k}\) to another service \(s_{j}\) with \(d(s_{k})=d(s_{j})\) and \(d(v,s_{k})>d(v,s_{j})\) (Case 2), the situation is a priori positive for the driver. S/he would have less distance to the starting point of the transportation service request but would earn the same money for the service itself. Thus, his net income would be higher. In this case, the compensation would be negative, with the amount \(c=vcost(d(v,s_{j})-d(v,s_{k}))\). That is, the driver would have to pay the cost of the difference in distances towards \(s_{j}\) with respect to the previous service \(s_{k}\). The idea of the mediator is to dynamically find global reassignments with compensations, such that the overall outcome of the mediator is zero or positive, for example, there would be no extra mediation cost. Given an existing assignment \(A_{c}\) at a given time, the algorithm we propose for calculating a new assignment \(A_{n}\) with compensations is summarised as follows:  
1. Assign all pending transportation requests to vehicles using the NVNS rule and add the assignments to \(A_{c}\)
2. Calculate an optimal assignment \(A_{n}\) between all vehicles and requests assigned in \(A_{c}\)
3. Calculate the overall compensation \(C_{o}\) to be paid /received to/from drivers for the change from \(A_{c}\) to \(A_{n}\)
4. If _mediatorEarning_ - \(C_{o}>0\) then
5.