METAHEURISTIC ANALYSIS APPLIED TO THE BERTH ALLOCATION PROBLEM : CASE STUDY IN A PORT CONTAINER TERMINAL

The simulated annealing (SA) and genetic algorithm (GA) metaheuristics are comparatively applied to the berth allocation problem (BAP) of a port container terminal. By synthesizing the experimental studies of the BAP available in the literature, the two methods are compared when applied to the same case. For this purpose, six test problems are considered, where SA and GA are compared using four crossover operators. Once the optimal GA crossover operator is determined, computational tests are performed with the data obtained at the port terminal to compare the performance of the two metaheuristics.


INTRODUCTION
The rapid development of international trade and the transportation of containerized cargo have necessitated an increase in the size and number of vessels.This significantly affects the infrastructure of container terminals.Hence, techniques are sought for assisting in the decision making that is necessary for the satisfaction of the growing demand for vessels, without increasing cost, whether due to delays in the service or inefficiency of the operation.
The search for an efficient logistics system that minimizes the waiting and service time for vessels prompted the formulation of an N p-hard combinatorial optimization problem known as the berth allocation problem (BAP) (Aykagan, 2008).An extensive review of BAP is found in the studies by Meersmans  vessel arrival and by berthing priority and condition, i.e., according to the time window offered by the terminal to the ship-owner, considering the total cost of the vessels in line.
The dock time window is a period of time offered by the terminal to the ship-owner on a given day to dock its vessel with the guarantee of a reserved space for berthing.This guarantees the payment of penalties by the terminal in case the vessel arrives during the given time window and is unable to berth owing to berth or pier space unavailability.
Therefore, the primary objective of BAP is the minimization of costs with respect to both the port and the ship-owner that are related to the service time; in this case, the total service time is considered to be from the moment of arrival of the vessel at the port to its berthing and deberthing.
The available models in the literature are classified according to spatial as well as time restrictions.In regard to the spatial restrictions, the classification is performed according to the layout of the docking areas of the port.That is, BAP with discrete layout (DBAP) and BAP with continuous layout (CBAP) can be defined.In DBAP, the docking area is partitioned in so called berths, where only one vessel can be served in a specific time interval, and the vessel's length cannot be longer than the berth length.In CBAP, the docking area is not partitioned, i.e., the vessels may dock in any position along the wharf or pier (Imai et al., 2005b).
The time restrictions include arrival time, berthing time, and waiting time in line.Time restrictions mainly occur in relation to the berthing and deberthing time.In the literature, the time restrictions have been classified as static arrival and dynamic arrival.In the former, it is assumed that all vessels are already in the anchoring area, ready to berth.Therefore, the arrival time can be disregarded.By contrast, in the latter, the vessels have different arrival times throughout the planning horizon; hence, they cannot berth before their arrival time.Thus, a sequence of vessel services should be performed, called vessel line.BAP with dynamic arrival reflects the port management needs more accurately (Bierwirth & Meisel, 2010;Imai et al., 2001).Arrival time can be either deterministic or stochastic.In the deterministic case, arrival time is considered a fixed parameter of the problem.By contrast, in the stochastic case, the uncertainties in the arrival time, caused by problems in the ports or navigation problems, are taken into consideration.Several studies have addressed various characteristics of BAP.New mathematical formulations are considered in the discrete, continuous, as well as real cases.
The systematic literature review of the subject revealed the existence of experimental studies aiming to identify the behavior of algorithms in relation to the BAP, and of studies that apply comparison/competition to validate the implementation of an algorithm for the BAP.Chart 1 summarizes the most frequently cited studies on this subject in the Scopus Online database.It shows the title and authors, the objective function, the method applied in the solution of BAP, and provides a brief summary of the conclusions of each study.
Chart 1 -Summary of the experimental studies of BAP in the literature.

Authors and title
Studied Method(s) Summarized Conclusions Imai et al. (2001) and Nishimura et al. (2001) Minimize the total waiting and handling times for every vessel.
The calculations obtained with GA indicated the efficient use of 5 berths instead of 7 berths used in a Japanese public port.The tests (fictitious data) demonstrated that the quality of the solution obtained by the (GA) was the same/similar to the one obtained by the (LR).Kim & Moon (2003) Minimize the penalty cost resulting from delay and the additional handling costs resulting from non-optimal locations.Simulated Annealing applied to CBAP.
The unfeasibility of the mixed-integer program (MIP) technique with 7 vessels was demonstrated, and the Simulated Annealing algorithm was suggested.

