# A Multi-Agent Optimization Approach for Multimodal Collaboration in Marine Terminals
## 3 Model Formulation
### Truck Arrival Management Agent
\begin{table}
\begin{tabular}{l l} \hline \hline
**Sets** & \\ \hline \(\mathcal{L}\) & Set of logistics companies, indexed by \(l\) \\ \hline
**Parameters** & \\ \hline \(T_{l,v,i}^{D}\) & Number of preferred trucks arrivals for deliveries by company \(l\) for vessel \(v\) in period \(i\) \\ \(T_{l,v,i}^{D}\) & Number of preferred trucks arrivals for pickups by company \(l\) for vessel \(v\) in period \(i\) \\ \(T_{max}\) & Maximum arrival rate for trucks per time-period \\ \(\Lambda_{l}\) & Deviation cost factor per company \(l\) \\ \hline
**Variables** & \\ \hline \(c_{l}\) & Deviation cost incurred to logistics company \(l\), measured in monetary units \\ \(r_{i}\) & Number of cumulative truck arrivals in period \(i\) \\ \(r_{v}^{D}\) & Number of cumulative truck arrivals in period \(i\), related to delivery jobs \\ \(r_{i}^{D}\) & Number of cumulative truck arrivals in period \(i\), related to pickup jobs \\ \(u_{l,v,i}^{D}\) & Number of truck arrivals by company \(l\) for vessel \(v\) in period \(i\), related to delivery jobs \\ \(u_{l,v,i}^{P}\) & Number of truck arrivals by company \(l\) for vessel \(v\) in period \(i\), related to pickup jobs \\  & jobs \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Sets, parameters and variables used by the truck arrival management agent. ```
1\(u^{P}\gets T^{P}\)
2\(u^{D}\gets T^{D}\)
3 for\(l\in\mathcal{L}\)do
4 for\(v\in\mathcal{V}\)do
5 for\(i\in\mathcal{I}\)do
6 if\(i\
otin w_{\cap}^{D}\wedge T_{l,j}^{D}>0\)then
7\(d\gets i-max(w_{\cap}^{D})\)
8\(u_{l,v,i-d}^{D}\gets u_{l,v,j}^{D}+u_{l,v,i-d}^{D}\)
9\(c_{l}\gets c_{l}+u_{l,v,i}^{D}*\exp\left(\Lambda_{i}*d\right)\)
10\(u_{l,v,i}^{D}\gets 0\)
11 elseif\(i\
otin w_{\cap}^{p}\wedge T_{l,j,v}^{D}>0\)then
12\(d\gets min(w_{\cap}^{p})-i\)
13\(u_{l,v,d+i}^{p}+u_{l,v,i}^{p}+u_{l,v,d+i}^{p}\)
14\(c_{l}\gets c_{l}+u_{l,v,i}^{p}*\exp\left(\Lambda_{l}*d\right)\)
15\(u_{l,v,i}^{p}\gets 0\)
16 for\(i\in\mathcal{I}\)do
17\(r_{i}\leftarrow\sum_{l\in\mathcal{L}}\sum_{v\in\mathcal{V}}u_{l,v,i}^{p}+u_{l,v,i}^{D}\)
18 return\(u^{P},u^{D},r,c\)
```  
**Algorithm 1**hard(\(T^{D},T^{P},\Lambda,w^{D},w^{P}\))  
The algorithm begins by identifying congested periods and sorting them from the most to the least congested. In Figure 4, we consider an example where the maximum arrival quota per time-period is set at 100 trucks and only one time-period needs correction. In this context, time-period 2 exceeds this limit by having 30 more truck arrivals than the set limit, indicating a soft violation. For each period \(i\) with a soft violation, if traffic is higher in the prior period \(i-1\) over the subsequent \(i+1\), pickup jobs are selected for deviation to time-period \(i+1\), as slightly delaying a pickup is allowed by our strategy. If traffic is higher in the subsequent period \(i+1\) over the prior \(i-1\), delivery jobs are selected for deviation to time-period \(i-1\), as slightly anticipating delivery jobs is allowed by our strategy as well. If adjacent periods have equal traffic, deviations alternate between pickups and deliveries. In the given example, time-period 3 initially has a lower arrival rate than time-period 1, prompting the rescheduling of five pickups from time-period 2 to time-period 3. After the initial five shifted trucks, the arrival rate of time-period 3 matches that of time-period 1, prompting the rescheduling to alternate between periods 1 and 3. As a result, 10 deliveries are shifted to time-period 1, and 10 more pickups are moved to time-period 3 leading to a total of 15 pickups delayed to time-period 3, bringing both periods to the \(T_{max}\) quota. As indicated by Algorithm 2, if both neighboring periods reach \(T_{max}\), the adjustment window is extended by one additional period to time-period \(i-2\) and \(i+2\). In this example, the remaining five trucks needing rescheduling from time-period 2 are shifted to time-period 4, after extending the adjustment window by one additional period.