# Solving the Container Relocation Problem by Using a Metaheuristic Genetic Algorithm

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Container Relocation Problem—Model Set Up

## 3. Literature Review

## 4. A New Method for CRP Resolving Based on Genetic Algorithm

#### 4.1. Genetic Algorithm

Algorithm 1. Pseudo code of genetic algorithm. |

#### 4.2. A New Method for CRP Resolving

#### 4.2.1. The Chromosome

_{2}). Applying this chromosome to solve the problem in Figure 3, the first blocking container is container 6 because it blocks the retrieval of the container with priority 1. Therefore, as shown in Figure 5, the container with priority 6 must be relocated in stack 2 (s

_{2}). Then, the container with priority 1 can be retrieved and shipped to the next transport location. It can be seen that the container with priority 2 can be retrieved immediately because it is located on the top of the stack with index 0 (s

_{0}).

#### 4.2.2. The Fitness Function

Algorithm 2. Pseudo code of fitness function calculation. |

#### 4.2.3. Selection

#### 4.2.4. Genetic Operators

Algorithm 3. Pseudo code of crossover process. |

_{1}has the values (3, 1, 0, 3, 0, 1, 3, 2, 0, 1) and chromosome

_{2}has the values (0, 2, 3, 0, 2, 2, 2, 1, 3, 0). The crossover point is assigned the value of 4 (crossover is performed for genes on indices 5 to 9) by using a random number function. After performing the crossover operator between these chromosomes, the genes at indices 5 to 9 are interchanged, resulting in two new chromosomes: chromosome

_{1′}with values (3, 1, 0, 3, 0, 2, 2, 1, 3, 0) and chromosome

_{2′}with values (0, 2, 3, 0, 2, 1, 3, 2, 0, 1).

Algorithm 4. Pseudo code of mutation process. |

## 5. Results and Discussion

^{®}Core™ i5-8265U CPU 1.60 GHz processor and 8 GB of RAM. The method described above was implemented in Java using the integrated development environment (IDE) NetBeans 11.3. Additionally, the Java Genetic Algorithm and Programming (JGAP) library [45] was used to implement the genetic algorithm in this programming procedure. The method was tested with different parameter values within the genetic algorithm to find the best possible setup of the genetic algorithm to obtain the highest quality solutions in the shortest possible time. The best possible setting of the genetic algorithm had the following parameter values: the number of generations was 300, the size of the population of each generation was 100, the mutation probability was 0.05, and elitism (the best possible solution from the previous generation is automatically included in the next generation) was set, and the percentage of chromosomes from the previous generation that is included in the next generation was 0.5. The small number of chromosomes in each population (100) allows very fast execution of the genetic algorithm. However, to obtain high quality solutions (chromosomes), the number of generations must be increased, as well as the percentage of the crossover probability which, in addition to mutation, allows a diverse searching of solution space for CRP. Half of the chromosomes (solutions) of the previous generation are included in the process of the next generation of genetic algorithm, so such selection ensures that quality solutions are included in the search process along with the newly randomly generated solutions of the next generation. All parameters of genetic algorithm and their values are given in Table 1.

_{1}) (Figure 13b). However, this is not the best possible option because, when the container 5 would have to be retrieved, the container 9 should be relocated over the container 7 or container 6 (i.e., the nearest stack). Thus, there is an additional relocation move that slows down the process of retrieving containers. Our newly proposed method is not restricted with any rule, so the genetic algorithm can randomly determine the stack with index 3 as the position for relocating container 9 (Figure 13c). In this way, containers 4, 5, 6, and 7 can be retrieved without making additional relocations resulting in a faster retrieval process.

## 6. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## References

