Heuristic Methods for Minimizing Cut Bars and Using Leftovers from the One-dimensional Cutting Process

The cutting problems consist in cutting a set of objects available in stock in order to produce the desired items in speciﬁed quantities and sizes. The one-dimensional cutting stock problem involves only one of the relevant dimensions in the cutting process, as in cutting bars, rolls and tubes. The cutting process can generate leftover (which can be reused in a new demand) or losses (which are discarded). This paper presents two heuristic methods for minimizing the number of cut bars in the one-dimensional cutting process, satisfying the items demand in an unlimited bars quantity of just one type. The results of simulations are compared with methods from literature and with the limiting values for this considered type of problem. The results show that proposed heuristics reduce processing time and the number of bars needed in cutting process, while it provides a greater leftover (by grouping losses) for the one-dimensional cutting stock problem. The heuristics contribute to reduction of raw materials or manufacturing costs in industrial processes, such as the automotive industry, construction, bicycle manufacturing and other purposes.


Introduction
The optimization of cutting stock problems aim to determine a set of items to be produced, in order to reduce the number of raw material in cutting process for manufacturing items. This problem belongs to an important area of Operational Research to assist in decision making process. For this reason, the study of cutting stock problems has aroused the interest of researchers [1,3,20,12,4].
There are different methods to mathematically model the cutting stock problems. One of the possible models is the Linear Programming, which proposes to solve linear optimization problems, describing real problems in order to maximize or minimize a given objective function, subject to a set of constraints, whose variables are linearly related [22]. By using Linear Programming models, the cutting stock problem consists of cutting a set of objects available in stock produce the desired items in specified quantities and sizes, in order to optimize an objective function.
The one-dimensional cutting stock problem involves only one of the relevant dimensions in the cutting process, as it occurs with cutting steel bars, paper rolls and tubes [8,9].
Historically, Gilmore and Gomory [13], one of the first to address the cutting stock problem, defines the Cutting Stock Problem as filling an order at minimum cost for specified numbers of lengths of material to be cut from given stock lengths of given cost. Authors described a technique for overcoming the difficulty in the linear programming formulation of the problem, which involves a large number of variables. Later, these authors extended and adapted the methods for cutting stock outlined to the specific full-scale paper trim problem [14]. And, in [15], higher dimensional cutting stock problems are discussed as linear programming problems.
Latter on, authors in [16] developed a sequential heuristic to roll cutting optimization for clothing industry. The issue of roll cutting is defined as a bicriterial multidimensional knapsack problem. After that, these authors applied the sequential heuristic for optimizing one-dimensional cutting stock when all stock lengths are different [17]. A combined method, which uses a sequential heuristic procedure and the branch-and-bound, is proposed in [18] for the solution to the general one-dimensional cutting stock problem.
One branch of cutting stock problem is called the usable leftover cutting stock problems [8], whose purpose is to determine the cutting patterns and to analyze the leftovers generated by the cutting process. This problem consists of one-dimensional cutting stock problem in which the non-used material in the cutting process may be used in the future, if large enough [7].
A particular one-dimensional cutting stock problem with both cutting and reuse decision variables was presented in [3]. It was formulated as an integer linear programming and it was efficiently solved by applying standard packages within a column generation technique.
In [7], classical heuristic methods are modified, so that cutting patterns with undesirable leftover, which are not large enough to be used and nor too small to be acceptable waste, are redesigned. A review of published studies that consider the solution of the one-dimensional cutting stock problem with the possibility of using leftovers to meet future demands, is presented by [9].
Cui and Yang [11] propose a heuristic algorithm for the one-dimensional cutting stock problem with usable leftover, consisting of two procedures: a linear programming that fulfills the major portion of the item demand and a sequential heuristic that fulfills the remaining portion of the item demand. Besides, in [8], it is assumed that leftovers should not remain in stock for a long time. Then, leftovers have priority-in-use compared to standard objects (objects bought by the industry) in stock and a heuristic procedure is proposed for this problem.
The paper [12] presents a review of the most important mathematical models and algorithms developed for the exact solution of the one-dimensional bin packing and cutting stock problems. In addition, the paper experimentally evaluates the performance of the main available software tools. Despite addressing the cutting stock problem, the authors do not address the use of leftovers.
Recently, Cui et al. [10] present an integer programming model for the one-dimensional cutting stock problem with limited leftover types and describes a heuristic algorithm based on a column-generation procedure to solve it. Authors introduced a heuristic procedure in [5], called the Residual Recombination Heuristic. The column generation technique is associated with a set of residual cutting patterns, recombining these residual cutting patterns in different ways, generating new integer feasible cutting patterns. In [6], the only objective to be achieved is to minimize the quantity of cut objects. Authors propose a modification in the Constructive Greedy Heuristic, building a cutting pattern by sorting in descending order the items of pair or odd length.
Finally, a genetic algorithm approach is presented in [2]. A genetic-based decision support system is applied to validate the solution feasibility of the problem and the objective is to minimize the leftovers in pipes cutting.
In the context of cutting stock problems and usable leftovers, the main goal of this paper is to propose two heuristic methods, in order to minimize the number of bars needed to cut known items demand, in the one-dimensional cutting process with no stock. The problem presented in this paper considers an unlimited quantity of one type of bar.
The proposed methods are measured by accuracy and runtime. The two proposed heuristics methods are described in the next section, whose performances are analyzed and compared with methods from literature. The accuracy is rated by: (i) total number of used bars, (ii) the loss and leftover produced in process. The runtime shows that the algorithms present better computational complexity. In this paper, loss and leftover are classified by size of bar not used, i.e, a bar smaller than a smallest item demanded is considered loss, otherwise leftover. The proposed heuristics aim to reduce losses, by grouping multiple losses in the same bar (whenever possible), so that the losses (unusable) become leftovers (usable).
The main contribution is to obtain optimized solutions, which are competitive with those found in the literature for the one-dimensional cutting stock problem, with relevant gains in computational complexity (or runtime) and convert loss to leftover whenever possible, so they can be reused. The heuristics can be used in commercial software solutions, which provide reduction of the raw materials used (or manufacturing costs) and environment preservation.
The remainder of the paper is organized as follows. Section 2 presents the definition of the problem considered in this paper and a numerical example. In Section 3, a numerical example defines the minimum number of bars needed in cutting process. Section 4 initially describes the Selection of Ordered Items (SOI) procedure, used in the first step of both proposed heuristics. After that, the innovations of this paper are presented: the heuristics methods OptmizationDistBSP and OptimizationTREE. The data set for simulation are provided in Section 5, followed by analysis of simulation's results (Section 6). Finally, in Section 7, the conclusion of the paper and the discussion about some aspects of future work are addressed.