Cordeau et al. (2005)
Minimize the sum for each vessel of the service time.
The Tabu search algorithm applied to DBAP.
It was demonstrated that the Tabu search algorithm outperformed both the first-come first-served rule and CPLEX.

Imai et al. (2008)
Minimize the total service time.
Genetic Algorithm applied to DBAP.
The number of rejected vessels owing to lack of service within the maximum time limit was minimized.The study is useful for the efficient management of extremely busy container terminals in underdeveloped countries.

Minimize
the total weighted service time of all the vessels.Optimization based GA heuristic (OBGA) and GA for DBAP.
Sensitivity analysis for the parameters of the OBGA and GA heuristics was performed.Both heuristics proved to be efficient, with small changes in the value of the objective function.

Mauri et al. (2008b)
Minimization of the number of rejected vessels due to the lack of service within the maximum time limit established.
Minimization of the number of rejected vessels due to the lack of service within the maximum time limit established.
Population Training Algorithm (PAT) in combination with Linear Programming (LP) for Column Generation for DBAP.
The results demonstrated the potential of the proposed approach, where high quality solutions were obtained for relatively large problems, in significantly short processing time.Buhrkal et al. (2011) Minimize the total waiting and handling times of every ship.Biased Random Key Genetic Algorithm (BRKGA) for DBAP.
The required computational time showed that, even in small-scale instances, the problem is difficult to solve by CPLEX.The use of BRKGA was justified for the solution of the tactical berth Allocation problem in realworld contexts; particularly, in those integrated designs where this problem frequently appears as a sub-problem.Therefore, the use of efficient procedures that provide nearoptimal solutions within short computational time is preferable.

Lalla-Ruiz et al. (2016b)
Minimize the total time required for the vessels to pass through the waterways.
Simulated Annealing for the Waterway Ship Scheduling Problem (WSSP) for (BAP).
Computational experiments showed that the problem is difficult to solve, even in smallscale instances, using a general-purpose solver.Nevertheless, the proposed S approaches may provide high-quality solutions in short computational time.Moreover, the tests showed that the SA approaches are suitable for contemporary problems.Hsu (2016) Minimize the total cost consisting of the sub-costs of waiting, delay and operation.
The proposed HPSO was compared with the two GA-based approaches.Among the three approaches, HPSO required the longest, albeit reasonable, computational time.Thus, it remains acceptable.

Mauri et al. (2016)
Minimize the sum of the service times while the vessels stay into the port.
The computational tests indicated the relative superiority of the ALNS heuristic for solving DBAP and CBAP.It determined all known optimal solutions for DBAP within shorter computational time.Better solutions were obtained for CBAP.Venturini (2017) Minimize the cost of idleness, delay, handling and the fuel consumption.