- International Maritime Organization. Available online: https://www.imo.org/en (accessed on 13 May 2022).
- United Nations Conference on Trade and Development 2017; Review of Maritime Transport; United Nations: New York, NY, USA, 2017; ISBN 9789213628089.
- Steenken, D.; Voß, S.; Stahlbock, R. Container Terminal Operation and Operations Research—A Classification and Literature Review. OR Spectr.
**2004**, 26, 3–49. [Google Scholar] [CrossRef] - Dundović, Č.; Hess, S. Unutarnji Transport. i Skladištenje; Pomorski Fakultet Rijeka: Rijeka, Croatia, 2007. [Google Scholar]
- Kozan, E.; Preston, P. Genetic Algorithms to Schedule Container Transfers at Multimodal Terminals. Int. Trans. Oper. Res.
**1999**, 6, 311–329. [Google Scholar] [CrossRef] - Bianchi, L.; Dorigo, M.; Gambardella, L.M.; Gutjahr, W.J. A Survey on Metaheuristics for Stochastic Combinatorial Optimization. Nat. Comput.
**2009**, 8, 239–287. [Google Scholar] [CrossRef] [Green Version] - Caserta, M.; Schwarze, S.; Voß, S. Container Rehandling at Maritime Container Terminals. Oper. Res. Comput. Sci. Interfaces Ser.
**2011**, 49, 247–269. [Google Scholar] [CrossRef] - Caserta, M.; Voß, S.; Sniedovich, M. Applying the Corridor Method to a Blocks Relocation Problem. OR Spectr.
**2011**, 33, 915–929. [Google Scholar] [CrossRef] - Mirjalili, S.; Mirjalili, S.M.; Lewis, A. Grey Wolf Optimizer. Adv. Eng. Softw.
**2014**, 69, 46–61. [Google Scholar] [CrossRef] [Green Version] - Mitchell, M. An Introduction to Genetic Algorithms; Complex Adaptive Systems; The MIT Press: Cambridge, MA, USA, 1996. [Google Scholar]
- Gulić, M.; Maglić, L.; Valčić, S. Nature Inspired Metaheuristics for Optimizing Problems at a Container Terminal. Pomorstvo
**2018**, 32, 10–20. [Google Scholar] [CrossRef] - Preston, P.; Kozan, E. An Approach to Determine Storage Locations of Containers at Seaport Terminals. Comput. Oper. Res.
**2001**, 28, 983–995. [Google Scholar] [CrossRef] - Bazzazi, M.; Safaei, N.; Javadian, N. A Genetic Algorithm to Solve the Storage Space Allocation Problem in a Container Terminal. Comput. Ind. Eng.
**2009**, 56, 44–52. [Google Scholar] [CrossRef] - Kozan, E.; Preston, P. Mathematical Modelling of Container Transfers and Storage Locations at Seaport Terminals. In Container Terminals and Cargo Systems: Design, Operations Management, and Logistics Control Issues; Kim, K.H., Günther, H.-O., Eds.; Springer: Berlin/Heidelberg, Germany, 2007; pp. 87–105. [Google Scholar]
- Park, T.; Kim, J.; Ryu, K.R. Iterative Replanning Using Genetic Algorithms for Remarshaling in a Container Terminal. In Proceedings of the 10th IASTED International Conference on Artificial Intelligence and Applications, AIA 2010, Insbruck, Austria, 15–17 February 2010. [Google Scholar]
- Gheith, M.; Eltawil, A.B.; Harraz, N.A. Solving the Container Pre-Marshalling Problem Using Variable Length Genetic Algorithms. Eng. Optim.
**2016**, 48, 687–705. [Google Scholar] [CrossRef] - Maglić, L.; Gulić, M.; Maglić, L. Optimization of Container Relocation Operations in Port Container Terminals. Transport
**2020**, 35, 37–47. [Google Scholar] [CrossRef] [Green Version] - Maglić, L. Optimizacija Raspodjele Kontejnera Na Slagalištu Lučkoga Kontejnerskog Terminala. Ph.D. Thesis, Faculty of Maritime Studies, University of Rijeka, Rijeka, Croatia, 2016. [Google Scholar]
- Hussein, M.; Petering, M.E.H. Genetic Algorithm-Based Simulation Optimization of Stacking Algorithms for Yard Cranes to Reduce Fuel Consumption at Seaport Container Transshipment Terminals. In Proceedings of the IEEE Congress on Evolutionary Computation, Brisbane, Australia, 10–15 June 2012. [Google Scholar]
- Jovanovic, R.; Tuba, M.; Voß, S. An Efficient Ant Colony Optimization Algorithm for the Blocks Relocation Problem. Eur. J. Oper. Res.
**2019**, 274, 78–90. [Google Scholar] [CrossRef] - ElWakil, M.; Gheith, M.; Eltawil, A. A New Simulated Annealing Based Method for the Container Relocation Problem. In Proceedings of the 6th International Conference on Control, Decision and Information Technologies (CoDIT), Paris, France, 2 September 2019. [Google Scholar]
- Dorigo, M.; Gambardella, L.M. Ant Colony System: A Cooperative Learning Approach to the Traveling Salesman Problem. IEEE Trans. Evol. Comput.
**1997**, 1, 53–66. [Google Scholar] [CrossRef] [Green Version] - Peter, J.M.L.; Emile, H.L.A. Simulated Annealing: Theory and Applications; Springer: Dordrecht, The Netherlands, 1987. [Google Scholar]
- Wu, K.-C.; Ting, C.-J. A Beam Search Algorithm for Minimizing Reshuffle Operations at Container Yards. In Proceedings of the International Conference on Logistics and Maritime Systems, Busan, Korea, 15–17 September 2010. [Google Scholar]
- Sculli, D.; Hui, C. Three Dimensional Stacking of Containers. Omega
**1988**, 16, 585–594. [Google Scholar] [CrossRef] - De Castillo, B.; Daganzo, C.F. Handling Strategies for Import Containers at Marine Terminals. Transp. Res. Part B Methodol.
**1993**, 27, 151–166. [Google Scholar] [CrossRef] [Green Version] - Kim, K.H. Evaluation of the Number of Rehandles in Container Yards. Comput. Ind. Eng.
**1997**, 32, 701–711. [Google Scholar] [CrossRef] - Hwan Kim, K.; Bae Kim, H. Segregating Space Allocation Models for Container Inventories in Port Container Terminals. Int. J. Prod. Econ.
**1999**, 59, 415–423. [Google Scholar] [CrossRef] - Caserta, M.; Schwarze, S.; Voß, S. A Mathematical Formulation and Complexity Considerations for the Blocks Relocation Problem. Eur. J. Oper. Res.
**2012**, 219, 96–104. [Google Scholar] [CrossRef] - Petering, M.E.H.; Hussein, M.I. A New Mixed Integer Program and Extended Look-Ahead Heuristic Algorithm for the Block Relocation Problem. Eur. J. Oper. Res.
**2013**, 231, 120–130. [Google Scholar] [CrossRef] - Zehendner, E.; Caserta, M.; Feillet, D.; Schwarze, S.; Voß, S. An Improved Mathematical Formulation for the Blocks Relocation Problem. Eur. J. Oper. Res.
**2015**, 245, 415–422. [Google Scholar] [CrossRef] - Kim, K.H.; Hong, G.P. A Heuristic Rule for Relocating Blocks. Comput. Oper. Res.
**2006**, 33, 940–954. [Google Scholar] [CrossRef] - Jovanovic, R.; Voß, S. A Chain Heuristic for the Blocks Relocation Problem. Comput. Ind. Eng.
**2014**, 75, 79–86. [Google Scholar] [CrossRef] - Bacci, T.; Mattia, S.; Ventura, P. The Bounded Beam Search Algorithm for the Block Relocation Problem. Comput. Oper. Res.
**2019**, 103, 252–264. [Google Scholar] [CrossRef] - Zhang, H.; Guo, S.; Zhu, W.; Lim, A.; Cheang, B. An Investigation of IDA * Algorithms for the Container Relocation Problem. In Trends in Applied Intelligent Systems; Springer: Heidelberg/Berlin, Germany, 2010. [Google Scholar]
- Expósito-Izquierdo, C.; Melián-Batista, B.; Marcos Moreno-Vega, J. A Domain-Specific Knowledge-Based Heuristic for the Blocks Relocation Problem. Adv. Eng. Inform.
**2014**, 28, 327–343. [Google Scholar] [CrossRef] - Zhu, W.; Qin, H.; Lim, A.; Zhang, H. Iterative Deepening A* Algorithms for the Container Relocation Problem. IEEE Trans. Autom. Sci. Eng.
**2012**, 9, 710–722. [Google Scholar] [CrossRef] - Murty, K.G.; Wan, Y.W.; Liu, J.; Tseng, M.M.; Leung, E.; Lai, K.K.; Chiu, H.W.C. Hongkong International Terminals Gains Elastic Capacity Using a Data-Intensive Decision-Support System. Interfaces
**2005**, 35, 61–75. [Google Scholar] [CrossRef] [Green Version] - Zhang, C.; Guan, H.; Yuan, Y.; Chen, W.; Wu, T. Machine learning-driven algorithms for the container relocation problem. Transp. Res. Part B Methodol.
**2020**, 139, 102–131. [Google Scholar] [CrossRef] - Feng, Y.; Song, D.-P.; Li, D.; Zeng, Q. The stochastic container relocation problem with flexible service policies. Transp. Res. Part B Methodol.
**2020**, 141, 116–163. [Google Scholar] [CrossRef] - Zweers, B.G.; Bhulai, S.; van der Mei, R.D. Optimizing pre-processing and relocation moves in the Stochastic Container Relocation Problem. Eur. J. Oper. Res.
**2020**, 283, 954–971. [Google Scholar] [CrossRef] [Green Version] - Ting, C.-J.; Wu, K.-C. Optimizing container relocation operations at container yards with beam search. Transp. Res. Part E Logist. Transp. Rev.
**2017**, 103, 17–31. [Google Scholar] [CrossRef] - Galle, V.; Barnhart, C.; Jaillet, P. A new binary formulation of the restricted Container Relocation Problem based on a binary encoding of configurations. Eur. J. Oper. Res.
**2018**, 267, 467–477. [Google Scholar] [CrossRef] - Jebari, K.; Madiafi, M. Selection Methods for Genetic Algorithms. Int. J. Emerg. Sci.
**2013**, 3, 333–344. [Google Scholar] - JGAP. Available online: https://sourceforge.net/projects/jgap/ (accessed on 20 July 2022).
- Fathollahi-Fard, A.M.; Hajiaghaei-Keshteli, M.; Tavakkoli-Moghaddam, R. Red deer algorithm (RDA): A new nature-inspired meta-heuristic. Soft Comput.
**2020**, 24, 14637–14665. [Google Scholar] [CrossRef] - Yazdani, M.; Jolai, F. Lion Optimization Algorithm (LOA): A nature-inspired metaheuristic algorithm. J. Comput. Des. Eng.
**2016**, 3, 24–36. [Google Scholar] [CrossRef] [Green Version]