Problem Definition
The proposed heuristic methods aim to present solutions for the general problem defined as follows.
Problem: to minimize the number of bars needed to cut known items demand, in the one-dimensional cutting process, such as the demand of items has to be met, by cutting bars of the same size. The demand of items has to be met: P p=1 x ip bar p ≥ d i , ∀i ∈ 1, ..., n, bar p ≥ 0 and integers, where the variables and parameters are described below.
bar p : number of cut bars in the cutting patterns p = 1, ..., P (variable) d i : demand of item i x ip : the number of items i = 1, ..., n cut in the cutting pattern p. In the one-dimensional case, any cutting pattern must satisfy [7] n i=1 l i x ip ≤ L, ∀p ∈ 1, ..., in which L is the size of the bar, l i is the length of item i and this expression guarantees that the number of produced items is not bigger than the size of the bar.
The cutting process can generate leftover (which can be reused in a new demand) or losses (which are discarded). The goal is to reduce losses, by grouping them in the same bar, when possible. Thus, the losses become leftovers.
The following numerical example illustrates a cutting process with a known items demands and how the losses and leftovers are identified. In the example illustrated in Figure 1, a set of different sizes and quantities of items must be produced (2 items of 60cm, 3 items of 55cm and 5 items of 30cm) from one fixed-size bar (180cm).  Table 1.   The three possible cutting patterns are using 3 bars to produce the demanded items. The total amount of unused material is 105cm. The main difference between the cutting patterns is the distribution of the unused material in bars. CP1 distributes the unused material on the three bars, while CP2 and CP3 concentrate it on two bars. Then, unused material is classified as loss (H loss ) or leftover (H lef t ), according to its size, the H represents the heuristic to be used. Considering as loss the unused smaller bar than the smallest demanded item, in this case, the loss will be discarded because it can not be used to produce a new item. Otherwise, the unused material is considered as leftover and can be used for future demand. Equation 3 presents the not used part of the bar by heuristic H .
In this equation, l i and x i are the size and the number of items i used in the cutting pattern, respectively. The classification unused bar: -Loss (H loss ): if unused bar is smaller than the smallest demanded item; -Leftover(H lef t ): if unused bar is greater or equal than the smallest demanded item. Table 1 shows the cutting patterns, in which all CPs have the same size of unused bars. Thus, given a set of demanded items, the cutting patterns should use the smallest number of bars possible, minimizing losses and grouping them in order to make them leftovers.

