# Bi-Objective Optimization for Joint Time-Invariant Allocation of Berths and Quay Cranes
## 3 Description and Formulation of BACASP
### Solution Representation  
In the proposed algorithm, integers are used for encoding and each solution consists of three parts, \(\mathit{Nest}\ =\ [BT;BP;NQC]\), where the length of each part is \(|V|\). \(BT\) denotes the berthing time of each vessel, \(BP\) denotes the berthing position of each vessel, and \(NQC\) denotes the number of QCs assigned to each vessel. The coding structure of an individual can be represented as follows:  
\[\mathit{Nest}\ =\ \left\{BT_{1},BT_{2},\ldots,BT_{|V|};BP_{1},BP_{2},\ldots, BP_{|V|};NQC_{1},NQC_{2},\ldots,NQC_{|V|}\right\} \tag{22}\]  
Figure 3: Flowchart of the proposed IMOCS.  
Decoding involves two stages. First, each vessel's berthing position, berthing time, and the number of QCs assigned are derived from the coded information, with the waiting time calculated as the difference between berthing and arrival times, and processing time based on position and the number of QCs assigned. Since the coded information only specifies the number of QCs per vessel without specific QC assignments, an additional assignment step is needed. In the second stage, specific QCs are assigned to vessels by their relative positions in the time-space diagram, which can be achieved by the proposed constructive heuristic algorithm (Algorithm 1). The QCs are uniformly distributed on the seaside in ascending order from left to right and are assigned to vessels without collision. It is worth noting that in order to minimize the distance traveled by QCs, the specific QCs assigned are the ones closest to the vessel's berthing position.  
```
1:A solution \(Nest=[y_{1},y_{2},\ldots,y_{n};x_{1},x_{2},\ldots,x_{n};q_{1},q_{2},\ldots,q_{n}]\) and other relevant parameters
2:A feasible BACASP solution.
3:Initialize \(V_{B}\leftarrow\emptyset\), \(V_{NB}\leftarrow\{\)l,2,...,\(N\}\).
4:while\(V_{NB}\
eq\emptyset\)do
5:Select vessel \(v\) with the earliest berthing time in \(V_{NB}\).
6:if vessel \(v\) overlaps with any vessel \(i\) in \(V_{B}\)then
7:Identifify available berth segments during \([V_{v},y_{v}+t_{v}]\).
8:if\(l_{v}\) continuous available berth segments for vessel \(v\) are foundthen
9:Allocate them to vessel \(v\) and update \(x_{v}\), \(t_{v}\).
10:else
11: Delay the berthing time \(y_{v}\) of vessel \(v\) until a vessel in \(V_{B}\) departs.
12:end
13:else
14: Identify available QCs near \([x_{v},x_{v}+l_{v}]\) during \([y_{v},y_{v}+t_{v}]\)
15:if\(q_{v}\) continuous available QCs for vessel \(v\) are foundthen
16: Assign them to vessel \(v\) and update \(V_{B}\gets V_{B}\bigcup v\), \(V_{NB}\gets V_{NB}\smallsetminus v\).
17:else
18: Delay the berthing time \(y_{v}\) of vessel \(v\) until a vessel in \(V_{B}\) departs.
19:end
20:end
21:end
```  
**Algorithm 1**A constructive algorithm for BACASP  
Figure 4 illustrates a case with four vessels. The following procedure shows the steps of the specific QC assignment.  
1. \(V_{B}\ =\ \varnothing\), \(V_{NB}\ =\ \{1,2,3,4\}\). \(v_{1}\) is the vessel with the earliest berthing time in \(V_{NB}\), so the closest available QCs, 3-4, are assigned to \(v_{1}\);
2. \(V_{B}\ =\ \{1\}\), \(V_{NB}\ =\ \{2,3,4\}\). \(v_{2}\) is the vessel with the earliest berthing time in \(V_{NB}\) and overlaps with \(v_{1}\), so adjust the berthing position and allocate \(l_{2}\) continuous available berth segments to \(v_{2}\), then the closest available QCs, 1-2, are assigned to \(v_{2}\);
3. \(V_{B}\ =\ \{1,2\}\), \(V_{NB}\ =\ \{3,4\}\). \(v_{3}\) is the vessel with the earliest berthing time in \(V_{NB}\), so the closest available QCs, 3-6, are assigned to \(v_{3}\);
4. \(V_{B}\ =\ \{1,2,3\}\), \(V_{NB}\ =\ \{4\}\). \(v_{4}\) is the vessel with the earliest berthing time in \(V_{NB}\) and the QCs cannot cross \(v_{3}\) to serve \(v_{4}\), so adjust the berthing position and allocate the \(l_{4}\) continuous available berth segments to \(v_{4}\), then the closest available QCs, 1-2, are assigned to \(v_{4}\).