**Figure 2.**Yard container bay and RTG crane [17].

**Figure 13.**An example of a different solution of container relocation between our previous method and the proposed method: (

**a**) Current situation within the yard bay; (

**b**) the situation within the yard bay after applying one possible rule proposed in [17]; and (

**c**) the situation within the yard bay after applying one relocation of our newly proposed method.

**Figure 14.**A comparison of the results of method GA with rules and our new method for all 40 instances of the test set for bay size 6 × 7.

**Figure 15.**An analysis of the average computational results (in seconds) of our new method for solving CRP of different bay sizes (3 × 3–6 × 7).

Parameter | Value |
---|---|

Number of generations | 300 |

Size of population | 100 |

Mutation rate | 0.05 |

Number of genes within the chromosome | 10 × number of containers in CRP |

Percentage of selected chromosomes from previous generation | 0.5 |

Elitism | set |

**Table 2.**The results of the CRP test set [24] on real sizes of bays achieved by the proposed method and the other best models of different authors.

Tiers × Stacks | No. of Containers | A* (A-Star) Method [35,37] | Decision Support System [38] | Min-Max [29] | Chain [33] | Chain F [33] | BSA [24] | GA with Rules [17] | New GA Method | Linear Programming |
---|---|---|---|---|---|---|---|---|---|---|