Minimum Number of Bars
The hypothetical cutting pattern illustrated in Figure 5 presents a distribution of items into the bars, in which the minimum number of bars required to produce the demanded items of the numerical example above, is determined. This is a hypothetical solution since all items must be produced in a continuous piece. Note that an item of 30cm was divided in two parts (the red parts of bars "b" and "c"), resulting in the use of full bars "a" and "b".
The minimum number of bars needed to produce the demanded items is defined in Equation 4. The lower bound of bars (B bar ) is used to evaluate the performance of proposed heuristics, i.e., better solutions use bars close to B bar . If any of the heuristics provide as solution a minimum number of cutting bars smaller than B bar , it means that the algorithm has an error and the solution is unreal.
Considering the items of the numerical example, B bar can be obtained as: Therefore, the minimum number of bars is 3, the same number of bars used in cutting patterns presented in Table 1. When this theoretical limit is achieved, the unused material remaining is defined in Equation 6.
The minimum theoretical limit of unused material (Equation 6) can be classified as follows: -Loss (B loss ): if unused material is smaller than the smallest demanded item; -Leftover(B lef t ): if unused material is greater or equal than the smallest demanded item.
Considering the numerical example, when the lower bound of bars is reached, the size of unused material is classified as leftover: This result indicates that: -The proposed cutting patterns (CP1, CP2 and CP3) are using the minimum number of bars; -The cutting pattern CP3 with continuous leftover nearest to B lef t is the best solution, comparing to cutting patterns CP1 and CP2.

The Proposed Heuristics
In this section, two proposed heuristics methods to solve the problem described in section 2 are presented. These heuristics are evaluated by total number of bars used in whole cutting process, the loss and leftover provided and also computational complexity of solution method.

Selection of Ordered Items (SOI)
First of all, a Selection of Ordered Items (SOI) procedure, described in Procedure 1, must be presented, since this ordering procedure, which is based on the First fit algorithm [19], is used in the first step of both proposed heuristics. This procedure uses as input the set of items demanded (l and d), sorted in descending order of size. Then, the items are selected to be cut, starting with the biggest one; if not possible, the next item is tested and so on. Other inputs are: the size of the bar (L) and the total number of items (n). The outputs are: the number of each items i in the cutting pattern or bar (x), the size of bar not used (L) and the updated demand of items (d).

Procedure 1: Selection of Ordered Items(SOI)
input : l, d, L, n output: x,L, d

OptimizationDistBSP Heuristic
The proposed OptimizationDistBSP heuristic is described in Algorithm 1, in which the set of demanded items is sorted in descending order of size (l). Then, the Selection of Ordered Items (SOI) procedure is used to generate the first cutting pattern (1 st phase). After this first selection, if the bar is not fully used, an optimization process is started (2 nd phase). In the second phase, the Algorithm 1 try to change one item selected to be cut (in 1 st phase) for another two smaller items, using ones that generate a smaller leftover bar. This process is repeated to all items selected in the 1 st phase. After 2 nd phase, the bar not used (L) is classified as leftover or loss.
The inputs of Algorithm 1 are: the items size l = {l 1 , ..., l n }; the items demand d = {d 1 , ..., d n }; the size of bar L; the number of items to be cut n.
Algorithm 1: OptimizationDistBSP Heuristic input : l, d, L, n output: lef tover, loss, bar 1 bar=1 2 Sort items in descending order of size (l) The outputs of Algorithm 1 are: the lef tover of all cuting process; the loss, the sum of loss in each bar used; the bar with sum of used bars.
The variables used in the Algorithm 1 are described as follows: -L: size of bar not used during the execution of the algorithm x i : the number of items i to be cut in the bar, for i = 1, ..., n

Tree-based Heuristic (OptimizationTREE )
A Tree-based Heuristic (OptimizationTREE ) is described in Algorithm 2, which has two phases: (i) selection of the items to be cut and (ii) loss reduction. First, the set of demanded items is sorted in descending order of size (l). In the 1 st phase, a set of items is selected according to Procedure 1. This first set is then used in the 2 nd phase to reduce losses as follows: for each selected item, reduce the number of items to be cut by one unit, trying to fill the rest of the bar with larger elements and then with smaller elements. After the next smaller item to be cut is selected, the algorithm verifies if a larger item can be used, if not, the next smaller item is processed. The inputs, outputs and main variables of Algorithm 2 are the same of Algorithm 1.
In this proposed heuristic, the losses of the cutting process are concentrated on the smallest number of bars possible, using a tree structure [21], in order to convert losses (unusable) into leftovers (usable) and reduce the number of bars needed in process.