CPLEX
A novel formulation was presented by integrating the BAP with vessel speed optimization for multiple ports under environmental considerations, in particular ship air emissions.
The literature review demonstrates the importance of algorithms for the solution of BAP in port operations.Even though they do not ensure that an optimal solution will be obtained, the heuristic methods described in Chart 1 are effective and suitable for real-world applications (Imai et al., 2001) Formally, the classical vehicle routing problem (VRP), is defined using a graph G = (V , A), where V = {v 1 , v 2 , . . ., v m } ∪ V 0 is a vertex set and A = {e 1 , e 2 , . . ., e n } is a set of arcs.Each vertex v i ∈ V − V 0 represents a client to be served, where v 0 ∈ V 0 represents a berth.Moreover, each arc (i, j ) ∈ A is associated with a non-negative cost c i j , usually the distance between two vertices.
It is important to note that all routes have berths (v 0 ) as start and arrival points and include a subset of A. Each client has a demand q = 0 to be met by one of the r vehicles initially berthed in the berth and it can only be visited once.VRP consists in determining a set of routes for minimizing the sum of the costs attributed to the arcs of A. Moreover, special attention is drawn to the fact that the capacity Q of the associated vehicle for each route should be respected.The multi-depot vehicle routing problem (MDVRP) is a generalization of VRP, where the set of vertices V is defined by V = {v 1 , v 2 , . . ., v m } ∪ V 0 , where V 0 = {v 01 , v 02 , . . ., v 0g } are the depots.The route i is defined as R i = {g, v 1 , v 2 , . . ., v n , g} with g ∈ V 0 and n = m.The cost of a route can be calculated as in the classic VRP.
Therefore, in the BAP model, the vessels are regarded as clients and the berths as garages or depots (each with its own specific vehicle).There are m vehicles (one for each depot) and each vehicle starts and finishes its route in its own depot.The vessels are modeled as vertices in a multigraph, where each depot (berth) is still divided into an origin vertex and a destination vertex.These vertices are constructed to correspond to the operating period of the berths.
The model proposed by Cordeau et al. (2005) is discrete and can be represented by a multigraph , and M and N are the set of berths and vessels, respectively.
Each berth k can be represented by a super vertex that contains two elementary vertices o(k) and d(k) that correspond to the operating period of berth k.The route R to berth k is the set where vessel v 1 is the first vessel to be served in berth k, whereas vessel v n is the last vessel to be served in berth k.In the berth allocation problem, the following sets of variables and constants are considered: N = set of vessels; M = set of berths; Subject to: Equation ( 1) represents the objective function (OF) that minimizes the time elapsed since vessel arrival, berthing, and service, with respect to the total allocation cost.Restriction (2) ensures that each vessel is allocated to a single berth, where vessel j is served after vessel i in berth k.Restriction (3) ensures that only one vessel will be the first to be served by each berth, i.e., there is only one vessel j that will be joined to the origin vertex o(k).Similarly, restriction (4) ensures that a single vessel will be the last to be served by each berth; this vessel i will be joined to the destination vertex d(k).Restriction (5) ensures the conservation of flow for the other vessels, i.e., the service for the vessels allocated to berth k, which will enter and exit the respective berth.Restriction ( 6) determines the calculation of the berthing time of the vessels that can be served by the berths.Restrictions ( 7) and ( 8) ensure that the berthing time will be after the arrival of the vessel, and that the time at which the service ends for a vessel will be prior to the limit time of the vessel (within the time window).Restrictions ( 9) and ( 10) ensure the non-violation of the time windows in the berths.Finally, restriction (11) ensures that the decision variables are binary.
In this model, according to observations, the service time (with its associated cost value) is represented in expression (12).Expression (13) minimizes the violations of the time windows of the vessels.Likewise, expression ( 14) minimizes the violations of the time windows of the berths.
Analyzing the restrictions of the model above, we note that it relates to a Multi-Depot Vehicle Routing Problem WITHOUT Time Windows.The model could result in impracticable solutions for the BAP; however, these are eliminated through the penalization imposed by the factors w = [w 0 , w 1 , w 2 ] added to the objective function.

METHODOLOGY
A metaheuristic is a set of concepts that can be used to define heuristic methods applicable to an extensive set of different problems.A metaheuristic can be seen as a general algorithmic structure that can be applied to different optimization problems, with relatively few changes required for adaption to specific problems.
According to Pureza & Morabito (2003), one concept of metaheuristics is that they represent techniques that, when applied to local search methods, exceed local optimality and yield a solution of the highest quality.
The SA and GA algorithms were designed to determine the minimum of a function that represents some characteristic of the modeled process.The evolution of these algorithms in time is completely different.In its search process, SA uses a single point, always generating a new solution from it, which is tested and may be accepted or not.By contrast, GA uses a set of points called a population, from which another population is generated and is always accepted.The common characteristic of these two algorithms is that the next point or the next population are generated obeying the stochastic properties.

Initial Solution and Neighborhood Structure
The initial solution for the problem is obtained using two heuristics: the berth distribution heuristic and the vessel programming heuristic.The distribution heuristic is responsible for allocating the vessels to the berths and the programming heuristic determines the service time of the vessels in the berths.
As neighborhood structure, three swap movements were used, following Mauri (2008): reordering of vessels (one vessel is selected to swap position with another vessel in the same berth), reallocation of vessels (one vessel is selected and allocated to another berth, where this vessel meets the berth restrictions), and swap of vessels (selected vessels in different berths are swapped, where the vessels must respect the restrictions imposed by the berths).All details about the heuristics and the neighborhood structure can be found in Rodrigues (2013).