3 × 3 | 7 | 3.58 | 3.42 | 3.42 | 3.42 | 3.38 | 3.38 | 3.38 | 3.30 | 3.30 |

4 × 3 | 9 | 6.67 | 6.10 | 5.82 | 5.82 | 5.95 | 5.67 | 5.85 | 5.67 | 5.67 |

5 × 3 | 11 | 10.60 | 9.80 | 9.10 | 9.10 | 8.70 | 8.40 | 8.93 | 8.40 | 8.40 |

6 × 3 | 13 | 15.40 | 13.60 | 12.97 | 12.77 | 12.30 | 11.50 | 12.30 | 11.50 | - |

3 × 4 | 10 | 5.67 | 5.03 | 4.95 | 4.95 | 4.95 | 4.85 | 4.98 | 4.85 | 4.85 |

4 × 4 | 13 | 10.50 | 9.05 | 8.75 | 8.72 | 8.57 | 8.43 | 8.55 | 8.42 | 8.42 |

5 × 4 | 16 | 16.30 | 14.50 | 13.12 | 13.02 | 13.17 | 12.20 | 12.63 | 12.25 | - |

6 × 4 | 19 | 23.20 | 19.10 | 17.15 | 17.05 | 16.92 | 15.60 | 16.93 | 15.62 | - |

