# A Multi-Agent Optimization Approach for Multimodal Collaboration in Marine Terminals
## 3 Model Formulation
### Truck Arrival Management Agent  
The truck arrival management agent is responsible for operations related to logistics companies and trucks. All sets, parameters and variables necessary to describe this agent are listed in Table 2. Each truck that accesses the terminal is considered to be dependent on a vessel \(v\in\mathcal{V}\) and owned by a Logistics Company \(l\in\mathcal{L}\). Additionally, each truck has a distinct job type as either a pickup or a delivery. A single truck is assumed to carry one TEU within the terminal and each truck has its own preferred arrival time-period \(i\in\mathcal{I}\). The sum of preferred arrival time-periods define \(T^{D}_{i,v,i}\) as the number of trucks that company \(l\) prefers to send for delivery jobs related to vessel \(v\) during time-period \(i\). Similarly, \(T^{p}_{i,v,i}\) represents the preferred number of trucks for pickup jobs. The stated preferred arrival periods for trucks simulate the appointment process in the proposed model. Each company is assumed to be characterized by a deviation factor \(\Lambda_{l}\). This deviation factor represents how averse a company is to deviations from their preferred schedule. When the preferred arrival schedule is deemed infeasible, a cost \(c_{l}\) is calculated as described in Equation (8). \[c_{l}=\sum_{i\in\mathcal{I}}n_{i}\cdot\exp\left(\Lambda_{l}*d_{i}\right) \tag{8}\]  
where \(n_{i}\) denotes the amount of trucks that need to be deviated at a specific time period for a logistics company and \(d_{i}\) is the time-period difference between period \(i\) and the first feasible time period. The exponential factor is selected to discourage assignments that differ to a large extent from a truck's preferred arrival period. A preferred arrival schedule may be deemed infeasible in two particular cases. The first cases relate to the timing of truck arrivals not aligning with the vessel's arrival and handling processes. We denote this form of infeasibility as hard. In this case, the preferred arrival schedule can be accepted by the truck arrival management agent, given the berth allocation agent's solution \(w_{v}^{P},w_{v}^{D}\), if the following conditions hold:  
\[ \begin{cases}T_{l,v,i}^{D}=0&\forall i\
otin w_{v}^{D}\\ T_{l,v,i}^{P}=0&\forall i\
otin w_{v}^{P}\end{cases}  \tag{9}\]  
Such infeasibility requires correction by incurring costs to logistics companies and rescheduling the trucks to the next feasible period. For instance, if trucks are planned for pickup in time-period 5 but the vessel moors in time-period 6 and finishes unloading by time-period 8, the trucks must be rescheduled to time-period 9, i.e., the earliest time-period when pickup can occur. Hard deviations are calculated using Algorithm 1. The second case of schedule infeasibility concerns the maximum arrival quota per time-period (\(T_{max}\)). In this scenario, deviations are required to reduce arrivals to \(T_{max}\), ensuring compliance with constraints set by the terminal processes agent. This type of infeasibility is classified as _soft_, as it does not imply an infeasible schedule but instead affects terminal productivity. To address soft deviations, Algorithm 2 is applied, as illustrated through a graphical example in Figure 4.