Simulated Annealing Applied to BAP
The SA algorithm originated from an algorithm called Metropolis (1953), and Kirkpatrick et al. (1983) suggested its use in a computational environment.The basic principle of the algorithm is to allow selected solutions worse than the current solution to explore the neighborhood, thereby escaping the local minimum and enabling the search to reach regions that are more promising.The SA algorithm is described as follows: 1.
GENERATE (a solution S using the distribution heuristic); 3.
EVALUATE (solution S using the programming heuristic); 4.

RETURN (S).
In line 1, the algorithm is started with the parameters used by Mauri et al. (2008).In line 2, there is an initial solution through the distribution heuristic.Initially, m empty berths are generated.
The n vessels are organized in order of arrival at the port and are sequentially and randomly distributed in the berths; however, it is always verified whether the selected berth can serve that particular vessel.
In line 3, the initial solution is evaluated using the programming heuristic.The calculations of the berthing time of each vessel and the objective function are performed.In this heuristic, the superposition of times is eliminated with the calculation of the berthing time of the vessels.
In line 4, S * is assigned to the value of the initial solution S, provided that it is the optimal solution at this step.In line 5, the iteration counter is initiated.
In line 6, the initial temperature value (T 0 ) is assigned to T .The parameter T 0 should be large enough for all transitions to be initially accepted.
Lines 7 and 8 establish the stopping criteria.While the temperature is higher than the current temperature and the number of iterations is smaller than the maximum number of iterations, execute the step of line 10.
Line 9 represents the increase of iterations.Line 10 generates a random neighbor solution S through one of the swap movements (reordering, reallocation, and swapping of vessels).
In line 11, the neighbor solution S is evaluated using the programming heuristic.
In line 12, the variation of the objective function (cost) is tested, i.e., = f (S ) − f (S).In line 13, if < 0, the method accepts the solution and S' becomes the new current solution.
In line 14, the current value is tested whether it is smaller than the stored value S*.If positive, the value of S is accepted.
From line 15 to line 19, if ≥ 0, the neighbor candidate solution can also be accepted; however, in this case, with probability of e − /T , where T is the parameter that regulates the probability of accepting worse cost solutions.
In line 20, after a fixed number of iterations (the number of iterations required by the system to reach thermal equilibrium at a given temperature), the temperature gradually decreases at a cooling rate of α.In this procedure, at the beginning, there is greater chance to escape the local minima, and as T approaches zero, the algorithm behaves similarly to a descending method because the probability of accepting worsening movements decreases.
The procedure terminates when the temperature reaches a value close to zero (freezing temperature: T c ) and solutions that worsen the value of the optimal solution are no longer accepted, i.e., when the system is stable.The solution obtained when the system is in this state indicates a local minimum, which, in some cases, is also a global minimum.
The reheating technique was also implemented to further improve the solutions obtained by SA.This technique consists in, after executing SA, applying it once again, using the optimal solution obtained so far as the initial solution.Different parameter values are used in the reheating.The initial temperature is reduced, compared with "normal" SA, and the maximum number of iterations increases.Hence, the search for better solutions intensifies in the spatial search region close to the initial solution, i.e., the reheating refines the solution obtained by SA.

Genetic Algorithm (GA) applied to the BAP
The GA algorithm attempts to simulate the natural evolutionary process of speciation and genetics, as shown in Figure 1.According to Michalewics (1992), the algorithm applies random choices to guide the search towards spatial regions with likely improvements, maintaining a set of potential solutions (a population of individuals).However, the probabilistic aspect of GA is distinguished from sheer random search.As in SA, the initial population for BAP is generated through the vessel distribution heuristic.The population size should range between 50 and 100 individuals because, depending on the population size, the performance of the algorithm could be affected.Overly small populations have lower diversity than that required for convergence to a satisfactory solution, with the possibility of premature convergence.Furthermore, overly large populations can affect the computational cost of the problem, as the search space could become excessively large.In the present study, the path representation was selected, where the individual is represented by a numeric vector; thus, the sequence represents vessels N i to be allocated to a specific berth B k , as shown in Figure 2. Therefore, each individual (chromosome) determines one solution for BAP, representing the berth allocation of the vessels.The cost of this programming is the value of the objective function, or aptitude of the individual from the population.

Evaluation of the Individuals
In this step, the same programming heuristic is used as in the SA algorithm, for determining the least costly programming of vessels, objective function, or aptitude (which minimizes the function).For each individual, the value of the objective function is calculated, and the best individuals are selected to reproduce in the current generation.The individuals are ordered according to their aptitude, i.e., their adaptation level with respect to the population where they belong.
According to Whitley (1994), the calculation of the aptitude function in GA could require a considerable amount of time, as for each iteration it is necessary to evaluate an entire population of potential solutions (individuals), rather than only one solution, as compared with other optimization techniques.

