COMPACT: Concurrent or Ordered Matrix-based Packing Arrangement Computation Technique

Packing optimization is a prevalent problem that necessitates robust and efficient algorithms that are also simple to implement. One group of approaches is the raster methods, which rely on approximating the objects with pixelated representations. Although they are versatile in treating irregular geometries, the raster methods received limited attention in solving problems involving rotatable objects, where available studies generally analyze only right-angled rotations. In addition, raster approximation allows the use of unique performance metrics and indirect consideration of constraints, which have not been exploited in the literature. This study presents the new Concurrent or Ordered Matrix-based Packing Arrangement Computation Technique (COMPACT). The method relies on raster representations of the objects that can be rotated by arbitrary angles, unlike the right-angled rotation restrictions imposed in many existing packing optimization studies based on raster methods. The raster approximations are obtained through loop-free operations that improve efficiency. Besides, a novel performance metric is introduced, which favors efficient filling of the available space by maximizing the internal contact between the objects as well as the contact between the objects and domain boundaries. Moreover, the objective functions are exploited to discard overlap and overflow constraints and enable the use of unconstrained optimization methods. Several test problems involving concurrent and ordered packing of multiple rectangular and circular objects into square bins are investigated. The results show that the proposed technique performs effectively in determining the packing arrangements.


Introduction
Packing optimization is an important problem class that concerns various disciplines including warehouse management, shipping, and design of engineering products.The widespread nature of this problem requires robust and efficient algorithms that are easy to utilize.
Various techniques have been developed to solve different packing optimization problems.A large amount of available studies addresses the problem of packing two-dimensional rectangular objects into rectangular bins while keeping the object edges orthogonal to the domain boundaries.For instance, Chen and Huang (2007) computed solutions for two-dimensional rectangle packing problems by introducing a search algorithm that places the rectangles into the container one by one using a corner occupation strategy.Later, Leung, Zhang, Zhou, and Wu (2012) proposed a hybrid heuristic algorithm that combines greedy strategy and simulated annealing methods to solve the rectangular knapsack packing problem.Recently, Chen et al. (2019) developed a deterministic heuristic algorithm for solving the two-dimensional rectangular packing problems that require maximizing the filled portion of the rectangular domain.
Packing problems concerning nonrectangular objects and domains were also prevalently investigated.For example, Del Valle, Queiroz, Miyazawa, and Xavier (2012) developed heuristic approaches for solving 2D cutting/packing problems involving irregular objects.Later, Chen et al. (2018) proposed a heuristic algorithm for solving circle packing problems for placing multiple identical circles into the smallest circular container.Lately, Bouzid and Salhi (2020) investigated orthogonal packing of rectangular objects into a circular space of fixed radius.
The complexity of the packing problems notably increases when the nonorthogonal rotation of the objects is allowed in addition to the translation (Cherri et al., 2016).These problems received relatively lesser attention compared to the problems involving fixed object orientations or orthogonal rotations.In one study, Zhang and Zhang (2009) introduced a 2D packing optimization technique called finite-circle method, which approximates polygons with a set of circles and converts the non-overlapping constraints into simple constraints between circles.Martins and Tsuzuki (2010) used a heuristic approach to minimize the waste space during the rotational placement of two-dimensional polygons into irregular containers.In another study by Martinez-Sykora et al. (2017), a strategy was proposed to solve bin packing problems with irregular pieces that can be freely rotated.
The difficulties in the formulations for packing problems involving irregular objects have led to the development of raster point methods, which rely on approximating the objects on a discretized grid.With these methods, packing configurations can be represented by assigning zeroes to the free domain cells and different values to the cells where a single object is present or multiple objects overlap.The key advantage of raster techniques is their applicability to the problems involving objects with complex shapes, where the main drawback is their resolution-dependent precision (Leao et al., 2019).In the literature, the research on packing optimization with raster methods is limited compared to the available work based on other techniques.In a particular study, Toledo et al. (2013) proposed a discrete modeling approach called the Dotted-Board Model, which relies on representing the bin with a two-dimensional grid and using the plausible grid points for the placement of arbitrary polygons.Later, Mundim, Andretta, and de Queiroz (2017) extended the Dotted-Board Model for packing non-polygonal objects with curved edges and used it within a heuristic approach based on genetic algorithms.Recently, Sato, Martins, Gomes, and Tsuzuki (2019) developed the raster overlap minimization algorithm to solve the irregular strip packing problem using a raster method that limits the solution space.
This study presents the new Concurrent or Ordered Matrix-based Packing Arrangement Computation Technique (COMPACT).In this framework, the object shapes are approximated by matrix-based (raster) representations.The objects can be rotated by angles that are not necessarily restricted to be right-angle multiples, unlike the conditions imposed in many existing packing optimization studies relying on raster methods.The raster approximations are obtained through loop-free operations that improve efficiency.Besides, a novel performance metric is introduced, which aids efficient filling of the available space by maximizing the internal contact between the objects as well as the contact between the objects and domain boundaries.Moreover, the possibility of exploiting the objective functions for discarding overlap and overflow constraints is explored to enable the use of unconstrained optimization methods.As case studies, the developed technique is utilized to pack multiple rectangular and circular objects in square domains using concurrent and ordered placement strategies.The results show that the proposed technique performs effectively in determining the packing arrangements.The organization of the study is as follows: The matrixbased object representation that forms the backbone of the developed technique is described in the following section.Section 3 covers the details regarding the formulation of the optimization problem.Section 4 covers the results from various case studies.In Section 5, the conclusions are stated and the directions for future studies are outlined.

