refactor: Redesign nesting engines with pipeline pattern and add exhaustive search

- Rename Result to PackResult to avoid confusion with Result<T>
- Add PackingRequest as immutable configuration replacing mutable engine state
- Add PackingStrategy enum (AdvancedFit, BestFit, Exhaustive)
- Implement pipeline pattern for composable packing steps
- Rewrite AdvancedFitEngine as stateless using pipeline
- Rewrite BestFitEngine as stateless
- Add ExhaustiveFitEngine with symmetry breaking for optimal solutions
  - Tries all bin assignments to find minimum bins
  - Falls back to AdvancedFit for >20 items
  - Configurable threshold via constructor
- Update IEngine/IEngineFactory interfaces for new pattern
- Add strategy parameter to MCP tools

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-01 15:16:40 -05:00
parent 6e8469be4b
commit b19ecf3610
22 changed files with 898 additions and 351 deletions

View File

@@ -18,7 +18,7 @@ namespace CutList.Services
/// <param name="stockBins">The available stock bins</param>
/// <param name="cuttingTool">The cutting tool to use (determines kerf/spacing)</param>
/// <returns>Result containing the packing result with optimized bins and unused items, or error message</returns>
public Result<CutList.Core.Nesting.Result> Pack(List<PartInputItem> parts, List<BinInputItem> stockBins, Tool cuttingTool)
public Result<PackResult> Pack(List<PartInputItem> parts, List<BinInputItem> stockBins, Tool cuttingTool)
{
try
{
@@ -30,11 +30,11 @@ namespace CutList.Services
engine.Spacing = cuttingTool.Kerf;
var packResult = engine.Pack(binItems);
return Result<CutList.Core.Nesting.Result>.Success(packResult);
return Result<PackResult>.Success(packResult);
}
catch (Exception ex)
{
return Result<CutList.Core.Nesting.Result>.Failure($"Packing failed: {ex.Message}");
return Result<PackResult>.Failure($"Packing failed: {ex.Message}");
}
}