How the SVGNest nesting algorithm works
masterSVGNest uses an orbital approach combined with a Genetic Algorithm (GA) for global optimization. The process is split into two main strategies:
1. Placement Strategy (No Fit Polygon)
To place parts without intersection, the algorithm uses the No Fit Polygon (NFP) concept.
- NFP: Created by "orbiting" part B around part A such that they touch but do not intersect. The NFP contains all valid placement positions for B relative to A.
- Inner Fit Polygon (IFP): Similar to NFP, but used to ensure the part stays within the boundaries of the bin.
- Union of NFPs: When multiple parts are already placed, the algorithm takes the union of their NFPs to find valid empty spaces.
2. Optimization Strategy (Genetic Algorithm)
To find the best insertion order and rotations, a Genetic Algorithm is used.
- Genes: The gene represents the insertion order of parts and their respective rotations.
- Heuristic: The algorithm uses a "first-fit-decreasing" heuristic (placing larger parts first) as a starting point.
- Fitness Function: The GA evaluates "fitness" based on:
- Minimizing unplaceable parts.
- Minimizing the number of bins used.
- Minimizing the width of all placed parts (to avoid long slivers of unused material).