Matrix-based object representation
The proposed technique relies on the raster representation of the objects in the matrix space.Let a rectangular design space be described by an empty matrix with H rows of height and W columns of width.A rectangular object having a height of h rows and a width of w columns can now be modeled within the domain by filling an area consisting of h × w entities with ones.The geometries should be approximated for curved shapes and polygons whose edges are not aligned with the rows and columns.Fig. 1 shows (a) exemplary matrix space approximations of a circle and a rectangle whose edges are aligned with the horizontal and vertical domain axes, and (b) the sparsity pattern of the matrix containing the objects.
The proposed technique does not restrict the edges of the rectangular objects to be aligned with the domain boundaries.Raster approximation of the rotated objects is exemplified with a ℎ = 0.4 = 0.4 by  = 1.5ℎ rectangle rotated by an angle of  = 30° around its top-left corner.Fig. 2 shows the sparsity patterns of this object for domain sizes of (a) 20 × 20, (b) 50 × 50, and (c) 100 × 100, which results in 92, 595, and 2414 nonzero entities (  ), respectively.As seen in this figure, the shape of the rotated geometry is more accurately captured with increasing resolution.A mathematical convergence can also be observed by calculating the ratio of nonzero entities to the total number of domain entities.When an unrotated rectangle is considered, the exact filling ratio (the proportion of ones to the total number of elements) can be calculated as ℎ/ = 0.24.For the presented three cases, the filling ratios are computed as 92/400 = 0.2300, 595/2500=0.2380, and 2414/10000 = 0.2414, which converge to the exact value with higher resolution.However, increasing the number of raster points inherently lengthens the computation durations (Leao et al., 2019).Therefore, excessive discretization resolutions should be avoided to keep the computation durations within reasonable limits.The raster approximations for the rectangles are attained by performing vector inequality operations and elementwise matrix multiplications.In the present study, only top-left corner coordinates of the rectangles are restricted to be integers.The other corners do not necessarily coincide with the matrix grid unlike the conditions enforced with certain raster-based methods such as the Dotted-Board Model (Toledo et al., 2013;Mundim, Andretta, and de Queiroz, 2017).
For a rectangle rotated counterclockwise by  degrees, the row and column coordinates of the bottom right corner (  and   ) can be found as Let   be a row vector and   be a column vector with elements ranging from 1 to H and 1 to W, respectively.Then, the lower and upper boundaries for the rows (  and   ) as well as the columns (  and   ) can be computed as where the brackets '⌊ ⌉' signify rounding towards the nearest integer.Note that,   and   are column vectors where   and   are row vectors.Using the calculated boundary vectors, four constituent matrices can be obtained through the following vector inequalities: The final object representation is attained by performing element-by-element multiplication (denoted by operator '∘') of calculated constituent matrices: The described approach avoids using loops, which in turn substantially accelerates the computations.Fig. 3 demonstrates the constituent matrices and final representation for a sample rectangular object.The final object representation is attained by performing elementwise multiplication of four constituent matrices obtained by using simple vector inequalities.
For circles, the raster approximations can be directly obtained without the necessity of calculating multiple constituent matrices.Let  1 be a row vector of ones with a length of H,  1 be a column vector of ones with a length of W, and  1 be an H by W matrix of ones.Then, the distance matrices along rows (  ) and columns (  ), and resultant distance matrix () can be calculated as follows: Finally, the matrix entities lying inside the circle can be filled with ones using the relation:

