Files
CutList/CutList.Core/Nesting/EngineFactory.cs
AJ Isaacs b19ecf3610 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>
2026-02-01 15:16:40 -05:00

21 lines
751 B
C#

namespace CutList.Core.Nesting
{
/// <summary>
/// Default implementation of IEngineFactory that creates packing engines
/// based on the specified strategy.
/// </summary>
public class EngineFactory : IEngineFactory
{
public IEngine CreateEngine(PackingStrategy strategy = PackingStrategy.AdvancedFit)
{
return strategy switch
{
PackingStrategy.AdvancedFit => new AdvancedFitEngine(),
PackingStrategy.BestFit => new BestFitEngine(),
PackingStrategy.Exhaustive => new ExhaustiveFitEngine(),
_ => throw new ArgumentOutOfRangeException(nameof(strategy), strategy, "Unknown packing strategy")
};
}
}
}