Data Set for Simulations
The numerical values used in simulations of proposed heuristics are based on [6], with the aim of minimizing the quantity of cut objects, considering the one-dimensional cutting stock problem. The database contains 18 categories of problems, each one with 100 instances. The categories are divided according to the quantity of items m, the average of the items demandsd, and different combinations of values v 1 and v 2 for determining the length of the items that are generated in the interval [v 1 L, v 2 L], with L the size of the bar, as shown on Table 2 [6].
Python language is used for all the heuristics implementation. In Optimiza-tionDistBSP and OptimizationTREE heuristics, the sorting method used is Quick Sort. Indeed, in order to maintain the same comparison environment, all the methods use Quick Sort. The hardware used for the simulations consists of an Intel processor ® Inside T M Core i7 920 @2.67Ghz with 16Gb of RAM.
For the heuristic simulations, the Linux operating system Ubuntu 18.04 x64 is used. The runtime of the presented instances is also considered in this paper, showing that the results are acceptable in practice.

Results and Discussion
The execution of the instances on each category provides results that allow to analyze in detail the performance of the proposed heuristics in comparison with methods from literature. Results were compared with First Fit Decreasing (FFD) and Greedy constructive heuristics, whose algorithms are found in [6]. As recommended in [6], the method used in this paper for solving the knapsack problem was that implicit enumeration suggested by [14], based on depth search first, enabling through the use of bounding that the worst solutions be discarded without losing the optimal solution. There are, in the literature, other techniques for solving the knapsack problem, such as in [24] and [23]. The constructive heuristics FFD and Greedy are the most famous and most studied methods for an approximative solution of the bin-packing problem. The heuristic proposed by [6], called "Modified Greedy Heuristic for the onedimensional cutting stock problem" was not used for comparison, since the code is not available.
Tables 3, 4, 5 and 6 present the results of OptimizationDistBSP , Opti-mizationTREE, FFD and Greedy heuristics, respectively. The mean of variable bar (bar), the mean of lef tover (lef t) and the mean of loss (loss) are presented by category, followed by its respective standard deviation: σ(bar), σ(lef t) and σ(loss). The penultimate column of these tables shows the runtime for each category, in seconds; and the last column shows the standard deviation of the runtime.    In order to illustrate the performances of the heuristics, Figure 6 represents: (a) the means of cutting bars resulting in OptimizationDistBSP, Optimization-TREE, FFD and Greedy heuristics, and it means minimum number of bars ("B bar"); (b) the standard deviation of cutting bars. Figure 7 represents: (a) the means of leftover, also calculated for the 4 heuristics, and mean of leftover of hypothetical cutting pattern; (b) the standard deviation of leftover. After that, Figure 8 is the same for the losses and Figure 9 presents the runtime for the heuristics. The theoretical value B b ar is also represented in figures. The statistical measures presented in Figures 6-9 indicate the performance across categories, considering the number of cutting bars, the leftover, the loss and the runtime of the proposed heuristics (OptimizationTREE and Optimiza-tionDistBSP ) and the FFD and Greedy heuristics, according to algorithms proposed by [6]. Observing the results of Tables 3, 4, 5 and 6 we can notice that: -The OptimizationDistBSP heuristic presents the number of cutting bars similar to FFD heuristic, however, it presents more leftovers and less losses, as desirable.
-The OptimizationTREE heuristic uses a little more bars than FFD and Greedy, but presenting more leftovers and the lowest losses in all categories. -The OptimizationTREE and OptimizationDistBSP heuristics have more leftovers and less losses when compared to FFD and Greedy heuristics. -The FFD heuristic provides more losses, that is, small parts spread over the bars used in the cutting process. The OptimizationTREE and Opti-mizationDistBSP heuristics provide less losses, which are concentrated in leftover. Thus this leftover can be used to attend the next demand. - Figure 9 shows that runtime of the Greedy heuristic is higher than the OptimizationT REE and OptimizationDistBSP heuristics, especially for bigger exemplars. -Thus, although the 4 heuristics provide a similar number of cutting bars, the FFD and Greedy heuristics generate less leftovers and more losses than the 2 heuristics proposed in this work (OptimizationTREE and Optimiza-tionDistBSP ), performing worse. -As expected, when observing Figure 8, the OptimizationTREE heuristic generates the smallest number of loss, followed by OptimizationDistBSP heuristic, showing the more desirable performance. - Figure 7 shows that the OptimizationTREE heuristic generates more leftovers, followed by OptimizationDistBSP heuristic. Generating leftovers is desirable when the number of cutting bars is close to B bar , since leftovers are used to meet next demands. In the proposed heuristics, the leftovers are concentrated in the last bars. It is important to note that the peaks presented by OptimizationT REE heuristic in Figure 7 are due to the use of the smallest items. In addition, the smallest item for each instance is fixed according to the smallest value of l i . During the execution of the algorithm, the demand for the items is met and then these items are no more considered for cutting. The remaining items are larger items since the algorithm removes a unit from the largest item in each iteration. Therefore, from a given bar, more leftovers and very few losses are generated, since the higher demand causes these last cutting patterns to be repeated more times, causing the visible peaks.
Another analysis can be done between the hypothetical cutting pattern that presents the minimum number of bars, the leftover and the loss resulting of this hypothetical pattern. The distance of these values and the results of heuristics are presented in the following equations. The GAP bar defined in Equation 8 presents the mean value of the distance (absolute error) between lower bound of bars (B barp ) and the heuristic result (H barp ), for each category. The "H" in the equation represents the chosen heuristic.
Similarly, the GAP lef t (Equation 9) and the GAP loss (Equation 10) show the main value of the distance (absolute error) between lower bound of leftovers (B lef tp ) and of loss (B lossp ), and the heuristic result of leftover (H lef tp ) and of loss (H lossp ), respectively, for each category.
Tables 7, 8, 9 and 10 show the values of the GAP obtained by Optimiza-tionDistBSP, OptimizationTREE, FFD and Greedy heuristics, respectively, considering the number of cutting bars, the leftover and the loss, for each category. The columns present the numeric value provided by Equations 8, 9 and 10, respectively, followed by its respective standard deviations.    Analyzing Tables 7, 8, 9 and 10, the OptimizationTREE heuristic presents the smallest GAP in relation to the number of losses (B bar ). The Optimiza-tionDistBSP heuristic presents, in average, the same gap than FFD and Greedy heuristics, but providing more leftovers. OptimizationTREE is closer to B bar and generates even bigger leftovers.
The computational complexity of the proposed algorithms are shown in Table 11, considering the worst case of the two heuristics proposed. The second column presents the number of sorts performed by each algorithm during its execution and the last column shows the complexity order of the algorithms, considering the worst case.  Table 9 shows that the OptimizationDistBSP algorithm presents, in the worst case, a quadratic order computational complexity (O(n 2 )). According to results, this heuristic uses the same number of cutting bars than FFD and Greedy heuristics (Figure 6), whose computational complexity is limited by the knapsack problem solver. The OptimizationT REE algorithm also presents quadratic order O(n 2 ), but providing more leftovers than the others to be reused, which is desirable, since OptimizationTREE aims to convert losses into leftovers, providing reuse. In addition, OptimizationDistBSP runs all categories using less time. The main runtime for all the 18 categories (in seconds) are: OptimizationDistBSP =0.0101, OptimizationTREE =0.0890, FFD = 0.01282 and Greedy = 0.1116. Then, for the case that considers unlimited quantity of one type of bar, OptimizationDistBSP and OptimizationT REE are more appropriated than FFD and Greedy heuristics.

