In the packing problem described in the previous chapter, we are faced with the problem of packing the set of pallet stacks obtained from the prior stacking process completely into a container. This problem was identified as being equivalent to a two-dimensional rectangle packing problem and an order-based genetic algorithm (GA) integrated with a rectangle packing algorithm was proposed for solving it. The proposed GA’s overall operation is similar to that of a standard GA, with some minor differences in chromosome representation and hence the im- plementation of the genetic operators. Candidate solutions are represented by chromosomes encoded as an order-based list of pallet stacks, with each pallet stack having an orientation property (0 or 1) that determines what orientation the stack will be packed in.
The GA’s initial population is generated by randomly assigning the orienta- tion of each stack in a given stack list to 0 or 1, and shuffling the order of the stacks in the list. The fitness of a chromosome is evaluated using the integrated rectangle packing algorithm which sets the fitness to the total number of stacks in the stack list that it is able to completely pack into the container. During the fitness evaluation process (see Algorithm 4.4), the algorithm checks if each stack (more precisely the bottom pallet of each stack) can be rotated. If the stack can be rotated, it is packed with the rectangle packing algorithm in the orientation assigned to the stack in the chromosome; if not, it is packed in the
stack’s only acceptable orientation irrespective of the orientation assigned to it. In dealing with the rotations this way, we satisfy the fourth constraint identified and considered in Chapter 1:
• Boxes can either be rotated or not. If a box is allowed to rotate, it can only be placed in a container in any of two given orientations; otherwise, it can only be placed in a single orientation.
When generating subsequent populations, the ‘random’ selection method is used for selecting chromosomes for reproduction. We use random selection in- stead of other GA selection mechanisms that tend to explicitly favour to some degree the selection of the fittest members of the population (e.g. tournament or roulette selection) because at this point the only fitness measure available to us is a binary measure that indicates if a given stack list can be completely packed into a container or not; and if the stacks can be packed completely, the entire GA process is stopped as a solution would have been found. This type of measure is not a good selection criterion; hence, the ‘random’ selection method, which does not rely on using any measure as a selection criterion, was selected.
During reproduction, after two parent chromosomes are selected, we employ a one-point crossover operation, which selects a random point in both chromosomes and swaps the orientations of the stacks in their end parts. The resulting children chromosomes obtained from the swaps make up the next population. As in the standard GA, reproduction via crossover is subject to a crossover probability. In the mutation operation employed, the order of the pallet stacks that comprise a chromosome is shuffled. As with crossover, this mutation is also subject to a mutation probability. In the overall operation of the algorithm, if a chromosome is evaluated and found to have a fitness equal to the total number of stacks in the chromosome (i.e. all the stacks in the chromosome can be packed completely), the algorithm terminates as a solution has been found; otherwise, the algorithm runs till it reaches the maximum number of generations and terminates indicating that no solution could be found that could be packed completely into the container for this particular selection of stacks.
Algorithm 4.4 Packing Algorithm - Fitness Evaluation Input:
StackList . i.e. candidate solution / chromosome Output:
fitness f itness ← 0
for all stack ∈ StackList do if stack can rotate then
stack.orientation ← suppliedOrientation else
stack.orientation ← def aultOrientation end if
canP ack ← TryPack(stack) if canP ack == true then
f itness ← f itness + 1 end if
end for
return f itness
4.4.1
The Simple Rectangle Packer
The rectangle packing algorithm employed as the integrated packer in the Pack- ing algorithm is called the Simple Rectangle Packer. It corresponds to the ‘Shelf Next Fit’ algorithm in Jyl¨anki [2010] and to the ‘Next-Fit Decreasing Height’ algorithm in Lodi et al. [2002] without the initial step that sorts items by non- increasing height. It is a simple algorithm optimised for runtime performance. It does sacrifice a bit of space efficiency for its high performance and low memory usage, but the time needed to pack a new rectangle isO(1) [Markus Ewald,2009]. It achieves good results with near-uniform sized rectangles but will waste lots of space with rectangles of varying dimensions. As our pallet set is weakly het- erogeneous (see Section 3.1), we selected this algorithm for its high performance expecting it to achieve good results when used as the integrated packer.
In its operation, the algorithm begins with a new row with height set to 0. For each rectangle it has to pack, it adds the rectangle to the current row
from left to right. If the rectangle’s height is greater than the row’s height and the entire packing area height has not been exceeded, the row’s height is set to the rectangle’s height. If the rectangle does not fit in the row (i.e. adding the rectangle makes it exceed the packing area width), the row is closed and another row is created. The process then repeats, adding rectangles to the row from left to right. When the packing area’s height is exceeded, the algorithm is no longer able to pack any rectangles. The algorithm is presented in Algorithm 4.5. Its implementation in code can be found in Markus Ewald [2011a].