# Enabling Horizontal Collaboration in Logistics Through Secure Multi-Party Computation
## 4 Toward an MPC-Based Solution for the CFDP
### Description of Our Solution
To do so, the algorithm checks whether the truck is at the same position as the order, whether the destination of the order and the truck are consistent (or, in case the truck has not yet been assigned a destination because it has no orders already assigned, it defines the destination accordingly), whether the available deck space of the truck is sufficient to process the order, and whether the order has not already been assigned to another truck. If all conditions are satisfied, the order is obliviously assigned to the truck, and all respective variables (remaining capacity, etc.) are updated; otherwise, the order is not processed in the specific activation of the function. create_empty_truck_drive. The sub-routine create_empty_truck_drive (Sub-routine 2) is only called when no further orders can be processed, i.e., if for all unprocessed orders there is no truck available at the same position. In this case, this algorithm moves an empty truck to the position of an order awaiting distribution. In line with the optimization goal in Equation (1), the algorithm sends an empty truck minimizing the distance, i.e., a truck closest to the waiting order. While the fill_truck sub-routine can be fully described by leveraging the building blocks described above, create_empty_truck_drive, on the other hand, requires a number of auxiliary sub-routines that we describe below. * find_unproc_origin takes as input the list of scrambled orders, and outputs the first order for which the processed flag is set to 0. * find_dist_to_order takes as input the list of scrambled trucks and a scrambled order object, and adds to each truck object a scrambled flag \([\texttt{DIST}]=[e.w]\), where \(e.w\) denotes the weight of the edge with origin equal to the position of the truck, and destination equal to the position of the order. * arg_min is a secure arg-min function, i.e., given a list of scrambled integers \(\left[x^{(1)}\right],\ldots,\left[x^{(N)}\right]\), it returns \([i]\) where \(x^{(i)}=\min\Bigl{(}x^{(1)},\ldots,x^{(N)}\Bigr{)}\). ```
1 Inputs:
2A scrambled truck object[Truck];
3A scrambled order object[Order]. 4 Computation:
5 Compute the following scrambled Boolean values: * \(\mathtt{eq}([\textsc{Truck.position}],[\textsc{Order.origin}])\), i.e., compute (without revealing it) whether the truck position coincides with the order origin. * \(\mathtt{eq}([\textsc{Truck.deset}],[\bot])\vee\mathtt{eq}([\textsc{Truck.deset}],[ \textsc{Order.deset}])\), i.e., compute whether the truck has destination equal to that of the order, or whether the destination has not yet been set; in this case the truck would be available for delivering the given order. * \(\mathtt{greater\_eq}([\textsc{Truck.capacity}]-[\textsc{Order.vol}],[0])\), i.e., compute whether the remaining truck capacity is larger or equal to the order volume. 6 Multiply these Boolean values, and multiply the result with \(([1]-[\textsc{Order.processed}])\); denote the obtained scrambled Boolean value by \([\textsc{isCompatible}]\). Notice that the result is equal to \([1]\) if all of the conditions described above are met and the order has not already been assigned to a different truck drive and to \([0]\) otherwise. 7 If truck and order are compatible, update the truck destination to match the order destination; this is performed by setting \([\textsc{Truck.deset}]\leftarrow\mathtt{if\_else}([\textsc{isCompatible}],[ \textsc{Order.deset}],[\textsc{Truck.deset}])\). 8 Update the truck capacity by setting \([\textsc{Truck.capacity}]\leftarrow[\textsc{Truck.capacity}]-[\textsc{Order.vol}] \cdot[\textsc{isCompatible}]\). 9 Update the order haulier indicator to match the truck haulier, if order and truck are compatible; this is performed by setting \([\textsc{Order.Haulier}]\leftarrow\mathtt{if\_else}([\textsc{isCompatible}],[ \textsc{Truck.Haulier}],[\textsc{Order.Haulier}])\)
10 Update the order status with \([\textsc{Order.processed}]\leftarrow[\textsc{Order.processed}]\vee[\textsc{isCompatible}]\).