- 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>
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using CutList.Core.Nesting.Pipeline;
|
|
|
|
namespace CutList.Core.Nesting
|
|
{
|
|
/// <summary>
|
|
/// Advanced bin packing engine using First-Fit Decreasing with optimization.
|
|
/// This is a stateless engine that uses a composable pipeline of steps.
|
|
/// </summary>
|
|
public class AdvancedFitEngine : IEngine
|
|
{
|
|
private readonly PackingPipeline _pipeline;
|
|
|
|
public AdvancedFitEngine()
|
|
{
|
|
_pipeline = new PackingPipeline()
|
|
.AddStep(new FilterOversizedItemsStep())
|
|
.AddStep(new SortItemsDescendingStep())
|
|
.AddStep(new FirstFitDecreasingStep())
|
|
.AddStep(new OptimizationStep())
|
|
.AddStep(new SortBinItemsStep())
|
|
.AddStep(new DuplicateBinsStep())
|
|
.AddStep(new SortBinsByUtilizationStep());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Packs items into bins using the FFD algorithm with optimization passes.
|
|
/// </summary>
|
|
public PackResult Pack(PackingRequest request)
|
|
{
|
|
return _pipeline.Execute(request);
|
|
}
|
|
}
|
|
}
|