Selection
The selection process of individuals from the population for reproduction is performed by the evaluation of the aptitude function of the individuals.The most apt individuals form an intermediary population to which the crossover operators will be applied.
According to Beasley et al. (1993), the selection process has great influence on the behavior of GA, as the type of selection could cause premature convergence or unacceptably slow convergence.Hence, there is no definitive method, and there is a need for appropriate selections to address problem classes.
The selection operator used here was the roulette method, where the individuals to be selected are represented in a roulette according to their aptitude.In this method, the individuals are selected to be part of an intermediary population using the drawing roulette.The aptitude level of each individual is related to the portion occupied by the individual in the roulette, i.e., individuals of higher aptitude will have a larger section in the roulette.The present study also included the use of elitist selection, i.e., the most apt individual of a population automatically proceeds to the next population.

Crossover Operators
The crossover operator is the most significant part of GA.The operator performs the swap of parts of pairs of individuals in an attempt to obtain better individuals from the selected individuals.The probability ranges between 40% and 95%.In the implemented algorithm, the crossover rate was fixated at 85% for all operators.
In the present study, the main operators were selected to adequately represent the individuals from the population along pathways.According to Potvin (1996), they are classified as follows: operators that preserve the absolute position as the Partially-mapped Crossover (PMX) and the Cycle Crossover (CX), and the operator that preserves the relative order as the Order Crossover (OX).In addition to these crossover operators, a heuristic crossover (HX) version was used.We now explain the handling of BAP solutions by these operators.Many problems for which the GA metaheuristic could be used have a typical issue in relation to the crossover operation.Namely, the elements of a chromosome may appear in a different order; however, the set of elements should be the same.The same occurs in the allocation problem: Although the order in which the vessels are served could vary, all vessels must be served.The recombination of two points selects two locations for the parent chromosomes to be sectioned.The entire section between these two points is changed, resulting in two different chromosomes.In this case, the offspring generated by each set of parents could often result in offspring with duplicated vessels, while some vessels may not appear on the list.Figure 3 illustrates this situation.

Partially-Mapped Crossover (PMX)
To solve the abovementioned problem, other types of crossover have been studied, for instance, Partially-Mapped Crossover (PMX).In PMX, a tournament subsequence of one of the parents is selected, preserving the order and position of as many positions as possible from the other parent.
A subsequence is first demarked by two sectional points.Then, the segments between the sectional points are swapped.A series of mappings is extracted from the swapped segment.In the example below: N 1 ↔ N 8 , N 9 ↔ N 5 , N 8 ↔ N 7 , and N 6 ↔ N 3 .The second step is to fill all positions where there is no conflict; in the example shown in Figure 4, this corresponds to positions N 4 and N 2 in both chromosomes.The last step is to use the mappings to fill the remaining positions, previously marked with X .Using the N 1 ↔ N 8 , mapping in vector O 1 there is, once again, a conflict; therefore, the mapping N 8 ↔ N 7 should be used to obtain an unrepeated gene.The positions in O 1 and O 2 relative to the duplicated elements are shown in Figure 4.

Order Crossover (OX)
OX creates an offspring by selecting a subsequence of a tournament from one of the parents, preserving the relative order of positions of the other parent.Using the previous crossover example, the sequence is sectioned in two points.From the second point of one of the parents, Pesquisa Operacional, Vol.38(2), 2018

Cycle Crossover (CX)
The CX operator preserves the absolute position of the vessels in the parent chromosomes.The first offspring is obtained with the repetition of the first vessel from P 1 , the position corresponding to this vessel is searched in P 2 , and the vessel will be inherited, preserving the position occupied in P 1 .The procedure continues until the chromosome is filled.In case a cycle is formed, the positions will be occupied by individuals from P 2 .Figure 6 shows the scheme of CX.The first vessel of P 1 is repeated in O 1 , the corresponding vessel in P 2 is N 7 , which is copied in O 1 , preserving the position occupied in P 1 .The same is repeated for N 8 , N 4 , and N 5 when the corresponding vessel in P 2 finishes one cycle.Henceforth, the offspring O 1 is filled with the individuals from P 2 , preserving the order occupied in the chromosome.

