## 3 Methodology
### Representation by Rules for the MPSP
* Rule \(Lr_{9}\): This rule fills the ship by bay from bay \(b=1\) to bay \(b=B\), and at each bay, it uses a stack score based on the removal priority of the containers in the yard to choose a position to allocate the incoming container, similar to what was performed to choose a position for a blocking container in rule \(Rr_{7}\). It seeks to put in the same stack containers that are going to be unloaded at the same or previous port, putting at the bottom the containers with the furthest destination port. If a container is being loaded, and all stacks already have containers that are going to be unloaded before it, the rule chooses the stacks that lead to the most distant relocation. For example, if there are three stacks available, and the first container to be unloaded at each stack is for port 3, port 4, and port 5, then the rule will choose the port 5 stack. * Rule \(Lr_{10}\): This rule is the same as rule \(Lr_{9}\), with the difference that when there is no stack to allocate a container where it will not cause any further relocation, it chooses the stack with the nearest relocation. For example, if there are three stacks available, and the first container to be unloaded at each stack is for port 3, port 4, and port 5, then the rule will choose the port 3 stack. * Rule \(Lr_{11}\): This rule fills the ship by bay from bay \(b=1\) to bay \(b=B\), choosing the smallest stack to relocate a container. If there are multiple columns with the same height, then it chooses the leftmost stack (i.e., from stack \(c=1\) to \(c=C\)). Finally, to unload the containers from the ship, the unloading rules \(Ur_{a}\) are used. This step is completed when all containers from the ship destined for port \(p\) have been unloaded:  
* Rule \(Ur_{1}\): At any port \(p\), this rule will only remove the containers whose destination is port \(p\) and all the ones that are blocking the stacks. * Rule \(Ur_{2}\): This rule states that all containers on the ship must be unloaded when arriving at a specific port \(p\) to allow for a complete rearrangement of every stack. * Rule \(Ur_{3}\): This rule was adapted from [43] and allows a blocking container to be internally relocated by repositioning it from one position in the ship bay \(b\) to another position in the same ship bay \(b\) if there is space to relocate it in this bay \(b\) and when it  
Figure 6: Ship loading rules’ searching flows. (**a**) Rule \(Lr_{1}\). (**b**) Rule \(Lr_{2}\). (**c**) Rule \(Lr_{3}\). (**d**) Rule \(Lr_{4}\). Figure 7: Ship loading rules’ searching flows. (**a**) Rule \(Lr_{5}\). (**b**) Rule \(Lr_{6}\). (**c**) Rule \(Lr_{7}\). (**d**) Rule \(Lr_{8}\). does not cause a future relocation; that is, in this stack, there are no containers that are going to be unloaded before the relocated container. Otherwise, it is unloaded from the ship. All containers that were unloaded from the ship at a port that was not their destination are loaded back after the unloading operation is finished by using the \(Rr_{e}\) and \(Lr_{l}\) rules that were at the gene applied to that port. Now, we will show how these ship and yard rules may be integrated for use in the simulation program.