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:
31
CutList.Core/Nesting/PackingStrategy.cs
Normal file
31
CutList.Core/Nesting/PackingStrategy.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace CutList.Core.Nesting
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the bin packing strategy/algorithm to use.
|
||||
/// </summary>
|
||||
public enum PackingStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// First-Fit Decreasing with optimization passes.
|
||||
/// Sorts items by length descending, then packs using first-fit.
|
||||
/// Includes optimization to improve packing by swapping items.
|
||||
/// Best for general-purpose use cases.
|
||||
/// </summary>
|
||||
AdvancedFit,
|
||||
|
||||
/// <summary>
|
||||
/// Best-Fit Decreasing algorithm.
|
||||
/// Sorts items by length descending, then places each item in the bin
|
||||
/// with the least remaining space that can still fit it.
|
||||
/// Simpler but can be effective for certain distributions.
|
||||
/// </summary>
|
||||
BestFit,
|
||||
|
||||
/// <summary>
|
||||
/// Exhaustive search that tries all possible combinations.
|
||||
/// Guarantees optimal solution but has exponential time complexity.
|
||||
/// Automatically falls back to AdvancedFit for more than 15 items.
|
||||
/// </summary>
|
||||
Exhaustive
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user