# Enabling Horizontal Collaboration in Logistics Through Secure Multi-Party Computation
## 4 Toward an MPC-Based Solution for the CFDP
### Description of Our Solution
```  
**Sub-routine 2**create_empty_truck_drive  
```
Inputs:
1 The array of scrambled order objects \([\textsc{orderSet}]=\left(\left[[\textsc{Order}^{(1)}],\ldots,[\textsc{Order}^{( \ell)}]\right]\right)\);
2 The array of scrambled truck objects \([\textsc{TruckSet}]=\left(\left[[\textsc{Truck}^{(1)}],\ldots,[\textsc{Truck }^{(\ell)}]\right]\right)\). 3 An array \([\textsc{Driveset}]\) of scrambled truck drive objects. Computation:
1. Call find_unproc_origin\(([\textsc{orderSet}])\) to obtain the scrambled object describing the position \([\textsc{UnprocPos}]\) of the first unprocessed order. 2. Call find_dist_to_order\(([\textsc{TruckSet}],[\textsc{UnprocPos}])\) to add a \([\textsc{dist}]\) flag to each truck object. 3. Compute \([i]=\mathtt{arg\_min}([\textsc{Truck.dist}]\) for \([\textsc{Truck}]\in[\textsc{TruckSet}])\) to identify a truck closest to the unprocessed order. 4. Select the truck \([\textsc{Truck}^{(i)}]\) with index \(i\); this step can be securely performed with MPC using standard methods. 5. Add the tuple \(\left(\left[[\textsc{Truck}^{(i)}\textsc{haulierId}],\left[[\textsc{Truck}^{(i).position}\right],[\textsc{UnprocPos}]\right)\right)\) to the list of scrambled truck drives \([\textsc{Driveset}]\). 6. \"Move\" the \(i\)-th truck to the position of the first unprocessed order by setting \(\left[[\textsc{Truck}^{(i)}.\textsc{position}]\right]=[\textsc{UnprocPos}]\). By leveraging the sub-routines fill_truck and create_empty_truck_drive, we can now define our solver MPC_solver (Protocol 3) for the CFDP. The algorithm is initialized with the scrambled orders and trucks provided by each huulier, where each order is labeled as unprocessed. Furthermore, the algorithm internally maintains a list of created truck drives and counts the number of orders that have already been processed. The algorithm is then carried out in cycles. In each cycle, it iterates over all trucks and orders, and assigns the order to the given truck using the fill_truck subroutine. The protocol then checks whether any order has been assigned (i.e., whether a truck drive has been created) during this iteration. If this is the case, the next cycle is started; otherwise, create_empty_truck_drive is called to avoid a deadlock. This procedure is repeated until all orders are processed. Finally, each party now receives its assigned orders. Full details are presented in Protocol 3. ``` Inputs: a collaborative freighter delivery instance, given by a map \(\mathcal{M}\), a set of orders orderSet, a set of trucks truckSet, and a set of huuliers haulierSet. Initialization:
1. The owner of each order object Order and truck object Truck uploads them to the MPC framework; scrambled objects [Order] and [Truck] are obtained. 2. For each order object [Order], the [processed] flag is initialized to \([0]\). 3. the parties initialize an empty list of scrambled truck drives [driveSet] \(\leftarrow\)\(\mathcal{O}\). 4. the parties initialize a counter of processed order numprocessed\(\gets\)\(0\). Computation:
1. For each [Truck] \(\in\)[TruckSet] and each [Order] \(\in\)[orderSet], parties run fill_truck\(([\)Truck\(]\),[Order]). 2. Parties compute the (scrambled) number of orders that have been processed in this round, and reconstruct its value; if this number is equal to \(0\), parties run create_empty_truck_drive\(([\)orderSet\(]\),[TruckSet\(]\),[DriveSet\(]\)). 3. Parties update the number of processed orders numprocessed by adding the number of orders processed in this round (computed in the previous step) to it. If numprocessed\(=|\)orderSet\(|\), they proceed to the output phase; otherwise, they update each truck location and reset their volume and destination, and go back to step 1. Output phase:
1. The parties reconstruct the scrambled haulier ID [Order.haulierId] of each order. Notice that this only reveals how many orders are assigned to each haulier, with no other information on the orders or trucks. Similarly, the parties reconstruct the haulier ID associated to each empty drive. 2.