3 × 5 | 13 | 6.95 | 5.90 | 5.75 | 5.75 | 5.80 | 5.75 | 5.80 | 5.75 | 5.75 |

4 × 5 | 17 | 14.40 | 12.20 | 11.40 | 11.35 | 11.40 | 11.00 | 11.35 | 10.98 | - |

5 × 5 | 21 | 21.00 | 18.10 | 17.07 | 16.95 | 16.65 | 15.60 | 16.75 | 15.60 | - |

6 × 5 | 25 | 31.80 | 25.60 | 23.92 | 23.52 | 23.57 | 21.10 | 22.60 | 21.15 | - |

3 × 6 | 16 | 8.95 | 7.92 | 7.72 | 7.72 | 7.85 | 7.65 | 7.88 | 7.65 | - |

4 × 6 | 21 | 16.00 | 13.20 | 12.67 | 12.55 | 12.60 | 12.00 | 12.48 | 12.02 | - |

5 × 6 | 26 | 26.90 | 22.60 | 20.60 | 20.42 | 20.52 | 19.30 | 20.32 | 19.35 | - |

6 × 6 | 31 | 41.20 | 32.60 | 29.02 | 28.77 | 28.57 | 26.10 | 28.50 | 26.15 | - |

3 × 7 | 19 | 11.50 | 10.10 | 9.02 | 9.05 | 9.17 | 8.95 | 9.15 | 8.95 | - |

4 × 7 | 25 | 19.40 | 20.10 | 16.35 | 16.45 | 16.07 | 15.50 | 16.13 | 15.48 | - |

5 × 7 | 31 | 33.00 | 30.90 | 23.15 | 22.92 | 22.70 | 21.40 | 22.60 | 21.42 | - |

6 × 7 | 37 | 45.80 | 45.00 | 34.40 | 34.07 | 34.07 | 31.00 | 33.55 | 31.62 | - |

Total sum of average relocations | 368.82 | 324.82 | 286.35 | 284.37 | 282.91 | 265.38 | 280.66 | 266.04 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Gulić, M.; Maglić, L.; Krljan, T.; Maglić, L.
Solving the Container Relocation Problem by Using a Metaheuristic Genetic Algorithm. *Appl. Sci.* **2022**, *12*, 7397.
https://doi.org/10.3390/app12157397

**AMA Style**

Gulić M, Maglić L, Krljan T, Maglić L.
Solving the Container Relocation Problem by Using a Metaheuristic Genetic Algorithm. *Applied Sciences*. 2022; 12(15):7397.
https://doi.org/10.3390/app12157397

**Chicago/Turabian Style**

Gulić, Marko, Livia Maglić, Tomislav Krljan, and Lovro Maglić.
2022. "Solving the Container Relocation Problem by Using a Metaheuristic Genetic Algorithm" *Applied Sciences* 12, no. 15: 7397.
https://doi.org/10.3390/app12157397