Total ones (T1)
The first objective function is simply defined as the number ones in the domain matrix ( 1 ): The maximization of this metric is equivalent to occupying the design space as much as possible without causing overlaps.However, this technique cannot be used in sequential placement as it would rank all feasible locations identically and create an ill-posed problem.

Distance from the center (DC)
As the second objective, the rectilinear (Manhattan) distance between the centers of the objects and domain is maximized.This approach favors filling the areas next to the boundaries starting from the corners.Let the row and column indices of the domain center be    and    , respectively.For a rectangle, the central row (   ) and column (   ) indices can be calculated as Using the central indices, the distance function to be minimized is defined as For a circular object, the distance function can be written as follows:

Distance to bottom-left (DBL)
The third metric is defined as the rectilinear distance between the objects and the bottom-left corner of the domain.Minimization of this distance has been prevalently used in the previous packing studies (Jakobs, 1996;Hopper and Turton, 1999).The negative of the distance is used to be consistent with the other utilized metrics, which are all maximized in the optimization.Therefore, the objective functions for the rectangles (   ) and circles (   ) can be expressed as follows: This objective is only used with sequential packing.

Adjacent ones (A1)
The number of adjacent ones is introduced as the last objective function, which correlates with the overall contact within the domain.This metric promotes efficient utilization of the available space and it is formulated by taking advantage of the raster representation.The objective function to be maximized ( 1 ) is simply defined as the sum of the entities of matrix F, which is the elementwise multiplication of four submatrices of the current domain matrix D:

