## 3 Methodology
### Rules Representation for the CRP  
To represent the flow of containers through a port yard, an occupation matrix \(yard_{p}\), where \(p=1,2,\ldots,P\), was employed as illustrated in Figure 1. In each position (\(i\),\(j\)), where \(i\in H\) and \(j\in W\), there is an index representing a container. As stated, this index represents the removal order of the containers; that is, container 1 is the first one to be retrieved, followed by container 2, and so on until container \(N_{p}\). For all rules, if the target container is at the top of its stack, and it is retrieved from the yard. Otherwise, an available position within the yard's stacking area must be found to relocate it and clear the access to the target container. To do so, the retrieval rules (\(Rr_{e}\)) run a search through the yard in a fixed pattern, which is different for each rule. When the available position is located, the first blocking container is relocated to this position. This procedure is repeated for all blocking containers above the target container. This step is completed when all containers from the yard are retrieved. All the \(Rr_{e}\) rules necessary for this operation will now be described in detail. The first four \(Rr_{e}\) rules are adaptations of the rules presented in [40]. Rules \(Rr_{5}\) and \(Rr_{6}\) are unpublished in the literature. The last four rules were proposed in the literature and properly adapted to be included in our solution method: the \(Rr_{7}\) rule was proposed in [34], \(Rr_{8}\) in [41], and \(Rr_{9}\) and \(Rr_{10}\) in [33]:  
* Rule \(Rr_{1}\): To locate an available position, this rule searches the yard's occupancy matrix in a fixed direction, starting from the last row \(H\) to the first row \(h=1\), row by row, and from left to right; that is, the stacks are arranged such that \(w=(1,2,\ldots,W)\), as illustrated in Figure 4a. * Rule \(Rr_{2}\): To locate an available position, this rule searches the yard's occupancy matrix in a fixed direction, starting from the last row to the first row, stack by stack, and from left to right, as illustrated in Figure 4b. * Rule \(Rr_{3}\): This rule reverses the direction used in rule \(Rr_{1}\). To locate an available position, it searches the yard's occupancy matrix in a fixed direction, starting from the last row to the first row, row by row, and from right to left; that is, the stacks are arranged such that \(w=(W,W-1,W-2,\ldots,1)\), as illustrated in Figure 4c. * Rule \(Rr_{4}\): This rule reverses the direction used in rule \(Rr_{2}\). To locate an available position, it searches the yard's occupancy matrix in a fixed direction, starting from the last row to the first row, stack by stack, and from right to left as illustrated in Figure 4d. * Rule \(Rr_{5}\): To locate an available position, this rule searches the yard's occupancy matrix in a fixed direction, starting from the last row to the first row, row by row, and alternating the direction in each row; that is, the last row \(H\) goes from left to right, row \(H-1\) goes from right to left, and so on until row \(h=1\), as illustrated in Figure 4e. * Rule \(Rr_{6}\): This rule is the reverse of rule \(Rr_{5}\). To locate an available position, it searches the yard's occupancy matrix in a fixed direction, starting from the last row to the first row, row by row, and alternating the direction in each row; that is, the last row \(H\) goes from right to left, row \(H-1\) goes from left to right, and so on until row \(h=1\), as illustrated in Figure 4f. * Rule \(Rr_{7}\): To relocate the blocking containers, this rule performs a computation of a stack score based on the removal priority of the containers at the yard. The goal is to relocate the blocking container to a new position where there are no containers that are going to be retrieved before it. If there is no such position available, then the stack chosen is the one that has the latest future relocation. For more details, see [34].