## 3 Optimization Model
### Model Constraints
\[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]  
When the front ship \(i\) is inbound and the rear ship \(i^{{}^{\prime}}\) is outbound and does not satisfy the two-way navigation requirements:  
\[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tle_{i}-\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,Mode=0, \forall i,i^{{}^{\prime}}\in I, \tag{8}\]  
Finally, when the front ship \(i\) is outbound and the rear ship \(i^{{}^{\prime}}\) is inbound and does not satisfy the two-way navigation requirements:  
\[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}1},Tle_{i}+Ts_{b^{\prime}}),A_{ii^{ \prime}}=1,Mode=0,\forall i,i^{{}^{\prime}}\in I, \tag{9}\]  
(2)  
Berth allocation constraints: All dispatched ships must have available berths as follows:  
\[\sum_{i=1}^{n}X_{i}=n, \tag{10}\]  
The berth type must be matched with the ship type as follows:  
\[M(K_{j}-T_{i})=0,\forall i\in I,j\in J, \tag{11}\]  
The length of the ship is limited by the length of the berth according to the following:  
\[MIo_{i}(BL_{j}-SL_{i})>0,\forall i\in I,j\in J, \tag{12}\]  
Incoming ships must ensure that the pre-allocated berths are free before they enter the port according to  
\[Io_{i}-MBo_{j}>0,\forall i\in I,j\in J, \tag{13}\]  
Each berth can only be allocated to one incoming ship as follows:  
\[Y_{ij}\leq 1,\forall i\in I,j\in J, \tag{14}\]  
An outgoing ship operating at the same berth immediately before an incoming ship is to be dispatched is constrained as follows:  
\[A_{ii_{i}}-MIo_{i}>0,\forall i\in I, \tag{15}\]  
Finally, priority should be given to arranging for ship i to berth at its preferred berth as follows:  
\[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]0  
(3)  
Time flow constraints: The berthing time of all scheduled ships must be later than their actual arrival time at the anchorage as follows:  
\[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]1  
The departure time of all scheduled ships must be later than the completion time of their corresponding operation as follows:  
\[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]2  
Finally, the beginning of operation for ships that are not required to undergo customs inspections (all barges and other marine ships) is defined as later than the berthing time as follows:\[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]3 (4) Bidirectional navigation constraints: The following conditions must be maintained if navigation occurs in both directions: \[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]4 (5) Seagoing ship inspection constraints: The first inspection of a seagoing ship must begin after the berthing time as follows: \[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]5 (6) Operations must begin after the first inspection completion time as follows: \[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]6 (7) The second inspection of a seagoing ship must begin after the completion of the operation as follows: \[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]7 (8) The application for departure from the port must occur after the completion of the second inspection as follows: \[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]8 (9) Finally, the time required for the seagoing ship to enter port and undergo inspection is given by \[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tb_{i}+\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,\forall i,i^{ \prime}\in I, \tag{7}\]9 (10) \[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tle_{i}-\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,Mode=0, \forall i,i^{{}^{\prime}}\in I, \tag{8}\]0 (11) \[T_{b^{\prime}}=max(TP_{f^{{}^{\prime}}2},Tle_{i}-\frac{S_{Gj}}{Vh_{i}}+Ts_{b^{ \prime}}-\frac{S_{G^{\prime}}}{Vh_{i^{\prime}}}),A_{ii^{\prime}}=1,Mode=0, \forall i,i^{{}^{\prime}}\in I, \tag{8}\]1 (12) where ships that cannot be scheduled to enter the port on the same day (\(S_{i}=0\)) are required to re-apply for port entry by 08:42 the next day (based on the 18 min required for ships to pass through the waterway and the 09:00 opening time of the inspection department).