Design variables
The design variables considered within the optimization are the row and column indices for the upper-left corners of the rectangles (  's and   's) and centers of the circles (  's and   's).When the rotation is allowed for the rectangles, the angles of rotation (  's) are considered as additional design variables.For  rectangular and  circular objects, all the design variables can be assembled into a single vector x as follows:

Bounds on the design variables
The domain of design variables is defined through lower and upper bounds.For rectangular objects, the values of the upper left corner coordinates and the rotation angles are bounded as follows: For circular objects, the bounds on the central indices are defined as (15)

Nonlinear constraints
Two sets of nonlinear constraints are considered while solving the problem.The first set ( 1 ) ensures that the objects are contained within the design space, and the second set ( 2 ) enforces avoiding overlaps.These two sets are stacked together within a vector g that should be smaller than zero:

Containment assurance
When the rotational motion is permitted for the rectangular objects, the lower and upper bounds of the position variables do not guarantee the prevention of overflowing.Therefore, a nonlinear constraint set is defined as For circular objects, the containment is directly ensured through the limits imposed on the position variables.

Overlap avoidance
While placing an object into the domain, the matrices representing the new object and the domain with previous objects are simply summed together.An overlap is detected for the matrix elements with values higher than 1.Therefore, for  total objects, the constraint for the overlap avoidance can be written as While maximizing total ones or adjacent ones as the performance metrics, explicit collision constraints may not be necessary since the improvement in the objective function and reduction in the overlaps are correlated in certain problems.

Optimizer
The described optimization problem is solved using a genetic algorithm capable of handling the non-convex design space.Specifically, the 'ga' function of MATLAB's Optimization Toolbox is used.The genetic algorithms have previously been shown to be effective for escaping locally optimal design points arising in packing problems (Jakobs, 1996;Hopper and Turton, 1999).Since the optimal positions should correspond to the matrix indices, the design variables are constrained to be integers.For the cases involving rotation, the integer angle variable multiplied by the predefined angular increment controls the orientation.

Case studies
This section covers the results from different case studies that involve the packing of rectangular and circular objects into 100 × 100 square bins.Both concurrent and sequential optimization strategies are explored.In the sequential placement, the objects are ordered with the decreasing diagonal length or area.The total number of ones, objects' rectilinear distances from the center, objects' distance from the bottomleft corner, and the number of adjacent ones are used as the objective functions.The combined influence of the optimization settings on COMPACT's performance in solving different problems is investigated.

Non-rotatable objects
The developed methodology is initially utilized to obtain packing configurations for non-rotatable objects.The first study involves sets of rectangular objects whose heights and widths are given in Table 1.These sets are obtained by splitting one rectangle into two new ones at each step as demonstrated in Fig. 5. Hence, the number of rectangles is regularly increased from 4 to 9 while going from the first case (Fig. 5a) to the last one (Fig. 5f).
Table 1 Heights and widths of the rectangles used in the sets used in the first study with restrained rotations.Table 2 shows the success rates in packing all objects of each set for different optimization strategies and objective functions.For each case, the average results for 100 computations are presented.In the concurrent optimization, the effectiveness of maximizing total ones ( 1 ) decreased with the increasing number of objects.Maximizing adjacent ones ( 1 ) showed a similar trend but gave slightly better results for the higher number of objects.No collision avoidance constraints are considered in these studies since the higher values of the objectives also favor reducing the overlaps.

Number
For the sequential optimization, the optimal solutions are found for all trials for the sets with 4 and 5 objects.For the analyzed sets, sorting by diagonal length generally performed better compared to area sorting, which was more slightly more effective for only intermediate numbers (6, 7) of objects.For the length sorting, using the distance to the bottom-left corner (  ) as the objective function provided the best results.However, maximizing adjacent ones also worked fairly well providing a 75% success rate for 9 nine objects.For the second study, another set of objects with the quantities and dimensions specified in Table 3 is used.This set perfectly occupies the domain for optimal packing, which requires placement of the objects according to a regular pattern.For concurrent optimization, the optimal packing could not be found using  1 as the performance metric, where  1 still succeeded 6 times out of 100 trials.For sequential placement,  1 delivered the best results by far with its 40% success rate, where   and   succeeded in 7% and none of the trials, respectively.The effectiveness of  1 originates from its inclination towards maximizing the line of contact, which in turn aids the formation of the required pattern.In Fig. 6, (a) one optimal solution for the second study and (b) positioning preferences of   and  1 during a sample run are demonstrated.
Table 3 The quantities and dimensions of the rectangles used in the second study with restrained rotations.

Rotatable objects
Objects with large aspect ratios may require alteration of their orientation to be fit into the available space.New sets of objects are generated to test the developed methodologies on the packing problems with rotational degrees of freedom.The orientation angle is restricted to be a multiple of 45° to cover diagonal placement possibilities while keeping the problem size minimal.
In the first investigation, a (45 × 45) square and four smaller circles of 39 units diameter are packed into the square domain.Figure 7 shows the optimal packing configuration for these objects.Despite the relatively simple characteristics of the problem, the optimal solution cannot be attained with the ordered placement based on decreasing size.The reason is that all three performance metrics (  ,   , and  1 ) tend to position the large square on a corner leaving room for only three of the circles.Only using   with the small-to-big ordering leads to the optimal solution indicating that packing smaller objects first can be advantageous in certain problems.While the sequential placement performed ineffectively for this problem, concurrent placement with active constraints provided success rates of 5% and 7% for  1 and  1 metrics, respectively.Therefore, if the problem size permits its use, the concurrent optimization strategy can offer versatility in tackling different problems.As another investigation, the concurrent optimization cases are repeated by removing collision and containment constraints.In the absence of constraints,  1 and  1 still yielded 5% and 4% success rates, respectively.These results demonstrate that these metrics intrinsically facilitate the containment of rotatable objects in addition to collision avoidance.The second case study concerns packing three rectangles and six circles into a square domain.The quantities and dimensions of the objects used in this study are given in Table 4.With the optimal packing, all objects in the set can be placed into the domain providing a filling ratio of 74.4% as shown in Fig. 8.
The concurrent optimization strategy is not effective for packing this set due to the increased number of objects and extra rotational degrees of freedom.For this problem, the filling ratios are compared for   ,   , and  1 metrics while collision and containment constraints are held active.When the objects are ordered in decreasing length (diagonal length for the rectangles and diameter for the circles) the average filling ratios over 100 trials were found as 56.7% and 67.7% using   and   , respectively.For this ordering, the best results were achieved with  1 , which yielded an average filling ratio of 70.8%.In this case,  1 outperforms the other metrics since it prefers positioning the smaller rectangles right next to the large rectangle, which is diagonally packed in the first step.Such placement leaves sufficient room at the corners where the large circles can be packed.When area-wise sorting was used,   ,   , and  1 provided 66.3%, 60.4%, and 56.5% mean filling ratios, respectively.Hence, the relative effectiveness of the utilized metrics can be significantly influenced by the ordering strategy.Fig. 8.A sample optimal solution for the objects used in the second study involving rotational degrees of freedom.The filling ratio for this packing configuration is 74.4%.
In the last study, the number of objects is increased to create a more difficult problem, where the quantities and dimensions of the packed objects are specified in Table 5.One possible optimal packing configuration for these objects is depicted in Fig. 9, where the filling ratio is 92.3%.Note that, length-wise and area-wise ordering strategies are identical for this set.
For this problem,   ,   , and  1 provided average filling ratios of 87.2%, 84.3%, and 82.2%, respectively.In this case, slight superiority of   is due to its preference of occupying the corners with the largest objects, which allows the intermediate rectangle to be diagonally placed into space in the middle.The configuration with the highest filling ratio (89.8%) is also achieved by   .The   metric provided the secondhighest mean ratio and showed almost no variability over the runs.Although  1 gave the lowest mean filling ratio, it showed greater variability compared to   and provided a maximum value of 88.2%, which is higher than the maximum ratio obtained by   .Fig. 9.A sample optimal solution for the objects used in the third study involving rotational degrees of freedom.The filling ratio for this packing configuration is 92.3%.

Conclusions
This study presents the new Concurrent or Ordered Matrix-based Packing Arrangement Computation Technique (COMPACT).The proposed method relies on approximating the object shapes by matrix-based (raster) representations.Such an approach provides versatility for packing various shapes and allows the use of new performance metrics.
In the proposed framework, the raster representations are obtained through loop-free operations that improve efficiency.The objects can be rotated by arbitrary angles, different from the right-angled rotation restrictions imposed in many existing packing optimization studies based on raster methods.Besides, a novel performance metric is introduced, which facilitates efficient filling of the available space by maximizing the overall contact within the domain.Moreover, exploitation of the objective functions for discarding overlap and overflow constraints is explored to enable the use of unconstrained optimization methods.
As case studies, the developed technique is utilized to pack multiple rectangular and circular objects in square bins.The suitability of concurrent and ordered placement strategies for solving different problems is investigated.In addition, the effectiveness of the utilized performance metrics is analyzed for various scenarios.The results show that the proposed technique performs effectively in obtaining plausible packing configurations.Furthermore, the case studies provide guidelines for the selection of suitable packing strategies, performance metrics, and constraints according to the problem type.
The developed techniques can certainly be extended for three-dimensional objects in future studies.It can also be used for packing problems involving various other objects and domain geometries.In particular, the new performance metric relying on contact maximization offers great potential for packing non-convex polygons.Although the genetic algorithms perform well with the described formulations, the implementation of other nonlinear optimization methods into the developed framework is also possible.

Fig. 1 .
Fig. 1.Matrix space approximations of a rectangle with ℎ = 3 rows height and  = 4 columns width, and a circle with  = 7 cells diameter.The upper-left corner of the rectangle and center of the circle are located on (  = 8,   = 2) and (  = 4,   = 7), respectively.(b) The sparsity pattern of the matrix containing the objects.

Fig. 3 .
Fig. 3.The constituent matrices ( 1 ,  2 ,  3 ,  4 ) and resulting representation () for an exemplary rectangle.The final object representation is attained by performing elementwise multiplication of four constituent matrices obtained by using simple vector inequalities.

Fig. 4 .
Fig. 4. Demonstration of the principle behind maximizing adjacent ones using two sample domains that contain rectangles (a) in contact (b) separated by zeroes.The sparsity patterns for domain matrices, four submatrices, and elementwise multiplications of the submatrices are shown at the top-left corners, right sides, and bottom-left corners of the subfigures, respectively.The contacting rectangles produce 12 nonzero entities while the separated ones yield 10 nonzero entities.The proposed adjacent ones metric provides several advantages:  It outperforms other metrics in solving certain problems,  It is versatile delivering god results for several different cases,  It is applicable for both concurrent and ordered optimization strategies,  It can be used with or without explicit constraints while performing well in many unconstrained cases.

Fig. 5 .
Fig. 5. Sample optimal solutions for different sets of rectangles used in the first study with restrained rotations.When packed optimally the objects perfectly fill the domain and their number in the sets increases from (a) to (f) as one rectangle is split into two new ones at each step.

Fig. 6 .
Fig. 6.(a) One optimal solution for the objects used in the second study with restrained rotations.The objects perfectly fill the domain for optimal packing.(b) Demonstration of two possible positions for the placement of the second object during a sample run.For   metric both positions are equally preferable whereas the bottom location is more preferable for  1 .

Fig. 7 .
Fig. 7.The optimal solution for the objects used in the first study involving rotational degrees of freedom.

Table 2
Success percentages in packing all objects of each set given in Table1for different optimization strategies and objective functions.

Table 4
Quantities and dimensions of the rectangular and circular objects used in the second study involving rotational degrees of freedom.

Table 5
Quantities and dimensions of the rectangular and circular objects used in the third study involving rotational degrees of freedom.