Two-dimensional irregular part nesting and maximum dense packing method based on grid mask and BL-GA-LS collaborative optimization
By using a grid masking and BL-GA-LS co-optimization method, the problem of nesting irregular and perforated parts was solved, improving space utilization and computational efficiency, stabilizing the handling of complex geometries, and achieving maximum dense filling.
Patent Information
- Application Number
- CN202611713559.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-11-02
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies suffer from low space utilization, high computational complexity, and poor numerical stability in the process of nesting irregularly shaped parts and parts with holes. Errors are particularly prone to occur when processing concave polygons and porous areas.
A method combining raster masking and BL-GA-LS co-optimization is adopted to discretize the continuous coordinates of the sheet metal and parts into grid cells. Raster masks are used to represent available and occupied areas. The placement order and angle of parts are optimized by combining genetic algorithms and local search. Maximum dense filling is achieved through layout height and non-placement penalty function.
It improves the space utilization of irregularly shaped parts and parts with holes, simplifies collision detection, stably handles convex polygons, concave polygons and irregularly shaped plates, automatically determines the number that can be placed, and improves the efficiency and calculation speed of multi-generation optimization.
Smart Images

Figure CN123179496A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer-aided manufacturing, specifically to a method for layout of two-dimensional irregular parts and maximum dense filling of similar parts based on grid masking and BL-GA-LS co-optimization. Background Technology
[0002] In production scenarios such as laser cutting, sheet metal processing, garment cutting, wood cutting, and composite material cutting, it is often necessary to place multiple two-dimensional parts into a single sheet. The parts may be convex polygons, concave polygons, near-circular shapes, polygons with holes, or other irregular contours, while the sheet may be rectangular, have irregular boundaries, or be a usable area with holes. The layout results need to meet requirements such as parts not overlapping, parts being located inside the sheet, process gaps being maintained between parts, and boundary gaps being maintained between parts and the sheet, while maximizing material utilization.
[0003] In existing technologies, heuristic nesting based on bounding rectangles first approximates the outline of the parts using their bounding boxes, and then sorts them by height, width, or area and places them using methods such as bounding boxes (BL) and lowest horizontal lines. This method is simple to implement, but the bounding boxes cannot represent concave boundaries and holes, and the parts cannot fully interlock, resulting in low utilization of irregularly shaped parts. Nesting methods based on continuous geometric Boolean operations and collision-free polygons usually calculate No-Fit Polygons (NFP) or Minkowski sums to represent the set of infeasible positions of one part relative to another part, and then search for feasible placement points in continuous space. This method has high accuracy, but it has high requirements for concave polygons, holes, multi-part combinations, irregularly shaped plate boundaries, and numerical robustness. Boolean operations are complex, and the engineering implementation and debugging costs are high.
[0004] The shortcomings of existing technical solutions are: insufficient representation of irregularly shaped parts and parts with holes. Using only circumscribed rectangles or simple contour approximations will waste available space near grooves and holes; continuous geometry NFP methods are complex to implement; stable polygon Boolean operations are required for concave polygons and porous regions; numerical errors are prone to occur when the input contours are collinear, have short sides, or are approximately overlapping. Summary of the Invention
[0005] (a) Technical problems to be solved
[0006] To address the shortcomings of existing technologies, this invention provides a method for 2D irregular part layout and maximum dense filling of similar parts based on grid masking and BL-GA-LS collaborative optimization, thus solving the problem of insufficient representation of irregular parts and parts with holes mentioned in the background technology. Using only circumscribed rectangles or simple contour approximations wastes available space near grooves and holes; continuous geometry NFP methods are complex to implement; stable polygon Boolean operations are required for concave polygons and porous regions; and numerical errors are prone to occur when the input contours are collinear, have short sides, or are approximately overlapping.
[0007] (II) Technical Solution
[0008] To achieve the above objectives, the present invention is implemented through the following technical solution: a two-dimensional irregular part layout and maximum dense filling method for homogeneous parts based on grid mask and BL-GA-LS co-optimization, comprising, S1, receiving a set of plate polygons containing outer contours and holes, a set of part polygons, a set of rotation angles, a grid step size, part gaps and plate boundary gaps, discretizing the continuous coordinates of the plate and parts into grid cells, subtracting the coordinates of the lower left corner of the bounding box from the continuous coordinates and dividing by the grid step size to map to discrete cell indices, and using an integer bit array to form a row grid mask to represent the occupancy status of the plate, parts and placed parts;
[0009] S2, the plate is rasterized into polygons, and a mask of the usable area of the plate is generated with the four corner points inside the outer contour of the plate and the boundary not crossing it. The boundary unit is shrunken based on the plate boundary gap, and a part mask is generated by rotating and transforming each part at each candidate rotation angle.
[0010] S3. Enumerate candidate positions using the BL decoder with low-to-high and same-high left-to-right order. After shifting the part mask by two layers of whole word offset and word offset, perform inclusion determination with the available area mask of the board material and overlap exclusion determination with the already placed part occupied mask. If the determination passes, place the part and expand it with a circular expansion kernel to write to the already placed part occupied mask. If the determination fails, mark it as not placed and process the next part.
[0011] S4, construct candidate solutions based on part arrangement and rotation angle sequence and decode them into layout using the BL decoder. Use layout height plus non-placement penalty as objective function. Use genetic algorithm for global search and call local search for refinement. Reuse intermediate results through prefix snapshots and cache objective function values with arrangement order and angle as keys.
[0012] S5, for the same part, the maximum dense filling is constructed in the angular periodic cycle to construct the same part replica sequence and reuse the BL decoder to place them one by one. When the number of successful placements reaches the current number of attempts, the number of attempts is doubled and then placed again until the number of successful placements is less than half of the number of attempts. When a replica cannot be placed, the attempt is stopped and the set of placed parts is returned.
[0013] S6 restores the discrete grid coordinates to the original coordinate system through inverse rotation and translation transformations, and outputs the placed part number, rotation angle, translation amount, contour point sequence, and the number of placed parts in layout height or maximum fill mode.
[0014] Preferably, in step S1, the row grid mask unsigned integer is used as the basic storage unit. The coordinate index of the grid cell is obtained by subtracting the coordinate of the lower left corner of the bounding box from the continuous coordinates, dividing by the grid step size and rounding down. The coordinate index is divided by 64 to obtain the block index, modulo 64 to obtain the bit index, and the bit mask value is the power of the bit index. Each row of grid is composed of 64-bit unsigned integers arranged continuously in block index order. If the grid cell is occupied, the corresponding bit is set to one; otherwise, it is set to zero. The gap between parts and the gap between sheet metal boundaries are converted into the number of discrete cells by dividing by the grid step size and rounding up. When the gap value approaches zero, the corresponding number of cells is set to zero.
[0015] Preferably, the determination condition for generating the usable area mask of the board material in step S2 is as follows: for each grid cell, take four corner points, and determine that all four corner points are located inside the outer contour of the board material or on the boundary and are not located inside the holes. At the same time, the outer contour boundary of the board material does not pass through the rectangle of the grid cell. Grid cells that meet all the conditions are set as usable bits. The determination of points within the polygon is made by the ray method. The specific method based on the shrinkage of the board material boundary gap is as follows: for each originally usable grid cell, check the neighborhood with the number of discrete cells as the radius. If there are out-of-bounds cells or unusable cells in the neighborhood, they are deleted from the usable area mask of the board material.
[0016] Preferably, the determination condition for generating the part mask in step S2 is as follows: for each grid cell within the bounding box of the rotated part, if any one of the following three conditions is met: the cell center point is located inside the outer contour of the part and not inside the hole, or any side of the outer contour of the part intersects with the grid cell rectangle, or any side of the hole of the part intersects with the grid cell rectangle, then the corresponding bit is set to one; the part mask also records the first occupied cell at the bottom left as an anchor point. During collision detection, the feasibility of the position corresponding to the anchor point is checked first. If the anchor point has exceeded the boundary or is occupied, the complete mask scan is skipped; the part mask is cached and stored using a cache key composed of the part number, angle discrete key, and step size discrete key.
[0017] Preferably, the shifting operation in step S3 is implemented as follows: the discrete index of the candidate placement position is divided by 64 to obtain the integer offset, and modulo 64 is taken to obtain the intra-word offset. Each row of the part mask is first positioned to the target word by the integer offset and then shifted left by the intra-word offset. The overflow bit generated by the left shift is written to the next target word. The part row mask that is determined to be shifted and the available area row mask of the board material are equal to the shifted part row mask itself after performing a bitwise AND operation. The overlap exclusion is determined to be zero after performing a bitwise AND operation between the shifted part row mask and the row mask occupied by the placed part.
[0018] Preferably, the circular expansion core in step S3 is constructed as follows: a circular neighborhood offset set is generated with the number of discrete units corresponding to the gap between parts or the gap between the sheet metal boundaries as the radius, which includes all offset pairs that satisfy the condition that the sum of the squares of the horizontal and vertical offsets does not exceed the square of the radius; after each successful placement of a part, all offsets in the circular expansion core are traversed for each occupied unit in the part mask, and the coordinates of the occupied unit plus the offset are written into the occupied mask of the placed part. When placing subsequent parts, the gap constraint can be uniformly satisfied by the overlap exclusion judgment.
[0019] Preferably, the operators of the genetic algorithm in step S4 include: tournament selection, randomly selecting a preset number of individuals each time and choosing the one with the smallest objective function as the parent generation; sequential crossover, randomly selecting intervals in the parent generation arrangement and directly copying them to the offspring generation, then filling the remaining positions according to the order of another parent generation to maintain the legality of the arrangement; angle genes are randomly selected from the two parents generation for inheritance at each position; mutation includes randomly swapping the arrangement order of two positions with mutation probability and randomly replacing the angle of a certain position with mutation probability; the neighborhood operation of the local search includes swapping the positions of two parts and changing the angle of a certain part, and accepting it if the objective function of the neighborhood solution is smaller; the prefix snapshot records the occupancy mask and layout height after the current optimal solution places the first t parts, and when the solution to be evaluated is the same as the first q genes of the optimal solution, it directly continues decoding from the difference position; at the same time, the objective function of the complete solution is cached using the arrangement order and angle discrete key as the cache key.
[0020] Preferably, the angle cycle loop in step S5 is implemented as follows: with the length of the candidate angle set as the cycle, the corresponding angle is selected after taking the modulo of the length of the candidate angle set according to the sequence number, and the starting offset of the angle cycle is randomly selected; when the BL decoder cannot place a copy in the same shape maximum fill mode, it stops trying and returns the set of parts that have been successfully placed. The termination condition for the iteration is that twice the number of successfully placed parts is less than the current number of attempts. If twice the number of successfully placed parts is greater than or equal to the current number of attempts, the number of attempts is doubled and then decoded again.
[0021] (III) Beneficial Effects
[0022] This invention provides a method for layout of two-dimensional irregular parts and maximum dense filling of similar parts based on grid masking and BL-GA-LS co-optimization. It has the following beneficial effects:
[0023] 1. This invention uses an objective function of "penalty for large number of unplaced parts + layout height" to arrange different parts, which can prioritize ensuring that all parts are placed and then optimize space usage.
[0024] 2. This invention sets up dedicated probing and termination logic for the maximum dense filling of the same parts, enabling the algorithm to automatically determine the number that can be placed without pre-specifying the exact number of copies; it uses mask caching, objective function caching and prefix snapshot caching to reduce repeated rasterization and repeated decoding, thereby improving the efficiency of multi-generation optimization.
[0025] 3. This invention uses grid cells and 64-bit row masks to represent available and occupied areas, transforming collision detection into bitwise operations and improving the speed of candidate position detection.
[0026] 4. By replacing complex continuous geometric Boolean operations with grid masks, it can stably handle convex polygons, concave polygons, parts with holes, and irregularly shaped plates; collision detection is performed using 64-bit row masks, which improves the speed of multiple evaluations; by combining GA and LS, it can search for better order and angle in different part layouts; and by using a dedicated fill branch for homogeneous parts, it can automatically approximate the maximum number that can be placed in the plate when the maximum number is unknown. Attached Figure Description
[0027] To make the content of this invention easier to understand, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings, wherein:
[0028] Figure 1 This is the overall flowchart of the present invention;
[0029] Figure 2 This is a schematic diagram comparing the geometric shape and the grid pattern described in this invention;
[0030] Figure 3 This is a schematic diagram of the BL scanning placement described in this invention;
[0031] Figure 4 This is a schematic diagram of the different parts arrangement described in this invention;
[0032] Figure 5 This is a schematic diagram of the arrangement of the same parts described in this invention in an irregularly shaped sheet metal. Detailed Implementation
[0033] The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0034] Example 1
[0035] according to Figure 1 The overall flowchart of the present invention provides a method for layout of two-dimensional irregular parts and maximum dense filling of similar parts based on grid masking and BL-GA-LS co-optimization, including:
[0036] 1. System Input and Data Structure
[0037] The system accepts the following input data: a set of part polygons, a set of sheet metal polygons, a set of candidate rotation angles, a mesh step size, part gaps, and boundary gaps; specifically, the sheet metal region is defined as a set of polygons.
[0038]
[0039] in This is a sequence of points along the outer contour of the sheet metal. This is a collection of unusable holes within the board material. Let the first... The components are:
[0040]
[0041] in For the outer contour of the part, This represents the set of holes in the part. The set of candidate rotation angles is:
[0042]
[0043] Let the grid step size be The gap between the parts is The gap between the part and the sheet metal is After performing parameter discretization preprocessing, the conversion formula from continuous intervals to discrete unit numbers is as follows:
[0044]
[0045]
[0046] in It is a very small positive number, used to reduce the impact of floating-point errors. When the gap is less than the near-zero threshold, the corresponding number of cells is taken as... .
[0047] any point The cell index in grid coordinates can be represented as:
[0048]
[0049] in This refers to the bottom left corner coordinates of the corresponding sheet metal or part enclosure. Each grid row uses several... Bit-integer storage, the first The block and bit of each unit are:
[0050]
[0051]
[0052]
[0053] Therefore, the two-dimensional Boolean matrix is compressed into a row-ordered bit array; if a cell is occupied, the corresponding bit is... Otherwise .
[0054] 2. The material can be generated using a region mask.
[0055] After discretizing the input parameters, the system first rasterizes the material according to the logic of the "Generate Mask" node in the overall flowchart to generate a mask of the usable area of the material. The goal of the material mask is to obtain the "area where the part is allowed to fall". This embodiment adopts a conservative judgment: a grid cell is considered usable only when all four corner points are located inside the outer contour or boundary of the material and not inside holes, and the boundary of the material does not pass through the cell.
[0056] Set unit The four corner points are:
[0057]
[0058]
[0059] If the following conditions are met:
[0060]
[0061]
[0062] Then, the unit is set as a usable position in the board material. The determination of a point within a polygon can be done using the ray method; the determination of a point within a polygon with holes is: the point must be within the outer contour and not within any hole. Using four-corner point determination can avoid misclassifying units that extend beyond the board material boundary as usable areas.
[0063] When setting boundary gap When, discretize it into Each unit. For each originally usable sheet metal unit, check its... Neighborhood. If there are out-of-bounds or unusable cells within the neighborhood, it means that the cell is close to the board boundary or hole boundary and should be removed from the available mask of the board. This transforms the constraint of "keeping the part away from the boundary" into reducing the available area of the board.
[0064] 3. Part mask generation and rotation buffer
[0065] Once the sheet metal mask is ready, the system continues with the part mask generation process in the "Generate Mask" node, processing the part... and candidate angles First, perform a rotation transformation on all contour points of the part:
[0066]
[0067] Calculate the bounding box after rotation:
[0068]
[0069]
[0070] The dimensions of the component mask are:
[0071]
[0072]
[0073] The determination of a unit's occupancy is based on the principle that "a unit is occupied as long as it intersects with a part." For units... If any of the following conditions are met, the corresponding bit will be set to 1:
[0074] 1. The center point of the unit is located inside the outer contour of the part and not inside the hole of the part;
[0075] 2. Any side of the part's outer contour intersects with the unit rectangle;
[0076] 3. Any side of the hole in the part intersects with the unit rectangle.
[0077] This judgment is more conservative than simple center point sampling, which can reduce the problem of missing slender boundaries or hole boundaries. The part mask also records the first occupied cell as the anchor point. The first occupied cell is the first cell that intersects with the part after the part is gridded. During collision detection, the feasibility of the anchor point is checked first. If the anchor point has exceeded the boundary or is occupied, there is no need to scan the entire mask.
[0078] To avoid redundant calculations, this embodiment uses a cache key consisting of "part number, angle discretization key, and mesh step size discretization key":
[0079]
[0080] When the same part is used again at the same angle and step size, the cache mask is returned directly.
[0081] 4. Feasibility assessment and gap expansion
[0082] After both the board mask and the component mask are ready, the system establishes a complete feasibility determination mechanism. This mechanism is the core of each candidate position evaluation in the BL decoder and a key guarantee for the correctness of the entire nesting method. From a timing perspective, feasibility determination is called in each candidate position enumeration of the BL decoder; gap expansion is executed immediately after each component is successfully placed to update the occupied area.
[0083] Let the current part mask be The candidate reference cell position is .Will After translating to the plate coordinate system, the following conditions must be met simultaneously:
[0084]
[0085]
[0086] in For the usable area mask of the board material, This is the occupancy mask for already placed parts. In bitwise form, it can be written as:
[0087]
[0088]
[0089] in This represents the occupancy mask for a specific row of the current part. This represents the mask of the available area for the corresponding row of the board material. This indicates the occupancy mask for parts that have been placed in the corresponding row. This indicates the offset within the block. The first formula means that the translated part row mask must fall completely within the available area of the board material; the second formula means that the translated part row mask must not overlap with the already occupied area.
[0090] in express Bit offset within a bit word Indicates the candidate placement position at Discrete cell index of direction. Because the row mask is based on... Bit-word block storage, when no When the value is an integer multiple, it needs to be split into whole character offset and intra-character position offset:
[0091]
[0092]
[0093] in This indicates the number of complete 64-bit words that are crossed to the right. This indicates the number of bits to shift left within the target 64-bit word. The current line mask is first... Locate the target word, then press Shift left; if the left shift produces an overflow bit, write the overflow bit to the next target word.
[0094] Part clearance This is achieved through occupancy inflation. Let... To determine the number of interstitial elements, construct a circular expansion core:
[0095]
[0096] When submitting a placed part, each occupied cell of that part traversing the expanding core offset in and will Write occupied mask Therefore, as long as subsequent parts do not overlap with the expanded parts... Intersection ensures the minimum part gap in a discrete sense.
[0097] 5. BL Decoding
[0098] BL decoding is used to decode a given part order and angle sequence into an actual nesting pattern. Let the input order be:
[0099]
[0100] The angle sequence is:
[0101]
[0102] For the One part to be placed To obtain its angle The component mask below Then, starting from the bottom left corner of the board, candidate positions are scanned. The scanning order ensures that lower positions are prioritized; within the same height, positions further to the left are prioritized, hence the name BL strategy. If none of the candidate positions meet the feasibility criteria, the part is marked as not placed, and the system continues processing the next part in the sequence. After successful placement, the continuous translation amount of the part is:
[0103]
[0104]
[0105] This allows us to obtain the final positions of the part's outer contour and holes in world coordinates. Let... For the first If the precise height of each part is known at the current angle, then the current layout height will be updated as follows:
[0106]
[0107] In the final output, you can also directly iterate through the vertices of the outer contour of the placed part and take all of them. The maximum value of the coordinates is used as the layout height.
[0108] 6. Space-saving layout between different parts
[0109] When the system task is to arrange different parts in the most space-efficient manner, the system enters the execution phase of the "Optimization Search" node in the overall flowchart. The BL decoder is embedded in the evaluation process of the Genetic Algorithm (GA) to search for the optimal combination of part placement order and rotation angle. For different sets of parts, "part order and angle of each part" is considered as a candidate solution. The candidate solution can be represented as:
[0110]
[0111] in It's the arrangement of part numbers. It is the angular sequence corresponding to the arrangement position. This represents a complete candidate solution. The number of units placed is obtained after calling the BL decoder. and layout height Let the total number of parts be... The number of items not placed is:
[0112]
[0113] The objective function is defined as:
[0114]
[0115] in A sufficiently large penalty coefficient; This represents the number of parts that were not placed. This represents the current layout height. The objective function first ensures that as many parts as possible are placed; only when the number of missing parts is the same, does it compare layout heights.
[0116] 6.1 Initial Population Generation
[0117] Individuals in the genetic algorithm population are This embodiment uses two initialization methods:
[0118] 1. Heuristic approach: Sort parts by their outer contour area from largest to smallest, placing larger parts first; select the angle that minimizes the contour area after rotation. Candidate angles with smaller values.
[0119] 2. Random Individual: Randomly shuffle the order of the parts and randomly select the angle for each position from the set of candidate angles.
[0120] Another type of heuristic individual involves perturbation, where neighboring individuals are exchanged with a certain probability based on a descending area order, in order to increase initial diversity.
[0121] The area of the part is calculated using the shoelace formula. For the sequence of outer contour points... The area of the outer contour is:
[0122]
[0123] If we calculate the area containing the holes, then:
[0124]
[0125] 6.2 Selection, Crossover, and Mutation
[0126] The genetic algorithm uses tournament selection. Random selection is performed each time. For each individual, the one with the smallest objective function is selected as the parent.
[0127] Sequential crossing is used to maintain the legality of the part arrangement. The steps are as follows:
[0128] 1. Randomly select an interval from the permutations of parent generation A. This interval is directly copied to the same position in the child generation.
[0129] 2. Scan the unused part numbers in the order of parent generation B, and fill the remaining empty slots of the child generation in sequence.
[0130] The offspring generated in this way are still arrangements of parts without repetition or omission.
[0131] Angular genes are inherited randomly positionally: the offspring's first... Each angle is randomly selected from the corresponding position of parent A or parent B. Mutations include:
[0132] 1. Sequential exchange mutation: based on probability Randomly select two positions and swap the order of the parts.
[0133] 2. Angle variation: based on probability Randomly select a location and replace its angle with another angle from the candidate angle set.
[0134] 6.3LS and prefix snapshot acceleration
[0135] Every preset number of generations, GA performs LS on the current best individual. LS attempts a preset number of neighborhood operations, including swapping the positions of two parts, changing the angle of a part, etc. If the objective function of the new solution is smaller, the new solution is accepted.
[0136] Adjacent candidate solutions typically only change in the latter half; to avoid re-decoding from the first part each time, this invention records a prefix snapshot of the current optimal solution. The prefix snapshot includes:
[0137]
[0138] in Before placement Occupancy mask after each component To correspond to the layout height, Solution to be evaluated. This is the current optimal solution; when the two are in front of each other... When all genes are identical, directly take the first one. Starting from the first snapshot, from the... Each component continues BL decoding.
[0139] If the first distinct position is:
[0140]
[0141] The evaluation of the new solution can then be written as:
[0142]
[0143] This method significantly reduces the redundant computation of similar solutions in LS.
[0144] Furthermore, this invention also caches the objective function of the complete solution. The cache key consists of the arrangement order and the angle discrete key:
[0145]
[0146]
[0147] If the same solution appears again, return the historical objective function directly.
[0148] 7. Maximum dense filling of the same part in sheet metal of different shapes
[0149] For the maximum fill problem involving identical parts, the input can provide only one target part. Candidate Angle Set and boards The goal of this problem is not to minimize the height of a given set of parts, but to maximize the number of parts that can be placed within a fixed sheet metal.
[0150]
[0151]
[0152]
[0153]
[0154]
[0155] This invention employs an automatic expansion and probing method. Let the current number of attempts be... First construct One copy of the same part:
[0156]
[0157] The order is fixed as follows:
[0158]
[0159] The angle sequence cycles according to the candidate angle period:
[0160]
[0161] in This is the starting offset for the angle cycle, which can be randomly selected to ensure differences in the starting point of the angle cycle across different runs. When the candidate angle set is empty, all angles are used. .
[0162] Then, the same BL decoder is invoked to place identical parts one by one. In the maximum fill mode for identical parts, if a copy cannot be placed, the decoder does not consider it a complete failure, but stops trying and returns the set of parts that have been successfully placed. Let the number of successfully placed parts be... .like:
[0163]
[0164] This indicates that the current number of attempts is still too small or close to the upper limit of the placeable capacity, so we continue to set:
[0165]
[0166] And decode again. If:
[0167]
[0168] This indicates that the number of attempts has significantly exceeded the capacity of the board, so the algorithm terminates and outputs the currently decoded set of placed items.
[0169] The advantage of the homogeneous filling branch is that the user does not need to know the maximum number that can be placed in advance; the BL decoder, board mask, part mask and gap expansion logic are reused with different part nesting to ensure that the geometric constraints of the two types of tasks are consistent.
[0170] 8. Result Restoration and Output
[0171] When the algorithm internally rotates or translates the material to handle its orientation, the final result needs to be inversely transformed back to the input coordinate system. Let the inverse rotation angle from the internal coordinates to the original coordinates be . Translation Then point Restored to:
[0172]
[0173] The output includes: the number of each placed part, the rotation angle of each part, the translation amount of each part, the sequence of outer contour points after placement, the sequence of hole points after placement, the total layout height, or the number of placed parts in the maximum fill mode.
[0174] Example 2:
[0175] This embodiment is based on Embodiment 1, and there are alternative implementation methods:
[0176] Grid step size It can be adaptively set according to processing accuracy, kerf width, and calculation time requirements; smaller... Improved geometric accuracy, but increased mask size and computational load; larger Increase speed, but reduce nesting accuracy.
[0177] The candidate angle set can be It can also incorporate any angle allowed by the process, for example Alternatively, candidate angles can be automatically generated based on the direction of the longest side of the part.
[0178] The BL scanning order can be replaced with the lowest height priority, edge priority, hole adjacency priority, or multi-candidate point scoring strategy, as long as the same feasibility determination and occupation submission mechanism are still used.
[0179] GA can replace or combine optimizers such as simulated annealing, tabu search, and ant colony optimization; the decoder and objective function of this invention can still be reused as an evaluation module.
[0180] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is limited by the appended claims and their equivalents.
Claims
1. A method for layout of two-dimensional irregular parts and maximum dense filling of similar parts based on grid masking and BL-GA-LS co-optimization, characterized in that, include: S1 receives a set of polygons of the plate and part, including the outer contour and holes, as well as a set of rotation angles, grid step size, part gap and plate boundary gap. The continuous coordinates of the plate and part are discretized into grid cells. The continuous coordinates are subtracted from the coordinates of the lower left corner of the bounding box and divided by the grid step size to map the discrete cell index. The row grid mask is formed by an integer bit array to represent the occupancy status of the plate, part and placed part. S2, the plate is rasterized into polygons, and a mask of the usable area of the plate is generated with the four corner points inside the outer contour of the plate and the boundary not crossing it. The boundary unit is shrunken based on the plate boundary gap, and a part mask is generated by rotating and transforming each part at each candidate rotation angle. S3. Enumerate candidate positions using the BL decoder with low-to-high and same-high left-to-right order. After shifting the part mask by two layers of whole word offset and word offset, perform inclusion determination with the available area mask of the board material and overlap exclusion determination with the already placed part occupied mask. If the determination passes, place the part and expand it with a circular expansion kernel to write to the already placed part occupied mask. If the determination fails, mark it as not placed and process the next part. S4, construct candidate solutions based on part arrangement and rotation angle sequence and decode them into layout using the BL decoder. Use layout height plus non-placement penalty as objective function. Use genetic algorithm for global search and call local search for refinement. Reuse intermediate results through prefix snapshots and cache objective function values with arrangement order and angle as keys. S5, for the same part, the maximum dense filling is constructed in the angular periodic cycle to construct the same part replica sequence and reuse the BL decoder to place them one by one. When the number of successful placements reaches the current number of attempts, the number of attempts is doubled and then placed again until the number of successful placements is less than half of the number of attempts. When a replica cannot be placed, the attempt is stopped and the set of placed parts is returned. S6 restores the discrete grid coordinates to the original coordinate system through inverse rotation and translation transformations, and outputs the placed part number, rotation angle, translation amount, contour point sequence, and the number of placed parts in layout height or maximum fill mode.
2. The method for layout of two-dimensional irregular parts and maximum dense filling of similar parts based on grid masking and BL-GA-LS co-optimization as described in claim 1, characterized in that: In step S1, the row grid mask unsigned integer is the basic storage unit. The coordinate index of the grid cell is obtained by subtracting the coordinate of the lower left corner of the bounding box from the continuous coordinates, dividing by the grid step size and rounding down. The coordinate index is divided by 64 to get the block index, modulo 64 to get the bit index, and the bit mask value is the power of the bit index. Each row of grid is composed of 64-bit unsigned integers arranged continuously in block index order. If the grid cell is occupied, the corresponding bit is set to one; otherwise, it is set to zero. The gap between parts and the gap between sheet metal boundaries are converted into the number of discrete cells by dividing by the grid step size and rounding up. When the gap value approaches zero, the corresponding number of cells is set to zero.
3. The method for two-dimensional irregular part layout and maximum dense filling of similar parts based on grid mask and BL-GA-LS co-optimization as described in claim 2, characterized in that: In step S2, the criteria for generating the usable area mask of the board material are as follows: for each grid cell, take four corner points, and determine that all four corner points are located inside the outer contour of the board material or on the boundary and are not located inside the holes. At the same time, the outer contour boundary of the board material does not pass through the rectangle of the grid cell. Grid cells that meet all the conditions are set as usable bits. The determination of points within the polygon is done using the ray method. The specific method based on the shrinkage of the board material boundary gap is as follows: for each originally usable grid cell, check the neighborhood with the number of discrete cells as the radius. If there are out-of-bounds cells or unusable cells in the neighborhood, they are deleted from the usable area mask of the board material.
4. The method for two-dimensional irregular part layout and maximum dense filling of similar parts based on grid mask and BL-GA-LS co-optimization as described in claim 3, characterized in that: In step S2, the conditions for generating the part mask are as follows: for each grid cell within the bounding box of the rotated part, if any one of the following three conditions is met: the cell center point is located inside the outer contour of the part and not inside the hole, or any side of the outer contour of the part intersects with the grid cell rectangle, or any side of the hole of the part intersects with the grid cell rectangle, then the corresponding bit is set to one; the part mask also records the first occupied cell at the bottom left as an anchor point. During collision detection, the feasibility of the position corresponding to the anchor point is checked first. If the anchor point has exceeded the boundary or is occupied, the complete mask scan is skipped; the part mask is cached and stored using a cache key composed of the part number, angle discrete key, and step size discrete key.
5. The method for two-dimensional irregular part layout and maximum dense filling of similar parts based on grid mask and BL-GA-LS co-optimization as described in claim 4, characterized in that: The shift operation in step S3 is implemented as follows: the discrete index of the candidate placement position is divided by 64 to obtain the integer offset, and modulo 64 is taken to obtain the intra-word offset. Each row of the part mask is first positioned to the target word by the integer offset and then shifted to the left by the intra-word offset. The overflow bit generated by the left shift is written to the next target word. The part row mask that is determined to be shifted and the available area row mask of the board are equal to the shifted part row mask itself after performing a bitwise AND operation. The overlap exclusion is determined to be zero after performing a bitwise AND operation between the shifted part row mask and the row mask occupied by the placed part.
6. The method for two-dimensional irregular part layout and maximum dense filling of similar parts based on grid mask and BL-GA-LS co-optimization as described in claim 5, characterized in that: In step S3, the circular expansion core is constructed as follows: a circular neighborhood offset set is generated with the number of discrete units corresponding to the gap between parts or the gap between the sheet metal boundaries as the radius. This set contains all offset pairs that satisfy the condition that the sum of the squares of the horizontal and vertical offsets does not exceed the square of the radius. After each successful placement of a part, all offsets in the circular expansion core are traversed for each occupied unit in the part mask. The coordinates of the occupied unit are added to the offset and written into the occupied mask of the placed part. When placing subsequent parts, the gap constraint can be uniformly satisfied by the overlap exclusion judgment.
7. The method for two-dimensional irregular part layout and maximum dense filling of similar parts based on grid mask and BL-GA-LS co-optimization as described in claim 6, characterized in that: The genetic algorithm operators in step S4 include: tournament selection, randomly selecting a preset number of individuals each time and choosing the one with the smallest objective function as the parent; sequential crossover, randomly selecting intervals in the parent arrangement and directly copying them to the offspring, then filling the remaining positions according to the order of another parent to maintain the legality of the arrangement; angle genes are randomly selected from the two parents for inheritance position by position; mutation includes randomly swapping the arrangement order of two positions with mutation probability and randomly replacing the angle of a certain position with mutation probability; the neighborhood operation of the local search includes swapping the positions of two parts and changing the angle of a certain part, and accepting it if the objective function of the neighborhood solution is smaller; the prefix snapshot records the occupancy mask and layout height after the current optimal solution has placed the first t parts, and when the solution to be evaluated is the same as the first q genes of the optimal solution, it directly continues decoding from the difference position; at the same time, the objective function of the complete solution is cached with the arrangement order and angle discrete key as the cache key.
8. The method for two-dimensional irregular part layout and maximum dense filling of similar parts based on grid mask and BL-GA-LS co-optimization as described in claim 7, characterized in that: The implementation of the angle cycle loop in step S5 is as follows: with the length of the candidate angle set as the cycle, the corresponding angle is selected after taking the modulo of the length of the candidate angle set according to the sequence number, and the starting offset of the angle cycle is randomly selected; when the BL decoder cannot place a copy in the same shape maximum fill mode, it stops trying and returns the set of parts that have been successfully placed. The termination condition for the iteration is that twice the number of successfully placed parts is less than the current number of attempts. If twice the number of successfully placed parts is greater than or equal to the current number of attempts, the number of attempts is doubled and then decoded again.