Conclusion
In this paper, one-dimensional cutting stock problems are considered, which minimizes the number of cutting bars in cutting process, satisfying the demand, considering cutting rolls with known demand, and using the leftovers provided from previous rolls cutting process. In order to accomplish this goal, two heuristic procedures are proposed: OptimizationDistBSP and Optimiza-tionTREE heuristics. The performances of the proposed heuristics are compared with the FFD and Greedy algorithms, according to [6], which presents the same objective: to minimize the number of cut bars.
It is important to note that when the number of bars is minimized, less losses are produced. With a better positioning of items in bars, the losses are converted in leftovers. In this paper, a loss is an unused bar smaller than the size of the smallest item demanded. However, the loss can be defined by the producer, for example, as a fixed value or a minimum acceptable percentage.
Using the heuristics proposed in this paper, the leftovers from previous cutting process can be used in next item's demands. This fact, therefore, offers a possible use of leftovers, instead of their disposal. Therefore, the results of this paper contribute to the reduction of the raw materials use, to the environment preservation and to the reduction of waste production, providing commercially viable solutions.
Finally, the proposed heuristics were implemented in open source (Python language) and the codes are freely available in the GitHub package resource 1 . All the exemplars used in this work are available on both links.
As prospects for continuing this research, we work in inclusion of a 3 rd phase in algorithms, i.e. after defining the all cutting patterns, changing the items distribution to aim to convert losses in leftover. This new phase must be carefully designed since it can increase the processing time.

Data Availibility Statement
The data and the codes presented in this study are openly available in GitHub package resource: github.com/omatheuspimenta/heuristictree and github.com/omatheuspimenta/heuristiciohbsp.