Heuristic Crossover (HX)
This operator applies heuristic information unexplored by other operators, uses the path representation, and considers the smallest allocation cost.The HX operator can be described as follows:  1. Select a random vessel from one of the parent chromosomes.
2. Compare the allocation costs for the next vessel in both parents and select the smallest.
3. If the lowest cost selected forms a cycle in the partial route, then choose a random cost that does not introduce a cycle.
4. Repeat steps 1 and 3 until all vessels are included in the berth.Figure 7 shows an example of the HX crossover where vessel N 8 was randomly selected; therefore, the allocation cost for N 5 and N 6 is analyzed, which are the next vessels in P 1 and P 2 , respectively.Assuming that the lowest cost corresponds to the sequence N 8 → N 5 , the cost analysis is performed for the next allocation.With regard to vessel N 7 , there is a cycle; hence, any vessel that does not introduce a cycle is randomly selected.In this example, vessel N 4 was selected, leaving only vessel N 1 to conclude the chromosome.

Mutation
From the selected individuals, the mutation operator performs random swaps of some genes of the individuals, enabling the study of new areas in the search space.Therefore, it avoids premature convergence of the population, maintaining the population diversity, and avoiding local minima.
In the reviewed literature, the mutation rate should be predicted within a range of 1% to 5%.
The implemented mutation operator was that of simple inversion proposed by Michalewicz (1992), where two points are randomly selected in the chromosome and the subsequence between them is inverted.
In this study, the operator was applied to each chromosome in the population with a probability of 2%.

Stop Criterion
Several criteria can be chosen to terminate the execution of GA: after a given number of generations (total evolutionary cycles), when there is no further improvement of the average aptitude or the best individual, when the aptitudes of the individuals from a population become similar, or when the diversity in the population is lost.
In this study, the selected stop criterion was the maximum number of generations, which was set at 150.000.

COMPUTATIONAL TOOL DEVELOPMENT
Recently, optimization tools have been increasingly used in simulators (Pureza & Morabito, 2003;Cherri et al., 2013).Moreover, approximation or heuristic algorithms as well as simulation tools have been combined with optimization tools.
Thus, a computational tool was developed with the aim of solving BAP using the SA and GA algorithms.The user is able to simulate different scenarios to find the optimal berth allocation for vessels, and therefore reduce (minimize) the waiting time in line and calculate the optimal berthing time to be offered.
The computational tool is fed by data about the date and time of arrival of the vessels, the duration of the time window (time period offered by the terminal to the ship-owner in order that the vessel, on a specific day, have the guarantee of space reserved for its berthing or the payment of penalties by the terminal if the time window is reached and the vessel cannot be berthed owing to lack of available berth).The computational tool offers some flexibility to the user with respect to the use of the algorithms.In the GA simulation, the crossover operators, the number of iterations (generations), and the mutation rate can be selected.These alternatives are used for adjusting the parameters in the algorithm, affecting the simulation of the problem.In the SA simulation, the initial solution can be obtained by four methods: user definition, movement swap, setting vessels in berths, and rejecting vessels; all these options are detailed in Rodrigues (2013).Moreover, the SA algorithm can be executed with or without the reheating procedure.The operational cost for each day of berth allocation is provided by GA and SA, which allow the daily follow-up of the solutions.
The interface of the developed tool allows the generation of a report on the data of the vessels, that is, a list of vessel arrivals and a list of berths (capacity, opening and closing times).Furthermore, all the results obtained in the process, the optimal solutions obtained, and the parameters in the application of the SA and GA metaheuristics are recorded.Moreover, in the case of SA, the total reallocation, reordering, and swap movements of the vessels are recorded.This allows for better evaluation of the neighborhood structure that uses the three movements, and the choice is made in a random but uniformly distributed manner.It should be emphasized that the application offers the option of securing vessels to the berths, as, in real situations, it may happen that a vessel can only be allocated in a berth appropriate to its type of cargo.

