## 3 Model Description and Formulation
### A Mathematical Formulation for the New Truck Appointment System
#### 3.2.1 A Mathematical Model from the Perspective of the Transport Company (Forwarder)  
The mathematical model (Model 1) for the transport company (forwarder) takes into account the penalties for the waiting time for the truck and the number of rehandling for carry-out containers.  
\[\text{Minimize}\ \sum_{n}\sum_{j}\sum_{k}\Bigg{\{}\frac{\sum_{n}\sum_{i}X_{ ijk}^{n}-1}{2}\sum_{i}X_{ijk}^{n}+r^{n}\frac{T+1}{2}\sum_{i\in\{n\}}X_{ijk}^{n} \Bigg{\}}. \tag{1}\]Subject to,  
\[\sum_{k}X^{n}_{ijk}\geq w^{n}_{ij}\ \text{for all}\ i,\ \ j,\ \text{and}\ n; \tag{2}\]  
\[\sum_{i}\sum_{j}X^{n}_{ijk}\leq v^{n}_{k}\ \text{for all}\ k\ \text{and}\ n; \tag{3}\]  
\[\sum_{n}\sum_{i\
eq k}X^{n}_{ijk}\leq Y_{jk}\ \text{for all}\ j\ \text{and}\ k; \tag{4}\]  
\[X^{n}_{ijk}\geq\ 0\ \text{for all}\ i,\ \ j,\ \ k,\text{and}\ n. \tag{5}\]  
Equation (1) is an objective function that minimizes the sum of the penalties for each transport company's truck waiting and rehandling of carry-out containers. Equation (2) is a constraint, and the number of trucks of task type assigned by the transport company (forwarder) to the yard block must satisfy the number of tasks for the transport company (forwarder) of task type assigned to the yard block. Equation (3) is a constraint, and the number of trucks from the transport company (forwarder) available in time window must be satisfied. Equation (4) is a constraint, and the number of tasks a truck can reserve allocated by the terminal operator for the yard block and the time window must be satisfied. Equation (5) represents the non-negative condition of the decision variable \(X^{n}_{ijk}\). In the mathematical model from the perspective of the transport company (forwarder), we apply \(Y_{jk}\) as a parameter.  
The penalty for the waiting time for the truck is the value calculated by multiplying the number of trucks assigned to the same yard block and time window by the expected time waiting for the task to start. We calculate the expected time waiting for the operation to begin like (6)-(8). \(P_{1}\) is the probability that a truck arrives at the yard block \(j\) and the time window \(k\). \(W\) is the number of tasks for trucks arriving earlier (the waiting time of the target truck), and \(\lambda\) the sequence in which the trucks arrived in the same yard block and time window. \(E_{1}\) is the expected time waiting for the operation to begin.  
\[P_{1}=1/\sum_{n}\sum_{i}X^{n}_{ijk}, \tag{6}\]  
\[W\ =\ \lambda-1,\ for\ \lambda\ =\ 1,2,\ldots,\sum_{n}\sum_{i}X^{n}_{ijk}, \tag{7}\]  
\[E_{1}\ =\ \sum_{\lambda}W\times P_{1}\ =\ \sum_{\lambda=1}^{\sum_{n}\sum_{i}X^{n} _{ijk}}(\lambda-1)/\sum_{n}\sum_{i}X^{n}_{ijk}=\left(\sum_{n}\sum_{i}X^{n}_{ ijk}-1\right)/2. \tag{8}\]  
The penalty for the number of rehandling for carry-out containers is the value calculated by multiplying the number of carry-out tasks, the expected number of rehandlings required to take out one, and the rate that requires rehandling during the carry-out operation. We calculate the expected number of rehandlings to take out one container like (9)-(11) [22]. \(P_{2}\) is the probability of taking a container out of tier \(t\). \(R\) is the number of rehandlings required to take it out of a specific location. \(E_{2}\) is the expected number of rehandlings to take a container out of a bay.  
\[P_{2}=1/T; \tag{9}\]  
\[R\ =\ T\ -\ t\ +\ 1,\ for\ 1\ \leq\ t\ \leq\ T; \tag{10}\]  
\[E_{2}=\ \sum_{t}R\times P_{2}=\sum_{t\ =\ 1}^{T}(T\ -\ t\ +\ 1)/T=(T\ +\ 1)/2. \tag{11}\]