## 3 Methodology  
Our methodology deals with both the CRP and MPSP concomitantly, aiming to reduce the total number of relocations for both the yards and the ship. This way, it is possible to ensure an efficient operation between the ship and port.  
The assumptions presented in the previous section were represented through the simulation modeling that is detailed in Algorithm 1. To define how exactly the loading and unloading would occur, rules representation was used. The rules are functions containing logical commands that describe actions that result in the movement of containers. This means that instead of creating binary variables and corresponding equations that control the position of each container in the ship or the yard, we created generic procedures for how to retrieve and reshuffle containers in the yard and unload and load containers out of and onto the ship.  
The rules that define the plan for the ship stowage operations and the port yard were coded in one vector and passed to the simulation program as a parameter. This parameter was an individual of the genetic algorithm (GA) and represented a possible solution to the problem. After simulating the rules represented by a certain individual, we had the total number of relocation movements performed, which was going to be used by the GA to calculate the fitness value of this individual.  
The mapping through rules representation was already successfully applied to isolated or specific integrated port operations: the multi-port stowage planning problem [36], multi-port stowage planning integrated with quay crane operation [9], or even multi-port stowage planning with the container relocation problem [35].  
The GA generated and selected various individuals in such a way that the total number of relocations performed was minimized, which was the objective of our problem. In the end, the GA would provide the combination of rules that solved each instance of the problem with the least number of relocation movements.  
The use of a method based on rules is justified since it is necessary to provide a feasible solution in a small amount of time for the decision maker. This is not possible even for solving the problems separately when using exact models, as can be seen in [35]. Additionally, our method always produces feasible occupation matrices, facilitating and ensuring the achievement of feasible solutions by heuristic methods.  
The main advantage of this methodology is that there is no limit to the number of rules that can be incorporated. The rules can be simple, sophisticated, or even take into account different operator practices or the prior knowledge of skilled personnel. Any rule can be created, simulated, and have its solution evaluated by the genetic algorithm.  
In the literature, there is a specific term for approaches that limit the search space in terms of easy-to-implement low-level heuristics: hyper-heuristic methods [37; 38].  
Additionally, heuristics are general enough to be applied to several instances of the same problem class, enabling uncertainty evaluation through the evaluation of multiple scenarios [39].  
It is important to stress that the literature considers hyper-heuristics as a heuristic to select one combination of heuristics [37]. Since we employed a meta-heuristic, such as a genetic algorithm, to select a good quality combination of rules, we classified our approach as a meta-hyper-heuristic approach.  
Taking this into account, first, we will individually explain each rule proposed to solve the CRP, followed by the rules proposed for the MPSP. Then, we will explain the integration of both problems by using the simulation program and the search for the best solution using the genetic algorithm.