Computational Tests
The computational tests were performed on a PC with an Intel Pentium R Dual-Core T4400 2.20 GHz CPU and 4 GB of RAM.The implementation was developed in the Delphi language based on Object Pascal (Pascal with object-oriented extensions) because it allows the inclusion of different simulation tools and the representation of dynamic aspects, increasing the model's accuracy.
The first computational tests were performed to measure computational time and the quality of the solution in regard to the crossover operators used in GA and the randomly applied swap movements in SA.The performance of these tests was used to demonstrate the quality of the solution obtained by the HX crossover operator, which used in the comparison of the SA and GA algorithms, in the allocation of 62 vessels to 3 berths of a container terminal.Hence, 6 test problems with real data were run 10 times each, involving 35, 55, and 62 vessels allocated to 5 and 10 berths.The mean results are presented in Tables 1, 2, 3, 4, 5, and 6, as follows: It can be seen that GA yielded superior solution and computational time compared with SA, in all tests.The problems involving 35 vessels did not show improvement in the objective function for the various crossover operators used.The HX and PMX operators yielded the optimal solutions; however, the computational time of the HX operator was significantly longer compared with  PMX.The (SA + Reheating) combination yielded the same solution as GA, with significantly longer computational time.In the problems involving 55 and 62 vessels, the optimal solution was obtained with the HX operator.Some tests were performed with (SA + Reheating); however, the computational time was longer than 45 min, yielding no better solutions than with GA.In all instances, the HX operator yielded the optimal solutions.
Considering the performed tests and the evidence of the local search procedures used by the SA and GA algorithms, special attention should be drawn to the qualitative evaluation of their behavior.
The scenario of analysis was derived from real situations found in the programming of vessels at a container terminal that uses three berths.This information is available on the website of Terminal de Conteineres -TECON RioGrande S/A (http://www.teconline.com.br).
The tests were performed based on a terminal with three operating berths of fixed length and a total of 62 vessels, with the following information: predicted time and date of arrival, length (meters), service time (00:00'00"), duration of time window (00:00'00"), and value in current currency of service time per minute.Some of these data are fictitious, for instance, the service cost, as it was not provided by the container terminal.

Obtained Results
30 tests were performed for each metaheuristic, for the same instance (62 vessels, 03 berths).These provided data for the final objective function as well as the run time for each metaheuristic.
For the first analysis, the graph shown in Figure 8, which compares the values of the objective function for each test, indicates the less volatile behavior of GA, as the values obtained for the objective function range from 185,000 to 190,000, whereas the SA exhibits greater variations.
By performing the same analysis for the run time of each metaheuristic, the graph shown in Figure 9 was obtained.It can be seen that the GA exhibits shorter run time compared with SA.
Pesquisa Operacional, Vol.38(2), 2018 This may be attributed to the difference between the neighborhood structures of each heuristic, as in SA, movements are randomly performed, whereas in GA, the selected crossover operator mandatorily performs all swap, reordering, and reallocation movements.Using the data obtained from a sample of 30 tests, the average run time and final OF were estimated, assuming that they represent the corresponding true values of the population, which are unknown.These and other estimations are presented in Table 7.Based on these estimations, the GA metaheuristic is more efficient than the SA metaheuristic in terms of the final OF and run time, as the objective of BAP is to minimize OF with the use of computationally efficient tools.
The consistency of the solution can be determined by calculating the standard deviation and the coefficient of variation.Both demonstrate that the values for OF and run time tend to be closer to the average in the case of GA.

Discussion
An important observation related to the number of vessels that were not allocated owing to violation of the time window is that GA allows the allocation of more vessels within the time window, which leads to a smaller cost in the objective function.
There is an apparent problem, namely, the implemented metaheuristics do not consider the possibility of interruptions in the service time due to the closing/opening of the berth, i.e., each vessel starts and concludes its operation on the same day.The vessels that are unable to conclude the operation on the day of their arrival are allocated at the first available time after 00'00" (min/s) on the following day.
For academic purposes, the analyses presented here are based on the results obtained using the GA and SA metaheuristics; however, the evaluation of their efficiency would require the comparison of these results with real data, which unfortunately are not available.Nevertheless, the GA metaheuristic implemented in the present study yielded better results.This implies a reduction in the operational costs of a terminal, the primary objective of BAP.
One of the objectives of this study was the search for instances of the proposed problem where the similarities and differences of the implemented metaheuristics would be exhibited.In this respect, the final results obtained according to the optimal objective function of each algorithm were compared.Thus, the vessels allocated to each berth by date and the final daily OF were considered.These data were obtained from the report generated by the application.The main difference was in the value of OF when the SA algorithm was executed.On January 12, 13, and 16, the objective function obtained by SA was superior to that of GA.This is attributed to the non-allocation of vessels.
In Table 8, on January 12, vessel CAP MELVILLE was not allocated.CAP MELVILLE arrived on January 11, with time window until 20:00 on January 12.This caused an increase in the objective function and forced the violation of the time window of this vessel on January 13, adding costs to the objective function for January 13 as well.
On January 16, there was a different situation; vessel MESSOLOGI, which arrived on January 15 with time window until 21h of January 16, was allocated to berth 3, after vessel MSC ADRI-ATIC, whose arrival was on January 16.As observed, the randomness of the neighborhood structure of the SA algorithm may have caused this incident because berth 2 was available to serve MESSOLOGI, which would prevent it from violating its time window.
The computational tests indicate the possibility of applying the studied metaheuristics to real situations, even if they represent medium and large-scale problems.

CONCLUSIONS
The present study aimed at describing the comparative application of the simulated annealing (SA) and genetic algorithm (GA) metaheuristics to the berth allocation problem (BAP) in a port container terminal.
The study highlighted important issues that naturally emerge when attempting to solve a berth allocation problem in a port terminal, namely, the selection and comparison of algorithms.In this respect, considering the performed bibliographical review, the present study can be added to the studies of DBAP.The studied algorithms were implemented to develop a computational tool, allowing the follow-up of the local search procedures in the determination of the optimal solutions for the problem.The first computational tests indicated the selection of the HX crossover operator for the comparison of GA and SA in the berth allocation of the port container terminal.The tests demonstrated the dynamic balance between diversification (breadth-first search = BFS) and intensification (depth-first search = DFS) in the applicability of the metaheuristics.
It is important to emphasize that the tests performed in this study were not intended to compare the techniques competitively, but rather to show that they are complementary tools in the decision-making process.The computational tool developed for the resolution of DBAP will encourage studies in research areas that aim at identifying and collecting a set of test problems for evaluating the performance of the GA and the SA algorithms.
Great caution should be taken when generalizing the statements about the performance of the algorithms, as it is not possible to state that an algorithmic approach is superior to another for a given problem.However, this issue may be meaningless because many current studies aim at hybridization and attempt to generalize the main characteristics of the studied algorithms.
Considering that BAP is a Combinatorial Optimization problem, and therefore non-polynomial, it should be emphasized that the computational time required for its solution is not deterministically calculated as a function of the dimension of the problem.This study does not exhaust the studies of BAP or those of the presented metaheuristics.The results obtained are encouraging; however, there are still gaps to be filled by future studies.For instance, continuous allocation.That is, a reformulation of the BAP modeling that allows the exclusion of the berth opening and closing times, as, in practice, some ports do not operate with this condition, although there is shift change (dockers, machine operators, etc.) Another key point would be a review of the restrictions and programming of algorithms, avoiding the interruption of service time owing to the closing/opening of the berth; although there could be a break in the berth service, in real situations, the vessel could start operating immediately after its arrival as long as there is an available berth, regardless of the break in the operational service, and as long as it does not generate costs for the terminal owing to, e.g., the violation of the time window of the vessel.
Generalized set-partitioning (GSPP) applied to DBAP.The performance of five formulations of DBAPs was compared.It was claimed that the model proposed by Cordeau et al. (2005) is computationally advantageous.The results obtained with GSPP were superior to those obtained by (Cordeau et al. 2005).Hu (2015) Minimize the work of cargo operated at nighttime.The multi-objective GA (moGA) for the bi-objective DBAP.The importance of the preference for daytime operations was demonstrated.Owing to the lack of research on the optimization of daytime shift allocation, the optimal performance of the algorithm should be studied in future work.Pesquisa Operacional, Vol.38(2), 2018 Lalla-Ruiz et al. (2014) Maximize the sum of the values of the chosen quay crane profiles and minimize the yard-related housekeeping cost.
at which the first vessel berthed in berth k; T k d(k) , ∀k ∈ M = time at which the last vessel berthed in berth k; t k i = duration of the service of vessel i in berth k; a i = time of arrival for vessel i; b i = time at which the time window ends for vessel i; v i = value (cost) of the service time for vessel i; s k = opening time for berth k; e k = closing time for berth k;

Figure 1 -
Figure 1 -Flowchart for the execution of GA.

Figure 8 -
Figure 8 -Comparative graph of the Final Objective Function.

Figure 9 -
Figure 9 -Comparative graph of run time.

Table 8 -
Differences between the programming of SA and GA.