Changeset 9596
- Timestamp:
- 06/07/13 01:20:12 (12 years ago)
- Location:
- branches/HeuristicLab.BinPacking
- Files:
-
- 3 added
- 11 deleted
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.BinPacking.sln
r9348 r9596 1 1 2 Microsoft Visual Studio Solution File, Format Version 1 1.003 # Visual Studio 201 02 Microsoft Visual Studio Solution File, Format Version 12.00 3 # Visual Studio 2012 4 4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.BinPacking-3.3", "HeuristicLab.Problems.BinPacking\3.3\HeuristicLab.Problems.BinPacking-3.3.csproj", "{F8A55094-3CD5-4034-B0CA-5BD7FFB016D4}" 5 5 EndProject … … 7 7 ProjectSection(SolutionItems) = preProject 8 8 ..\Build.cmd = ..\Build.cmd 9 Performance1.psess = Performance1.psess 9 10 ..\PreBuildEvent.cmd = ..\PreBuildEvent.cmd 10 11 EndProjectSection … … 60 61 HideSolutionNode = FALSE 61 62 EndGlobalSection 63 GlobalSection(Performance) = preSolution 64 HasPerformanceSessions = true 65 EndGlobalSection 62 66 EndGlobal -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Plugin.cs
r9593 r9596 26 26 /// Plugin class for HeuristicLab.Problems.BinPacking.Views plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.9 495")]28 [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.9593")] 29 29 [PluginFile("HeuristicLab.Problems.BinPacking.Views-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Common", "3.3")] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Properties/AssemblyInfo.cs
r9593 r9596 54 54 // by using the '*' as shown below: 55 55 [assembly: AssemblyVersion("3.3.0.0")] 56 [assembly: AssemblyFileVersion("3.3.7.9 495")]56 [assembly: AssemblyFileVersion("3.3.7.9593")] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftGroupingVectorDecoder.cs
r9593 r9596 41 41 [Item("Identical bin two dimensional grouping vector decoder", "<Description missing...>")] 42 42 [StorableClass] 43 public class BottomLeftGroupingVectorDecoder : PackingSolutionDecoder< 44 TwoDimensionalPacking, 45 RectangularPackingBin, 46 RectangularPackingItem>, I2DGVDecoder { 47 48 public BottomLeftGroupingVectorDecoder() 49 : base() { 50 //EncodedSolutionParameter.ActualName = "EncodedSolution"; 51 } 43 public class BottomLeftGroupingVectorDecoder : PackingSolutionDecoder<TwoDimensionalPacking, RectangularPackingBin,RectangularPackingItem>, I2DGVDecoder { 44 public BottomLeftGroupingVectorDecoder() : base() {} 52 45 [StorableConstructor] 53 46 protected BottomLeftGroupingVectorDecoder(bool deserializing) : base(deserializing) { } … … 59 52 } 60 53 61 62 54 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 63 64 55 var solution = encodedSolution as GroupingVectorEncoding; 65 56 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); 66 67 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 69 70 result.BinPackings = TwoDimensionalPackingFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); //BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); 57 PackingPlan2D result = new PackingPlan2D(binMeasures); 58 result.Pack(solution, itemMeasures); 71 59 return result; 72 60 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftMultiComponentVectorDecoder.cs
r9593 r9596 41 41 [Item("Identical bin two dimensional multi component vector decoder", "<Description missing...>")] 42 42 [StorableClass] 43 public class BottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder< 44 TwoDimensionalPacking, 45 RectangularPackingBin, 46 RectangularPackingItem>, I2DMCVDecoder { 47 48 public BottomLeftMultiComponentVectorDecoder() 49 : base() { 50 //EncodedSolutionParameter.ActualName = "EncodedSolution"; 51 } 43 public class BottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder<TwoDimensionalPacking,RectangularPackingBin, RectangularPackingItem>, I2DMCVDecoder { 44 public BottomLeftMultiComponentVectorDecoder() : base() {} 52 45 [StorableConstructor] 53 46 protected BottomLeftMultiComponentVectorDecoder(bool deserializing) : base(deserializing) { } … … 59 52 } 60 53 61 62 54 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 63 64 55 var solution = encodedSolution as MultiComponentVectorEncoding; 65 56 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponent Vector"); 66 67 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 69 70 result.BinPackings = TwoDimensionalPackingFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); //BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); 71 57 PackingPlan2D result = new PackingPlan2D(binMeasures); 58 result.Pack(solution, itemMeasures); 72 59 return result; 73 60 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftPackingSequenceDecoder.cs
r9593 r9596 40 40 [Item("Identical bin, two dimensional, direct permutation decoder", "<Description missing...>")] 41 41 [StorableClass] 42 public class BottomLeftPackingSequenceDecoder : PackingSolutionDecoder< 43 TwoDimensionalPacking, 44 RectangularPackingBin, 45 RectangularPackingItem>, I2DPSDecoder { 42 public class BottomLeftPackingSequenceDecoder : PackingSolutionDecoder<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>, I2DPSDecoder { 46 43 47 public BottomLeftPackingSequenceDecoder() 48 : base() { 49 //EncodedSolutionParameter.ActualName = "EncodedSolution"; 50 } 44 public BottomLeftPackingSequenceDecoder(): base() { } 51 45 [StorableConstructor] 52 46 protected BottomLeftPackingSequenceDecoder(bool deserializing) : base(deserializing) { } … … 58 52 } 59 53 60 61 54 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 62 63 55 var solution = encodedSolution as PackingSequenceEncoding; 64 56 if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence"); 65 66 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 67 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 68 69 result.BinPackings = TwoDimensionalPackingFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); //BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); 70 57 PackingPlan2D result = new PackingPlan2D(binMeasures); 58 result.Pack(solution, itemMeasures); 71 59 return result; 72 60 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointGroupingVectorDecoder2D.cs
r9593 r9596 41 41 [Item("Identical bin, two dimensional, extreme points based decoder for the GroupingVector encoding.", "<Description missing...>")] 42 42 [StorableClass] 43 public class ExtremePointGroupingVectorDecoder2D : PackingSolutionDecoder< 44 TwoDimensionalPacking, 45 RectangularPackingBin, 46 RectangularPackingItem>, I2DGVDecoder { 47 48 public ExtremePointGroupingVectorDecoder2D () 49 : base() { 50 } 43 public class ExtremePointGroupingVectorDecoder2D : PackingSolutionDecoder<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>, I2DGVDecoder { 44 public ExtremePointGroupingVectorDecoder2D () : base() {} 51 45 [StorableConstructor] 52 46 protected ExtremePointGroupingVectorDecoder2D (bool deserializing) : base(deserializing) { } … … 59 53 60 54 public static PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> Decode(GroupingVectorEncoding solution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 61 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 62 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 63 64 result.BinPackings = TwoDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);//ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures); 65 55 PackingPlan2D result = new PackingPlan2D(binMeasures, true, false); 56 result.Pack(solution, itemMeasures); 66 57 return result; 67 58 } 68 59 69 60 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 70 71 61 var solution = encodedSolution as GroupingVectorEncoding; 72 62 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); 73 74 63 return Decode(solution, binMeasures, itemMeasures); 75 64 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointMultiComponentVectorDecoder2D.cs
r9593 r9596 42 42 [Item("Identical bin, two dimensional, extreme points based decoder for the MultiComponentVector encoding.", "<Description missing...>")] 43 43 [StorableClass] 44 public class ExtremePointMultiComponentVectorDecoder2D : PackingSolutionDecoder< 45 TwoDimensionalPacking, 46 RectangularPackingBin, 47 RectangularPackingItem>, I2DMCVDecoder { 48 49 public ExtremePointMultiComponentVectorDecoder2D () 50 : base() { 51 } 44 public class ExtremePointMultiComponentVectorDecoder2D : PackingSolutionDecoder<TwoDimensionalPacking,RectangularPackingBin, RectangularPackingItem>, I2DMCVDecoder { 45 public ExtremePointMultiComponentVectorDecoder2D () : base() {} 52 46 [StorableConstructor] 53 47 protected ExtremePointMultiComponentVectorDecoder2D (bool deserializing) : base(deserializing) { } … … 60 54 61 55 public static PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> Decode(MultiComponentVectorEncoding solution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 62 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 63 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 64 65 result.BinPackings = TwoDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);//ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures); 66 56 PackingPlan2D result = new PackingPlan2D(binMeasures, true, false); 57 result.Pack(solution, itemMeasures); 67 58 return result; 68 59 } 69 60 70 61 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 71 72 62 var solution = encodedSolution as MultiComponentVectorEncoding; 73 63 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector"); 74 75 64 return Decode(solution, binMeasures, itemMeasures); 76 65 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointPackingSequenceDecoder2D.cs
r9593 r9596 40 40 [Item("Identical bin, two dimensional, extreme points based decoder for the PackingSequence encoding.", "<Description missing...>")] 41 41 [StorableClass] 42 public class ExtremePointPackingSequenceDecoder2D : PackingSolutionDecoder< 43 TwoDimensionalPacking, 44 RectangularPackingBin, 45 RectangularPackingItem>, I2DPSDecoder { 46 47 public ExtremePointPackingSequenceDecoder2D () 48 : base() { 49 } 42 public class ExtremePointPackingSequenceDecoder2D : PackingSolutionDecoder<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>, I2DPSDecoder { 43 public ExtremePointPackingSequenceDecoder2D () : base() {} 50 44 [StorableConstructor] 51 45 protected ExtremePointPackingSequenceDecoder2D (bool deserializing) : base(deserializing) { } … … 59 53 60 54 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 61 62 55 var solution = encodedSolution as PackingSequenceEncoding; 63 56 if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence"); 64 65 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 66 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 67 68 result.BinPackings = TwoDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);//ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures); 69 57 PackingPlan2D result = new PackingPlan2D(binMeasures, true, false); 58 result.Pack(solution, itemMeasures); 70 59 return result; 71 60 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftGroupingVectorDecoder.cs
r9593 r9596 38 38 39 39 namespace HeuristicLab.Problems.BinPacking.Decoders { 40 [Item("Identical bin three dimensional direct grouping vectordecoder", "<Description missing...>")]40 [Item("Identical bin, three dimensional, GroupingVector-decoder", "<Description missing...>")] 41 41 [StorableClass] 42 public class DeepestBottomLeftGroupingVectorDecoder : PackingSolutionDecoder< 43 ThreeDimensionalPacking, 44 CuboidPackingBin, 45 CuboidPackingItem>, I3DGVDecoder { 46 47 public DeepestBottomLeftGroupingVectorDecoder() 48 : base() { 49 //EncodedSolutionParameter.ActualName = "EncodedSolution"; 50 } 42 public class DeepestBottomLeftGroupingVectorDecoder : PackingSolutionDecoder<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DGVDecoder { 43 public DeepestBottomLeftGroupingVectorDecoder() : base() {} 51 44 [StorableConstructor] 52 45 protected DeepestBottomLeftGroupingVectorDecoder(bool deserializing) : base(deserializing) { } … … 58 51 } 59 52 60 61 53 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 62 63 54 var solution = encodedSolution as GroupingVectorEncoding; 64 55 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); 65 66 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 67 68 result.BinPackings = ThreeDimensionalPackingFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures); 69 56 PackingPlan3D result = new PackingPlan3D(binMeasures); 57 result.Pack(solution, itemMeasures); 70 58 return result; 71 59 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftMultiComponentVectorDecoder.cs
r9593 r9596 39 39 40 40 namespace HeuristicLab.Problems.BinPacking.Decoders { 41 [Item("Identical bin three dimensional multi component vectordecoder", "<Description missing...>")]41 [Item("Identical bin, three dimensional, MultiComponentVector-decoder", "<Description missing...>")] 42 42 [StorableClass] 43 public class DeepestBottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder< 44 ThreeDimensionalPacking, 45 CuboidPackingBin, 46 CuboidPackingItem>, I3DMCVDecoder { 47 48 public DeepestBottomLeftMultiComponentVectorDecoder() 49 : base() { 50 //EncodedSolutionParameter.ActualName = "EncodedSolution"; 51 } 43 public class DeepestBottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DMCVDecoder { 44 public DeepestBottomLeftMultiComponentVectorDecoder() : base() { } 52 45 [StorableConstructor] 53 46 protected DeepestBottomLeftMultiComponentVectorDecoder(bool deserializing) : base(deserializing) { } … … 59 52 } 60 53 61 62 54 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 63 64 55 var solution = encodedSolution as MultiComponentVectorEncoding; 65 56 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponent Vector"); 66 67 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 68 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 69 70 result.BinPackings = ThreeDimensionalPackingFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures); 71 57 PackingPlan3D result = new PackingPlan3D(binMeasures); 58 result.Pack(solution, itemMeasures); 72 59 return result; 73 60 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftPackingSequenceDecoder.cs
r9593 r9596 38 38 39 39 namespace HeuristicLab.Problems.BinPacking.Decoders { 40 [Item("Identical bin, three dimensional, direct permutationdecoder", "<Description missing...>")]40 [Item("Identical bin, three dimensional, PackingSequence-decoder", "<Description missing...>")] 41 41 [StorableClass] 42 public class DeepestBottomLeftPackingSequenceDecoder : PackingSolutionDecoder< 43 ThreeDimensionalPacking, 44 CuboidPackingBin, 45 CuboidPackingItem>, I3DPSDecoder { 46 47 public DeepestBottomLeftPackingSequenceDecoder() 48 : base() { 49 //EncodedSolutionParameter.ActualName = "EncodedSolution"; 50 } 42 public class DeepestBottomLeftPackingSequenceDecoder : PackingSolutionDecoder<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DPSDecoder { 43 public DeepestBottomLeftPackingSequenceDecoder(): base() {} 51 44 [StorableConstructor] 52 45 protected DeepestBottomLeftPackingSequenceDecoder(bool deserializing) : base(deserializing) { } … … 58 51 } 59 52 60 61 53 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 62 63 54 var solution = encodedSolution as PackingSequenceEncoding; 64 55 if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence"); 65 66 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 67 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 68 69 result.BinPackings = ThreeDimensionalPackingFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures); 70 56 PackingPlan3D result = new PackingPlan3D(binMeasures); 57 result.Pack(solution, itemMeasures); 71 58 return result; 72 59 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointGroupingVectorDecoder3D.cs
r9593 r9596 42 42 [Item("Identical bin, three dimensional, extreme points based decoder for the GroupingVector encoding.", "<Description missing...>")] 43 43 [StorableClass] 44 public class ExtremePointGroupingVectorDecoder3D : PackingSolutionDecoder< 45 ThreeDimensionalPacking, 46 CuboidPackingBin, 47 CuboidPackingItem>, I3DGVDecoder { 48 49 public ValueParameter<BoolValue> StackingConstraintsParameter { 50 get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; } 51 } 52 53 public ExtremePointGroupingVectorDecoder3D () 54 : base() { 55 Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not.")); 56 } 44 public class ExtremePointGroupingVectorDecoder3D : PackingSolutionDecoder< ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DGVDecoder { 45 public ExtremePointGroupingVectorDecoder3D () : base() { } 57 46 [StorableConstructor] 58 47 protected ExtremePointGroupingVectorDecoder3D (bool deserializing) : base(deserializing) { } … … 65 54 66 55 public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(GroupingVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures, bool stackingConstraints) { 67 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 68 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 69 70 result.BinPackings = ThreeDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures, stackingConstraints); 71 56 PackingPlan3D result = new PackingPlan3D(binMeasures, true, stackingConstraints); 57 result.Pack(solution, itemMeasures); 72 58 return result; 73 59 } 74 60 75 61 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 76 77 62 var solution = encodedSolution as GroupingVectorEncoding; 78 63 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); 79 80 64 return Decode(solution, binMeasures, itemMeasures, StackingConstraintsParameter.Value.Value); 81 65 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointMultiComponentVectorDecoder3D.cs
r9593 r9596 43 43 [Item("Identical bin, three dimensional, extreme points based decoder for the MultiComponentVector encoding.", "<Description missing...>")] 44 44 [StorableClass] 45 public class ExtremePointMultiComponentVectorDecoder3D : PackingSolutionDecoder< 46 ThreeDimensionalPacking, 47 CuboidPackingBin, 48 CuboidPackingItem>, I3DMCVDecoder { 49 50 public ValueParameter<BoolValue> StackingConstraintsParameter { 51 get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; } 52 } 53 54 public ExtremePointMultiComponentVectorDecoder3D () 55 : base() { 56 Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not.")); 57 } 45 public class ExtremePointMultiComponentVectorDecoder3D : PackingSolutionDecoder<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DMCVDecoder { 46 public ExtremePointMultiComponentVectorDecoder3D () : base() { } 58 47 [StorableConstructor] 59 48 protected ExtremePointMultiComponentVectorDecoder3D (bool deserializing) : base(deserializing) { } … … 66 55 67 56 public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures, bool stackingConstraints) { 68 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 69 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 70 71 result.BinPackings = ThreeDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures, stackingConstraints); 72 57 PackingPlan3D result = new PackingPlan3D(binMeasures, true, stackingConstraints); 58 result.Pack(solution, itemMeasures); 73 59 return result; 74 60 } 75 61 76 62 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 77 78 63 var solution = encodedSolution as MultiComponentVectorEncoding; 79 64 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector"); 80 81 65 return Decode(solution, binMeasures, itemMeasures, StackingConstraintsParameter.Value.Value); 82 66 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointPackingSequenceDecoder3D.cs
r9593 r9596 41 41 [Item("Identical bin, three dimensional, extreme points based decoder for the PackingSequence encoding.", "<Description missing...>")] 42 42 [StorableClass] 43 public class ExtremePointPackingSequenceDecoder3D : PackingSolutionDecoder< 44 ThreeDimensionalPacking, 45 CuboidPackingBin, 46 CuboidPackingItem>, I3DPSDecoder { 47 48 public ValueParameter<BoolValue> StackingConstraintsParameter { 49 get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; } 50 } 51 52 public ExtremePointPackingSequenceDecoder3D () 53 : base() { 54 Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not.")); 55 } 43 public class ExtremePointPackingSequenceDecoder3D : PackingSolutionDecoder<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DPSDecoder { 44 public ExtremePointPackingSequenceDecoder3D () : base() {} 56 45 [StorableConstructor] 57 46 protected ExtremePointPackingSequenceDecoder3D (bool deserializing) : base(deserializing) { } … … 65 54 66 55 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 67 68 56 var solution = encodedSolution as PackingSequenceEncoding; 69 57 if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence"); 70 71 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 72 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 73 74 result.BinPackings = ThreeDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures, StackingConstraintsParameter.Value.Value); 75 58 PackingPlan3D result = new PackingPlan3D(binMeasures, true, StackingConstraintsParameter.Value.Value); 59 result.Pack(solution, itemMeasures); 76 60 return result; 77 61 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ISOContainerMultiComponentVectorDecoder3D.cs
r9593 r9596 60 60 61 61 public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 62 63 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 64 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(); 65 /* 66 #region Preperations 67 int nrOfBins = solution.NrOfBins; 68 69 Dictionary<int, List<PackingInformation>> unpackedItemIndexesPerBin = new Dictionary<int, List<PackingInformation>>(); 70 Dictionary<int, HashSet<ThreeDimensionalPacking>> extremePointsForBin = new Dictionary<int, HashSet<ThreeDimensionalPacking>>(); 71 ObservableDictionary<int, CuboidPackingBin> resultingBinMeasures = new ObservableDictionary<int, CuboidPackingBin>(); 72 var occupiedPoints = new List<int[, ,]>(); 62 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> resultPlan = new PackingPlan3D(binMeasures); 63 ObservableList<BinPacking3D> result = new ObservableList<BinPacking3D>(); 73 64 74 for (int i = 0; i < nrOfBins; i++) {75 unpackedItemIndexesPerBin[i] = new List<PackingInformation>(solution.PackingInformations[i]);65 var sequenceMatrix = solution.GenerateSequenceMatrix(); 66 Dictionary<int, bool> rotated = solution.GenerateRotationArray(); 76 67 77 extremePointsForBin[i] = new HashSet<ThreeDimensionalPacking>(); 78 extremePointsForBin[i].Add(new ThreeDimensionalPacking(i, 0, 0, 0, false)); 79 occupiedPoints = ExtremePointsFunctions3D.IncreaseBinCountForOccupiedPoints(occupiedPoints, binMeasures); 80 resultingBinMeasures[i] = new CuboidPackingBin(binMeasures.Width, binMeasures.Height, binMeasures.Depth); 68 //Fill bins according to grouping vector 69 List<int> remainingIDs = new List<int>(); 70 foreach (var sequence in sequenceMatrix) { 71 remainingIDs = remainingIDs.Concat(sequence).ToList(); 72 var bp = new BinPacking3D(binMeasures); 73 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, true, rotated); 74 if (remainingIDs.Count > 0) { 75 bp.DoubleDepth(); 76 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, true, rotated); 77 } 78 result.Add(bp); 81 79 } 80 result.RemoveAll(x => x.ItemPositions.Count == 0); 81 result = new ObservableList<BinPacking3D>(result.OrderByDescending(bp => bp.PackingDensity)); 82 82 83 ObservableDictionary<int, ThreeDimensionalPacking> itemPositions = new ObservableDictionary<int, ThreeDimensionalPacking>(); 84 var remainingItems = new List<PackingInformation>(); 85 86 #endregion Preperations 87 88 89 //Iterate over all bin-lists 90 for (int binNr = 0; binNr < nrOfBins; binNr++) { 91 //Iterate over the current bin-item-list and find feasible positions in the current bin for each item 92 var unpackedItems = unpackedItemIndexesPerBin[binNr]; 93 for (int i = 0; i < unpackedItems.Count; i++) { 94 var itemIndex = unpackedItems[i].ItemID; 95 var item = itemMeasures[itemIndex]; 96 97 extremePointsForBin[binNr] = ExtremePointsFunctions3D.OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, resultingBinMeasures[binNr]); 98 var positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 99 100 if (positionFound == null && resultingBinMeasures[binNr].Depth.Equals(binMeasures.Depth)) { 101 occupiedPoints = DoubleDepthForBinNr(occupiedPoints, ref resultingBinMeasures, binNr); 102 positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 103 } 104 105 if (positionFound != null) { 106 extremePointsForBin[binNr].Remove(positionFound); 107 itemPositions[itemIndex] = positionFound; 108 occupiedPoints = ExtremePointsFunctions3D.OccupyPointsForNewItem(occupiedPoints, item, positionFound, itemIndex); 109 extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, resultingBinMeasures[binNr]); 110 } else { 111 remainingItems.Add(unpackedItems[i]); 112 solution.PackingInformations[binNr].Remove(unpackedItems[i]); 83 //Try to put remaining items in existing bins 84 var temp = new List<int>(remainingIDs); 85 foreach (int id in temp) { 86 foreach (var bp in result) { 87 var position = bp.FindExtremePointForItem(itemMeasures[id], rotated[id], true); 88 if (remainingIDs.Count > 0) { 89 bp.DoubleDepth(); 90 position = bp.FindExtremePointForItem(itemMeasures[id], rotated[id], true); 91 } 92 if (position != null) { 93 bp.PackItem(id, itemMeasures[id], position); 94 remainingIDs.Remove(id); 113 95 } 114 96 } 115 97 } 116 98 117 118 //Packing of remaining items 119 //Iterate over all bin-lists 120 for (int binNr = 0; binNr < nrOfBins && remainingItems.Count > 0; binNr++) { 121 var unpackedItems = new List<PackingInformation>(remainingItems); 122 //Iterate over all the remaining items 123 for (int i = 0; i < unpackedItems.Count; i++) { 124 var itemIndex = unpackedItems[i].ItemID; 125 var item = itemMeasures[itemIndex]; 126 127 extremePointsForBin[binNr] = ExtremePointsFunctions3D.OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, resultingBinMeasures[binNr]); 128 var positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 129 130 131 if (positionFound == null && resultingBinMeasures[binNr].Depth.Equals(binMeasures.Depth)) { 132 occupiedPoints = DoubleDepthForBinNr(occupiedPoints, ref resultingBinMeasures, binNr); 133 positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 134 } 135 136 if (positionFound != null) { 137 extremePointsForBin[binNr].Remove(positionFound); 138 itemPositions[itemIndex] = positionFound; 139 occupiedPoints = ExtremePointsFunctions3D.OccupyPointsForNewItem(occupiedPoints, item, positionFound, itemIndex); 140 extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, resultingBinMeasures[binNr]); 141 remainingItems.Remove(unpackedItems[i]); 142 solution.PackingInformations[binNr].Add(unpackedItems[i]); 143 } 99 //Put still remaining items in new bins 100 while (remainingIDs.Count > 0) { 101 var bp = new BinPacking3D(binMeasures); 102 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, true, rotated); 103 if (remainingIDs.Count > 0) { 104 bp.DoubleDepth(); 105 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, true, rotated); 144 106 } 145 if (remainingItems.Count > 0 && binNr + 1 >= nrOfBins) { 146 extremePointsForBin[nrOfBins] = new HashSet<ThreeDimensionalPacking>(); 147 extremePointsForBin[nrOfBins].Add(new ThreeDimensionalPacking(nrOfBins, 0, 0, 0, false)); 148 occupiedPoints = ExtremePointsFunctions3D.IncreaseBinCountForOccupiedPoints(occupiedPoints, binMeasures); 149 resultingBinMeasures[nrOfBins] = new CuboidPackingBin(binMeasures.Width, binMeasures.Height, binMeasures.Depth); 150 solution.PackingInformations[nrOfBins] = new ItemList<PackingInformation>(); 151 nrOfBins++; 152 } 107 result.Add(bp); 153 108 } 154 155 result.BinPackings = BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>.GetBinPackings(itemPositions, resultingBinMeasures, itemMeasures, nrOfBins); */ 156 return result; 157 } 158 159 private static List<int[, ,]> DoubleDepthForBinNr(List<int[, ,]> occupiedPoints, ref ObservableDictionary<int, CuboidPackingBin> binMeasures, int binNr) { 160 var oldDepth = binMeasures[binNr].Depth; 161 binMeasures[binNr].Depth = binMeasures[binNr].Depth * 2; 162 var newBinOccupation = new int[binMeasures[binNr].Width, binMeasures[binNr].Height, binMeasures[binNr].Depth]; 163 for (int w = 0; w < binMeasures[binNr].Width; w++) { 164 for (int h = 0; h < binMeasures[binNr].Height; h++) { 165 for (int d = 0; d < binMeasures[binNr].Depth; d++) { 166 if (d < oldDepth) 167 newBinOccupation[w, h, d] = occupiedPoints[binNr][w, h, d]; 168 else 169 newBinOccupation[w, h, d] = -1; 170 } 171 } 172 } 173 174 occupiedPoints[binNr] = newBinOccupation; 175 return occupiedPoints; 109 result.RemoveAll(x => x.ItemPositions.Count == 0); 110 resultPlan.BinPackings = new ObservableList<BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>>(result.OrderByDescending(bp => bp.PackingDensity)); 111 return resultPlan; 176 112 } 177 113 178 114 179 180 181 115 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 182 183 116 var solution = encodedSolution as MultiComponentVectorEncoding; 184 117 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector"); 185 186 118 return Decode(solution, binMeasures, itemMeasures); 187 119 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/PackingSolutionDecoder.cs
r9563 r9596 59 59 get { return (ILookupParameter<PackingPlan<D, B, I>>)Parameters["PackingPlan"]; } 60 60 } 61 public ValueParameter<BoolValue> StackingConstraintsParameter { 62 get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; } 63 } 61 64 62 65 … … 67 70 Parameters.Add(new LookupParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data taken from the bin-packing problem-instance.")); 68 71 Parameters.Add(new LookupParameter<B>("PackingBinMeasures", "Packing-bin data taken from the bin-packing problem-instance.")); 72 Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not.")); 69 73 } 70 74 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/OccupiedPoints.cs
r9593 r9596 33 33 [Item("Occupated Points", "A datastructure holding all currently occupied points of a packing-bin.")] 34 34 [StorableClass] 35 public abstract class OccupiedPoints<D, I> : Item35 public abstract class OccupiedPoints<D, B, I> : Item 36 36 where D : class, IPackingDimensions 37 where B : PackingShape<D>, IPackingBin 37 38 where I : PackingShape<D>, IPackingItem { 38 39 39 public OccupiedPoints( ) : base() { }40 public OccupiedPoints(B binMeasures) : base() { } 40 41 [StorableConstructor] 41 42 protected OccupiedPoints(bool deserializing) : base(deserializing) { } 42 protected OccupiedPoints(OccupiedPoints<D, I> original, Cloner cloner)43 protected OccupiedPoints(OccupiedPoints<D,B,I> original, Cloner cloner) 43 44 : base(original, cloner) { 44 45 } … … 51 52 public abstract bool IsStaticStable(I item, D ep); 52 53 public abstract bool WeightIsSupported(I item, D ep, ItemList<I> items); 53 54 public abstract void ChangeBinMeasures(B binMeasures); 54 55 } 55 56 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/OccupiedPoints2D.cs
r9593 r9596 35 35 [Item("Occupated Points 2D", "A datastructure holding all currently occupied points of a 2D packing-bin.")] 36 36 [StorableClass] 37 public class OccupiedPoints2D : OccupiedPoints<TwoDimensionalPacking, RectangularPacking Item> {37 public class OccupiedPoints2D : OccupiedPoints<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> { 38 38 39 39 [Storable] 40 40 private int[,] occupiedPoints { get; set; } 41 41 42 public OccupiedPoints2D(RectangularPackingBin binMeasures) : base( ) {42 public OccupiedPoints2D(RectangularPackingBin binMeasures) : base(binMeasures) { 43 43 occupiedPoints = new int[binMeasures.Width, binMeasures.Height]; 44 44 for (int w = 0; w < binMeasures.Width; w++) { … … 67 67 return true; 68 68 } 69 70 69 public override void OccupyPoints(RectangularPackingItem measures, TwoDimensionalPacking position, int itemID) { 71 70 int width = position.Rotated ? measures.Height : measures.Width; … … 77 76 } 78 77 } 79 80 78 public override bool IsPointOccupied(TwoDimensionalPacking point) { 81 79 return occupiedPoints[point.X, point.Y] != -1; 82 80 } 83 84 81 public override int ShortestPossibleSideFromEP(TwoDimensionalPacking ep) { 85 82 int shortestSide = int.MaxValue; … … 102 99 return shortestSide; 103 100 } 104 105 101 public override bool IsStaticStable(RectangularPackingItem item, TwoDimensionalPacking ep) { 106 102 //For the current implementation there was no need for stacking-constraints in the 2D-case. 107 103 //But it could be interesting for shelf-packing applications! 108 return true;104 throw new NotImplementedException(); 109 105 } 110 106 public override bool WeightIsSupported(RectangularPackingItem item, TwoDimensionalPacking ep, ItemList<RectangularPackingItem> items) { 111 107 return true; 112 108 } 109 public override void ChangeBinMeasures(RectangularPackingBin binMeasures) { 110 throw new NotImplementedException(); 111 } 113 112 } 114 113 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/OccupiedPoints3D.cs
r9593 r9596 35 35 [Item("Occupied Points 3D", "A datastructure holding all currently occupied points of a 3D packing-bin.")] 36 36 [StorableClass] 37 public class OccupiedPoints3D : OccupiedPoints<ThreeDimensionalPacking, CuboidPacking Item> {37 public class OccupiedPoints3D : OccupiedPoints<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> { 38 38 39 39 [Storable] 40 40 private int[, ,] occupiedPoints { get; set; } 41 41 42 public OccupiedPoints3D(CuboidPackingBin binMeasures) {42 public OccupiedPoints3D(CuboidPackingBin binMeasures) : base(binMeasures) { 43 43 occupiedPoints = new int[binMeasures.Width, binMeasures.Height, binMeasures.Depth]; 44 44 for (int w = 0; w < binMeasures.Width; w++) { … … 71 71 return true; 72 72 } 73 74 73 public override void OccupyPoints(CuboidPackingItem measures, ThreeDimensionalPacking position, int itemID) { 75 74 int width = position.Rotated ? measures.Depth : measures.Width; … … 83 82 } 84 83 } 85 86 84 public override bool IsPointOccupied(ThreeDimensionalPacking point) { 87 85 return occupiedPoints[point.X, point.Y, point.Z] != -1; 88 86 } 89 90 87 public override int ShortestPossibleSideFromEP(ThreeDimensionalPacking ep) { 91 88 int shortestSide = int.MaxValue; … … 114 111 return shortestSide; 115 112 } 116 117 118 113 public override bool IsStaticStable(CuboidPackingItem item, ThreeDimensionalPacking ep) { 119 114 //Static stability is given, if item is placed on the ground … … 164 159 return false; 165 160 } 166 161 public override void ChangeBinMeasures(CuboidPackingBin binMeasures) { 162 int oldDepth = occupiedPoints.GetLength(2); 163 var newBinOccupation = new int[binMeasures.Width, binMeasures.Height, binMeasures.Depth]; 164 for (int w = 0; w < binMeasures.Width; w++) { 165 for (int h = 0; h < binMeasures.Height; h++) { 166 for (int d = 0; d < binMeasures.Depth; d++) { 167 if (d < oldDepth) 168 newBinOccupation[w, h, d] = occupiedPoints[w, h, d]; 169 else 170 newBinOccupation[w, h, d] = -1; 171 } 172 } 173 } 174 occupiedPoints = newBinOccupation; 175 } 167 176 } 168 177 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/ThreeDimensionalPacking.cs
r9440 r9596 81 81 return base.GetHashCode() + 13 * X + 17 * Y + 23 * Z; 82 82 } 83 84 public static ThreeDimensionalPacking MoveLeft(ThreeDimensionalPacking original) { 85 return new ThreeDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Z, original.Rotated); 86 } 87 public static ThreeDimensionalPacking MoveDown(ThreeDimensionalPacking original) { 88 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Z, original.Rotated); 89 } 90 public static ThreeDimensionalPacking MoveBack(ThreeDimensionalPacking original) { 91 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y, original.Z - 1, original.Rotated); 92 } 93 94 public static ThreeDimensionalPacking MoveRight(ThreeDimensionalPacking original) { 95 return new ThreeDimensionalPacking(original.AssignedBin, original.X + 1, original.Y, original.Z, original.Rotated); 96 } 97 public static ThreeDimensionalPacking MoveUp(ThreeDimensionalPacking original) { 98 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y + 1, original.Z, original.Rotated); 99 } 100 public static ThreeDimensionalPacking MoveFront(ThreeDimensionalPacking original) { 101 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y, original.Z + 1, original.Rotated); 102 } 83 103 } 84 104 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/TwoDimensionalPacking.cs
r9440 r9596 77 77 return base.GetHashCode() + 13 * X + 17 * Y; 78 78 } 79 80 public static TwoDimensionalPacking MoveLeft(TwoDimensionalPacking original) { 81 return new TwoDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Rotated); 82 } 83 public static TwoDimensionalPacking MoveDown(TwoDimensionalPacking original) { 84 return new TwoDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Rotated); 85 } 86 87 public static TwoDimensionalPacking MoveRight(TwoDimensionalPacking original) { 88 return new TwoDimensionalPacking(original.AssignedBin, original.X + 1, original.Y, original.Rotated); 89 } 90 public static TwoDimensionalPacking MoveUp(TwoDimensionalPacking original) { 91 return new TwoDimensionalPacking(original.AssignedBin, original.X, original.Y + 1, original.Rotated); 92 } 93 79 94 } 80 95 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/GroupingVectorEncoding.cs
r9348 r9596 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using System.Linq; 22 24 using System.Text; 23 25 using HeuristicLab.Common; … … 50 52 GroupingVector = new IntegerVector(); 51 53 } 54 55 public List<List<int>> GenerateSequenceMatrix() { 56 List<List<int>> result = new List<List<int>>(); 57 int nrOfBins = GroupingVector.Max() + 1; 58 for (int i = 0; i < nrOfBins; i++) 59 result.Add(new List<int>()); 60 for (int i = 0; i < GroupingVector.Length; i++) { 61 result[GroupingVector[i]].Add(i); 62 } 63 return result; 64 } 65 66 52 67 53 68 public override string ToString() { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/BinBasedMultiComponentVectorCrossover.cs
r9563 r9596 33 33 public class BinBasedMultiComponentVectorCrossover : MultiComponentVectorCrossover { 34 34 [StorableConstructor] 35 protected BinBasedMultiComponentVectorCrossover 36 protected BinBasedMultiComponentVectorCrossover (BinBasedMultiComponentVectorCrossoveroriginal, Cloner cloner) : base(original, cloner) { }37 public BinBasedMultiComponentVectorCrossover 35 protected BinBasedMultiComponentVectorCrossover(bool deserializing) : base(deserializing) { } 36 protected BinBasedMultiComponentVectorCrossover(BinBasedMultiComponentVectorCrossover original, Cloner cloner) : base(original, cloner) { } 37 public BinBasedMultiComponentVectorCrossover() 38 38 : base() { 39 39 } 40 40 public override IDeepCloneable Clone(Cloner cloner) { 41 return new BinBasedMultiComponentVectorCrossover 41 return new BinBasedMultiComponentVectorCrossover(this, cloner); 42 42 } 43 43 44 44 public override MultiComponentVectorEncoding Cross(IRandom random, MultiComponentVectorEncoding parent1, MultiComponentVectorEncoding parent2) { 45 MultiComponentVectorEncoding child = new MultiComponentVectorEncoding(); 45 MultiComponentVectorEncoding child = new MultiComponentVectorEncoding (); 46 46 47 int nrOfItems = parent1.NrOfItems; 47 48 bool[] itemAlreadyAssigned = new bool[nrOfItems]; 48 49 bool useParent2 = false;50 49 int nrOfBins = parent1.NrOfBins > parent2.NrOfBins ? parent2.NrOfBins : parent1.NrOfBins; 51 50 51 //Add one bin from parent1 52 int swappedBinNr = random.Next(nrOfBins); 53 var swappedBin = new ItemList<PackingInformation>(); 54 for (int i = 0; i < parent1.PackingInformations[swappedBinNr].Count; i++) { 55 PackingInformation pi = new PackingInformation(parent1.PackingInformations[swappedBinNr][i]); 56 if (!itemAlreadyAssigned[pi.ItemID]) { 57 itemAlreadyAssigned[pi.ItemID] = true; 58 swappedBin.Add(new PackingInformation(pi)); 59 } 60 } 61 child.PackingInformations[swappedBinNr] = swappedBin; 52 62 63 //Get the remaining bins from parent2 53 64 for (int binNr = 0; binNr < nrOfBins; binNr++) { 54 MultiComponentVectorEncoding currentParent1 = useParent2 ? parent2 : parent1; 55 MultiComponentVectorEncoding currentParent2 = useParent2 ? parent1 : parent2; 56 57 58 var newBin = new ItemList<PackingInformation>(); 59 double crossPointPercent = 0; 60 61 int nrOfItems1 = currentParent1.PackingInformations[binNr].Count; 62 if (nrOfItems1 > 0) { 63 double crossPoint1 = random.Next(nrOfItems1); 64 crossPointPercent = crossPoint1 / nrOfItems1; 65 for (int i = 0; i < crossPoint1; i++) { 66 PackingInformation pi = new PackingInformation(currentParent1.PackingInformations[binNr][i]); 65 if (binNr != swappedBinNr) { 66 var newBin = new ItemList<PackingInformation>(); 67 var currentParent = parent2; 68 int nrOfItemsInBin = currentParent.PackingInformations[binNr].Count; 69 for (int i = 0; i < nrOfItemsInBin; i++) { 70 PackingInformation pi = new PackingInformation(currentParent.PackingInformations[binNr][i]); 67 71 if (!itemAlreadyAssigned[pi.ItemID]) { 68 72 itemAlreadyAssigned[pi.ItemID] = true; … … 70 74 } 71 75 } 76 child.PackingInformations[binNr] = newBin; 72 77 } 73 74 int nrOfItems2 = currentParent2.PackingInformations[binNr].Count;75 if (nrOfItems2 > 0) {76 int crossPoint2 = Convert.ToInt32(nrOfItems2 * crossPointPercent);77 for (int i = crossPoint2; i < nrOfItems2; i++) {78 PackingInformation pi = new PackingInformation(currentParent2.PackingInformations[binNr][i]);79 if (!itemAlreadyAssigned[pi.ItemID]) {80 itemAlreadyAssigned[pi.ItemID] = true;81 newBin.Add(new PackingInformation(pi));82 }83 }84 }85 86 child.PackingInformations[binNr] = newBin;87 useParent2 = !useParent2;88 78 } 89 79 80 //Pack still remaining items in bin#0 90 81 for (int itemID = 0; itemID < nrOfItems; itemID++) { 91 82 if (!itemAlreadyAssigned[itemID]) … … 93 84 } 94 85 95 86 96 87 return child; 97 88 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/MultiComponentVectorEncoding.cs
r9563 r9596 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Text; 24 25 using HeuristicLab.Collections; … … 64 65 : base() { 65 66 PackingInformations = new ObservableDictionary<int, ItemList<PackingInformation>>(); 66 } 67 } 68 69 public List<List<int>> GenerateSequenceMatrix() { 70 List<List<int>> result = new List<List<int>>(); 71 foreach (var bi in PackingInformations) { 72 var temp = new List<int>(); 73 foreach (var piEntry in bi.Value) { 74 temp.Add(piEntry.ItemID); 75 } 76 result.Add(temp); 77 } 78 return result; 79 } 80 public Dictionary<int, bool> GenerateRotationArray() { 81 Dictionary<int, bool> result = new Dictionary<int, bool>(); 82 foreach (var bi in PackingInformations) 83 foreach (var pi in bi.Value) 84 result[pi.ItemID] = pi.Rotated; 85 return result; 86 } 87 88 67 89 68 90 public override string ToString() { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/SequenceBasedMultiComponentVectorCrossover.cs
r9593 r9596 33 33 public class SequenceBasedMultiComponentVectorCrossover : MultiComponentVectorCrossover { 34 34 [StorableConstructor] 35 protected SequenceBasedMultiComponentVectorCrossover (bool deserializing) : base(deserializing) { }36 protected SequenceBasedMultiComponentVectorCrossover (SequenceBasedMultiComponentVectorCrossoveroriginal, Cloner cloner) : base(original, cloner) { }37 public SequenceBasedMultiComponentVectorCrossover ()35 protected SequenceBasedMultiComponentVectorCrossover (bool deserializing) : base(deserializing) { } 36 protected SequenceBasedMultiComponentVectorCrossover (SequenceBasedMultiComponentVectorCrossover original, Cloner cloner) : base(original, cloner) { } 37 public SequenceBasedMultiComponentVectorCrossover () 38 38 : base() { 39 39 } 40 40 public override IDeepCloneable Clone(Cloner cloner) { 41 return new SequenceBasedMultiComponentVectorCrossover (this, cloner);41 return new SequenceBasedMultiComponentVectorCrossover (this, cloner); 42 42 } 43 43 44 44 public override MultiComponentVectorEncoding Cross(IRandom random, MultiComponentVectorEncoding parent1, MultiComponentVectorEncoding parent2) { 45 MultiComponentVectorEncoding child = new MultiComponentVectorEncoding (); 46 45 MultiComponentVectorEncoding child = new MultiComponentVectorEncoding(); 47 46 int nrOfItems = parent1.NrOfItems; 48 47 bool[] itemAlreadyAssigned = new bool[nrOfItems]; 48 49 bool useParent2 = false; 49 50 int nrOfBins = parent1.NrOfBins > parent2.NrOfBins ? parent2.NrOfBins : parent1.NrOfBins; 50 int swappedBin = random.Next(nrOfBins); 51 51 52 52 53 for (int binNr = 0; binNr < nrOfBins; binNr++) { 54 MultiComponentVectorEncoding currentParent1 = useParent2 ? parent2 : parent1; 55 MultiComponentVectorEncoding currentParent2 = useParent2 ? parent1 : parent2; 56 53 57 54 58 var newBin = new ItemList<PackingInformation>(); 55 var currentParent = binNr == swappedBin ? parent1 : parent2;59 double crossPointPercent = 0; 56 60 57 int nrOfItemsInBin = currentParent.PackingInformations[binNr].Count; 58 for (int i = 0; i < nrOfItemsInBin; i++) { 59 PackingInformation pi = new PackingInformation(currentParent.PackingInformations[binNr][i]); 60 if (!itemAlreadyAssigned[pi.ItemID]) { 61 itemAlreadyAssigned[pi.ItemID] = true; 62 newBin.Add(new PackingInformation(pi)); 61 int nrOfItems1 = currentParent1.PackingInformations[binNr].Count; 62 if (nrOfItems1 > 0) { 63 double crossPoint1 = random.Next(nrOfItems1); 64 crossPointPercent = crossPoint1 / nrOfItems1; 65 for (int i = 0; i < crossPoint1; i++) { 66 PackingInformation pi = new PackingInformation(currentParent1.PackingInformations[binNr][i]); 67 if (!itemAlreadyAssigned[pi.ItemID]) { 68 itemAlreadyAssigned[pi.ItemID] = true; 69 newBin.Add(new PackingInformation(pi)); 70 } 71 } 72 } 73 74 int nrOfItems2 = currentParent2.PackingInformations[binNr].Count; 75 if (nrOfItems2 > 0) { 76 int crossPoint2 = Convert.ToInt32(nrOfItems2 * crossPointPercent); 77 for (int i = crossPoint2; i < nrOfItems2; i++) { 78 PackingInformation pi = new PackingInformation(currentParent2.PackingInformations[binNr][i]); 79 if (!itemAlreadyAssigned[pi.ItemID]) { 80 itemAlreadyAssigned[pi.ItemID] = true; 81 newBin.Add(new PackingInformation(pi)); 82 } 63 83 } 64 84 } 65 85 66 86 child.PackingInformations[binNr] = newBin; 87 useParent2 = !useParent2; 67 88 } 68 89 … … 72 93 } 73 94 74 95 75 96 return child; 76 97 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs
r9593 r9596 35 35 using HeuristicLab.Problems.BinPacking.Dimensions; 36 36 using HeuristicLab.Problems.BinPacking.PackingBin; 37 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 38 using HeuristicLab.Encodings.PackingEncoding.GroupingVector; 39 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 37 40 38 41 namespace HeuristicLab.Encodings.PackingEncoding.PackingPlan { 39 42 [Item("PackingPlan", "Represents a concrete solution for a bin-packing problem.")] 40 43 [StorableClass] 41 public class PackingPlan<D, B, I> : ParameterizedNamedItem, IPackingPlan44 public abstract class PackingPlan<D, B, I> : ParameterizedNamedItem, IPackingPlan 42 45 where D : class, IPackingDimensions 43 46 where B : PackingShape<D>, IPackingBin … … 52 55 } 53 56 } 57 [Storable] 58 protected bool StackingConstraints { get; set; } 59 [Storable] 60 protected bool UseExtremePoints { get; set; } 61 62 [Storable] 63 public B BinMeasures { get; private set; } 54 64 55 65 [Storable] … … 71 81 #endregion 72 82 73 public PackingPlan(B binMeasures) 74 : this(){ 75 //this.BinPackings.Add(new BinPacking<D,B,I> ()); 76 } 77 public PackingPlan() 78 : base() { 79 this.BinPackings = new ObservableList<BinPacking<D, B,I>>(); 83 public PackingPlan(B binMeasures, bool useExtremePoints, bool stackingConstraints) 84 : base(){ 85 BinMeasures = (B)binMeasures.Clone(); 86 StackingConstraints = stackingConstraints; 87 UseExtremePoints = useExtremePoints; 88 BinPackings = new ObservableList<BinPacking<D, B, I>>(); 80 89 } 81 90 … … 86 95 this.BinPackings = new ObservableList<BinPacking<D, B, I>>(original.BinPackings); 87 96 } 88 public override IDeepCloneable Clone(Cloner cloner) { 89 return new PackingPlan<D,B,I>(this, cloner); 90 } 91 97 98 99 public abstract BinPacking<D, B, I> NewBinPacking(); 100 public void UpdateBinPackings() { 101 BinPackings.RemoveAll(x => x.ItemPositions.Count == 0); 102 BinPackings = new ObservableList<BinPacking<D, B, I>>(BinPackings.OrderByDescending (bp => bp.PackingDensity)); 103 } 104 105 public void Pack(MultiComponentVectorEncoding solution, ItemList<I> itemMeasures) { 106 var sequenceMatrix = solution.GenerateSequenceMatrix(); 107 Dictionary<int, bool> rotated = solution.GenerateRotationArray(); 108 109 //Fill bins according to grouping vector 110 List<int> remainingIDs = new List<int>(); 111 foreach (var sequence in sequenceMatrix) { 112 remainingIDs = remainingIDs.Concat(sequence).ToList(); 113 var bp = NewBinPacking(); 114 if (!UseExtremePoints) 115 bp.SlidingBasedPacking(ref remainingIDs, itemMeasures, rotated); 116 else 117 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints, rotated); 118 BinPackings.Add(bp); 119 } 120 UpdateBinPackings(); 121 122 //Try to put remaining items in existing bins 123 var temp = new List<int>(remainingIDs); 124 foreach (int id in temp) { 125 foreach (var bp in BinPackings) { 126 var position = UseExtremePoints ? bp.FindExtremePointForItem(itemMeasures[id], rotated[id], StackingConstraints) : bp.FindPositionBySliding(itemMeasures[id], rotated[id]); 127 if (position != null) { 128 bp.PackItem(id, itemMeasures[id], position); 129 remainingIDs.Remove(id); 130 } 131 } 132 } 133 134 //Put still remaining items in new bins 135 while (remainingIDs.Count > 0) { 136 var bp = NewBinPacking(); 137 if (!UseExtremePoints) 138 bp.SlidingBasedPacking(ref remainingIDs, itemMeasures, rotated); 139 else 140 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints, rotated); 141 BinPackings.Add(bp); 142 } 143 UpdateBinPackings(); 144 } 145 public void Pack(GroupingVectorEncoding solution, ItemList<I> itemMeasures) { 146 var sequenceMatrix = solution.GenerateSequenceMatrix(); 147 148 //Fill bins according to grouping vector 149 List<int> remainingIDs = new List<int>(); 150 foreach (var sequence in sequenceMatrix) { 151 remainingIDs = remainingIDs.Concat(sequence).ToList(); 152 var bp = NewBinPacking(); 153 if (!UseExtremePoints) 154 bp.SlidingBasedPacking(ref remainingIDs, itemMeasures); 155 else 156 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints); 157 BinPackings.Add(bp); 158 } 159 UpdateBinPackings(); 160 161 //Try to put remaining items in existing bins 162 var temp = new List<int>(remainingIDs); 163 foreach (int id in temp) { 164 foreach (var bp in BinPackings) { 165 var position = UseExtremePoints ? bp.FindExtremePointForItem (itemMeasures[id], false, StackingConstraints) : bp.FindPositionBySliding(itemMeasures[id], false); 166 if (position != null) { 167 bp.PackItem(id, itemMeasures[id], position); 168 remainingIDs.Remove(id); 169 } 170 } 171 } 172 173 //Put still remaining items in new bins 174 while (remainingIDs.Count > 0) { 175 var bp = NewBinPacking(); 176 if (!UseExtremePoints) 177 bp.SlidingBasedPacking(ref remainingIDs, itemMeasures); 178 else 179 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints); 180 BinPackings.Add(bp); 181 } 182 UpdateBinPackings(); 183 } 184 public void Pack(PackingSequenceEncoding solution, ItemList<I> itemMeasures) { 185 List<int> remainingIDs = new List<int>(solution.PackingSequence); 186 while (remainingIDs.Count > 0) { 187 var bp = NewBinPacking(); 188 if (!UseExtremePoints) 189 bp.SlidingBasedPacking(ref remainingIDs, itemMeasures); 190 else 191 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints); 192 BinPackings.Add(bp); 193 } 194 UpdateBinPackings(); 195 } 196 92 197 93 198 #region Events … … 126 231 } 127 232 128 [Item("BinPacking", "Represents a single-bin packing for a bin-packing problem.")] 233 234 235 236 [Item("PackingPlan2D", "Represents a concrete solution for a 2D bin-packing problem.")] 129 237 [StorableClass] 130 public abstract class BinPacking<D,B,I> : Item 131 where D : class, IPackingDimensions 132 where B : PackingShape<D>, IPackingBin 133 where I : PackingShape<D>, IPackingItem { 134 135 [Storable] 136 public ObservableDictionary<int, D> ItemPositions { get; private set; } 137 138 [Storable] 139 public B BinMeasures { get; private set; } 140 141 [Storable] 142 public ObservableDictionary<int, I> ItemMeasures { get; private set; } 143 144 [Storable] 145 public HashSet<D> ExtremePoints { get; protected set; } 146 147 [Storable] 148 public OccupiedPoints<D, I> OccupiedPoints { get; protected set; } 149 150 public BinPacking(B binMeasures) : base() { 151 ItemPositions = new ObservableDictionary<int, D>(); 152 ItemMeasures = new ObservableDictionary<int, I>(); 153 BinMeasures = (B)binMeasures.Clone(); 154 ExtremePoints = new HashSet<D>(); 155 ExtremePoints.Add(binMeasures.Origin); 156 } 157 238 public class PackingPlan2D : PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> { 239 public PackingPlan2D(RectangularPackingBin binMeasures) : this(binMeasures, false, false) { } 240 public PackingPlan2D(RectangularPackingBin binMeasures, bool useExtremePoints, bool stackingConstraints) : base(binMeasures, useExtremePoints, stackingConstraints) { } 158 241 [StorableConstructor] 159 protected BinPacking(bool deserializing) : base(deserializing) { }160 protected BinPacking(BinPacking<D,B,I>original, Cloner cloner)242 protected PackingPlan2D(bool deserializing) : base(deserializing) { } 243 protected PackingPlan2D(PackingPlan2D original, Cloner cloner) 161 244 : base(original, cloner) { 162 this.ItemPositions = new ObservableDictionary<int, D>(original.ItemPositions); 163 this.ItemMeasures = new ObservableDictionary<int, I>(original.ItemMeasures); 164 this.BinMeasures = (B)original.BinMeasures.Clone(cloner); 165 } 166 167 168 protected abstract void GenerateNewExtremePointsForNewItem(I measures, D position); 169 public abstract D FindExtremePointForItem(I measures, bool rotated, bool stackingConstraint); 170 public abstract D FindPositionBySliding(I measures, bool rotated); 171 public void PackItem(int itemID, I measures, D position) { 172 ItemMeasures[itemID] = measures; 173 ItemPositions[itemID] = position; 174 ExtremePoints.Remove(position); 175 GenerateNewExtremePointsForNewItem(measures, position); 176 OccupiedPoints.OccupyPoints(measures, position, itemID); 177 } 178 179 180 public double PackingDensity { 181 get { 182 double result = 0; 183 foreach (var entry in ItemMeasures) 184 result += entry.Value.MultipliedMeasures; 185 result /= BinMeasures.MultipliedMeasures; 186 return result; 187 } 188 } 189 190 public bool IsPositionFeasible1(I currentItem, D currentPosition) { 191 //In this case feasability is defined as following: 1. the item fits into the bin-borders; 2. the item does not collide with another already packed item 192 if (!BinMeasures.Encloses(currentPosition, currentItem)) 193 return false; 194 195 foreach (var ipEntry in ItemPositions) { 196 if (ItemMeasures[ipEntry.Key].Overlaps(ipEntry.Value, currentPosition, currentItem)) 197 return false; 198 } 199 200 return true; 201 } 202 public bool IsPositionFeasible(I currentItem, D position) { 203 if (!BinMeasures.Encloses(position, currentItem)) 204 return false; 205 206 return OccupiedPoints.IsPositionFeasible (currentItem, position); 245 } 246 public override IDeepCloneable Clone(Cloner cloner) { 247 return new PackingPlan2D(this, cloner); 248 } 249 public override BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> NewBinPacking() { 250 return new BinPacking2D(BinMeasures); 207 251 } 208 252 } … … 212 256 213 257 214 [Item(" BinPacking2D", "Represents a single-bin packing for a 2D bin-packing problem.")]258 [Item("PackingPlan3D", "Represents a concrete solution for a 3D bin-packing problem.")] 215 259 [StorableClass] 216 public class BinPacking2D : BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> { 217 218 public BinPacking2D(RectangularPackingBin binMeasures) : base(binMeasures) { 219 OccupiedPoints = new OccupiedPoints2D(binMeasures); 220 } 260 public class PackingPlan3D : PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> { 261 public PackingPlan3D(CuboidPackingBin binMeasures) : this(binMeasures, false, false) { } 262 public PackingPlan3D(CuboidPackingBin binMeasures, bool useExtremePoints, bool stackingConstraints) : base(binMeasures, useExtremePoints, stackingConstraints) { } 221 263 [StorableConstructor] 222 protected BinPacking2D(bool deserializing) : base(deserializing) { }223 protected BinPacking2D(BinPacking2D original, Cloner cloner)264 protected PackingPlan3D(bool deserializing) : base(deserializing) { } 265 protected PackingPlan3D(PackingPlan3D original, Cloner cloner) 224 266 : base(original, cloner) { 225 267 } 226 268 public override IDeepCloneable Clone(Cloner cloner) { 227 return new BinPacking2D(this, cloner); 228 } 229 230 protected override void GenerateNewExtremePointsForNewItem(RectangularPackingItem newItem, TwoDimensionalPacking position) { 231 232 int newWidth = position.Rotated ? newItem.Height : newItem.Width; 233 int newHeight = position.Rotated ? newItem.Width : newItem.Height; 234 235 //Find ExtremePoints beginning from sourcepointX 236 var sourcePointX = new TwoDimensionalPacking(0, position.X + newWidth, position.Y); 237 if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height) { 238 //Traversing down the y-axis 239 while (sourcePointX.Y > 0 && !OccupiedPoints.IsPointOccupied(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1))) { 240 sourcePointX.Y--; 241 } 242 ExtremePoints.Add(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y)); 243 } 244 245 246 247 248 //Find ExtremePoints beginning from sourcepointY 249 var sourcePointY = new TwoDimensionalPacking(0, position.X, position.Y + newItem.Height); 250 if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height) { 251 //Traversing down the x-axis 252 while (sourcePointY.X > 0 && !OccupiedPoints.IsPointOccupied(new TwoDimensionalPacking (0,sourcePointY.X - 1, sourcePointY.Y))) { 253 sourcePointY.X--; 254 } 255 ExtremePoints.Add(new TwoDimensionalPacking(0, sourcePointY.X, sourcePointY.Y)); 256 } 257 258 ExtremePoints = new HashSet<TwoDimensionalPacking>(ExtremePoints. 259 OrderBy(ep => ep.AssignedBin). 260 ThenBy(ep => ep.X). 261 ThenBy(ep => ep.Y). 262 ThenBy(ep => OccupiedPoints.ShortestPossibleSideFromEP(ep))); 263 } 264 265 public override TwoDimensionalPacking FindExtremePointForItem(RectangularPackingItem measures, bool rotated, bool stackingConstraint) { 266 RectangularPackingItem item = new RectangularPackingItem( 267 rotated ? measures.Height : measures.Width, 268 rotated ? measures.Width : measures.Height, 269 measures.TargetBin); 270 271 int epIndex = 0; 272 while (epIndex < ExtremePoints.Count && (!IsPositionFeasible(item, ExtremePoints.ElementAt(epIndex)))) { epIndex++; } 273 274 if (epIndex < ExtremePoints.Count) { 275 var result = ExtremePoints.ElementAt(epIndex); 276 result.Rotated = rotated; 277 return result; 278 } 279 return null; 280 } 281 public override TwoDimensionalPacking FindPositionBySliding(RectangularPackingItem measures, bool rotated) { 282 TwoDimensionalPacking currentPosition = new TwoDimensionalPacking(0, 283 BinMeasures.Width - (rotated ? measures.Height : measures.Width), 284 BinMeasures.Height - (rotated ? measures.Width : measures.Height), rotated); 285 //Slide the item as far as possible to the left 286 while (IsPositionFeasible(measures, MoveLeft(currentPosition)) 287 || IsPositionFeasible(measures, MoveDown(currentPosition))) { 288 //Slide the item as far as possible to the bottom 289 while (IsPositionFeasible(measures, MoveDown(currentPosition))) { 290 currentPosition = MoveDown(currentPosition); 291 } 292 if (IsPositionFeasible(measures, MoveLeft(currentPosition))) 293 currentPosition = MoveLeft(currentPosition); 294 } 295 296 return IsPositionFeasible(measures, currentPosition) ? currentPosition : null; 297 } 298 private static TwoDimensionalPacking MoveLeft(TwoDimensionalPacking original) { 299 return new TwoDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Rotated); 300 } 301 private static TwoDimensionalPacking MoveDown(TwoDimensionalPacking original) { 302 return new TwoDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Rotated); 269 return new PackingPlan3D(this, cloner); 270 } 271 public override BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> NewBinPacking() { 272 return new BinPacking3D(BinMeasures); 303 273 } 304 274 } 305 275 306 307 308 [Item("BinPacking3D", "Represents a single-bin packing for a 3D bin-packing problem.")]309 [StorableClass]310 public class BinPacking3D : BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> {311 312 313 public BinPacking3D(CuboidPackingBin binMeasures) : base(binMeasures) {314 OccupiedPoints = new OccupiedPoints3D(binMeasures);315 }316 [StorableConstructor]317 protected BinPacking3D(bool deserializing) : base(deserializing) { }318 protected BinPacking3D(BinPacking3D original, Cloner cloner)319 : base(original, cloner) {320 }321 public override IDeepCloneable Clone(Cloner cloner) {322 return new BinPacking3D(this, cloner);323 }324 325 protected override void GenerateNewExtremePointsForNewItem(CuboidPackingItem newItem, ThreeDimensionalPacking position) {326 int newWidth = position.Rotated ? newItem.Depth : newItem.Width;327 int newDepth = position.Rotated ? newItem.Width : newItem.Depth;328 329 //Find ExtremePoints beginning from sourcepointX330 var sourcePointX = new ThreeDimensionalPacking(0, position.X + newWidth, position.Y, position.Z);331 if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height && sourcePointX.Z < BinMeasures.Depth) {332 //Traversing down the y-axis333 int currentYValue = sourcePointX.Y;334 while (currentYValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointX.X, currentYValue, sourcePointX.Z))) {335 currentYValue--;336 }337 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointX.X, currentYValue, sourcePointX.Z));338 339 //Traversing down the z-axis340 int currentZValue = sourcePointX.Z;341 while (currentZValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointX.X, sourcePointX.Y, currentZValue - 1))) {342 currentZValue--;343 }344 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, currentZValue));345 }346 347 348 349 350 //Find ExtremePoints beginning from sourcepointY351 var sourcePointY = new ThreeDimensionalPacking(0, position.X, position.Y + newItem.Height, position.Z);352 if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height && sourcePointY.Z < BinMeasures.Depth) {353 //Traversing down the x-axis354 int currentXValue = sourcePointY.X;355 while (currentXValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, currentXValue - 1, sourcePointY.Y, sourcePointY.Z))) {356 currentXValue--;357 }358 ExtremePoints.Add(new ThreeDimensionalPacking(0, currentXValue, sourcePointY.Y, sourcePointY.Z));359 360 //Traversing down the z-axis361 int currentZValue = sourcePointY.Z;362 while (currentZValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointY.X, sourcePointY.Y, currentZValue - 1))) {363 currentZValue--;364 }365 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, currentZValue));366 }367 368 369 370 371 372 //Find ExtremePoints beginning from sourcepointZ373 var sourcePointZ = new ThreeDimensionalPacking(0, position.X, position.Y, position.Z + newDepth);374 if (sourcePointZ.X < BinMeasures.Width && sourcePointZ.Y < BinMeasures.Height && sourcePointZ.Z < BinMeasures.Depth) {375 //Traversing down the x-axis376 int currentXValue = sourcePointZ.X;377 while (currentXValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, currentXValue - 1, sourcePointZ.Y, sourcePointZ.Z))) {378 currentXValue--;379 }380 ExtremePoints.Add(new ThreeDimensionalPacking(0, currentXValue, sourcePointZ.Y, sourcePointZ.Z));381 382 //Traversing down the y-axis383 int currentYValue = sourcePointZ.Y;384 while (currentYValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointZ.X, currentYValue, sourcePointZ.Z))) {385 currentYValue--;386 }387 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointZ.X, currentYValue, sourcePointZ.Z));388 }389 390 ExtremePoints = new HashSet<ThreeDimensionalPacking>(ExtremePoints.391 OrderBy(ep => ep.AssignedBin).392 ThenBy(ep => ep.Z).393 ThenBy(ep => ep.X).394 ThenBy(ep => ep.Y).395 ThenBy(ep => OccupiedPoints.ShortestPossibleSideFromEP(ep)));396 }397 398 public override ThreeDimensionalPacking FindExtremePointForItem(CuboidPackingItem measures, bool rotated, bool stackingConstraint) {399 400 CuboidPackingItem item = new CuboidPackingItem(401 rotated ? measures.Depth : measures.Width,402 measures.Height,403 rotated ? measures.Width : measures.Depth,404 measures.TargetBin);405 406 int epIndex = 0;407 while (epIndex < ExtremePoints.Count && (408 !IsPositionFeasible(item, ExtremePoints.ElementAt(epIndex)) || (stackingConstraint && !OccupiedPoints.IsStaticStable(item, ExtremePoints.ElementAt(epIndex)))409 )) { epIndex++; }410 411 if (epIndex < ExtremePoints.Count) {412 var result = ExtremePoints.ElementAt(epIndex);413 result.Rotated = rotated;414 return result;415 }416 return null;417 }418 public override ThreeDimensionalPacking FindPositionBySliding(CuboidPackingItem measures, bool rotated) {419 //Starting-position at upper right corner (=left bottom point of item-rectangle is at position item.width,item.height)420 ThreeDimensionalPacking currentPosition = new ThreeDimensionalPacking(0,421 BinMeasures.Width - (rotated ? measures.Depth : measures.Width),422 BinMeasures.Height - measures.Height,423 BinMeasures.Depth - (rotated ? measures.Width : measures.Depth), rotated);424 //Slide the item as far as possible to the bottom425 while (IsPositionFeasible(measures, MoveDown(currentPosition))426 || IsPositionFeasible(measures, MoveLeft(currentPosition))427 || IsPositionFeasible(measures, MoveBack(currentPosition))) {428 //Slide the item as far as possible to the left429 while (IsPositionFeasible(measures, MoveLeft(currentPosition))430 || IsPositionFeasible(measures, MoveBack(currentPosition))) {431 //Slide the item as far as possible to the back432 while (IsPositionFeasible(measures, MoveBack(currentPosition))) {433 currentPosition = MoveBack(currentPosition);434 }435 if (IsPositionFeasible(measures, MoveLeft(currentPosition)))436 currentPosition = MoveLeft(currentPosition);437 }438 if (IsPositionFeasible(measures, MoveDown(currentPosition)))439 currentPosition = MoveDown(currentPosition);440 }441 442 return IsPositionFeasible(measures, currentPosition) ? currentPosition : null;443 }444 private static ThreeDimensionalPacking MoveLeft(ThreeDimensionalPacking original) {445 return new ThreeDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Z, original.Rotated);446 }447 private static ThreeDimensionalPacking MoveDown(ThreeDimensionalPacking original) {448 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Z, original.Rotated);449 }450 private static ThreeDimensionalPacking MoveBack(ThreeDimensionalPacking original) {451 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y, original.Z - 1, original.Rotated);452 }453 }454 455 456 457 276 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj
r9593 r9596 166 166 <Compile Include="Analyzers\BinPackingAnalyzer.cs" /> 167 167 <Compile Include="Decoders\2D\BL\BottomLeftMultiComponentVectorDecoder.cs" /> 168 <Compile Include="Decoders\2D\TwoDimensionalPackingFunctions.cs" />169 168 <Compile Include="Decoders\2D\EP\ExtremePointGroupingVectorDecoder2D.cs" /> 170 169 <Compile Include="Decoders\2D\EP\ExtremePointMultiComponentVectorDecoder2D.cs" /> 171 170 <Compile Include="Decoders\2D\EP\ExtremePointPackingSequenceDecoder2D.cs" /> 172 <Compile Include="Decoders\3D\ThreeDimensionalPackingFunctions.cs" />173 171 <Compile Include="Decoders\3D\EP\ExtremePointMultiComponentVectorDecoder3D.cs" /> 174 172 <Compile Include="Decoders\3D\EP\ExtremePointGroupingVectorDecoder3D.cs" /> … … 180 178 <Compile Include="Decoders\2D\BL\BottomLeftPackingSequenceDecoder.cs" /> 181 179 <Compile Include="Decoders\3D\EP\ISOContainerMultiComponentVectorDecoder3D.cs" /> 182 <Compile Include="Decoders\SequentialPackingFunctions.cs">183 <SubType>Code</SubType>184 </Compile>185 180 <Compile Include="Decoders\PackingSolutionDecoder.cs" /> 186 <Compile Include="Dimensions\OccupiedPoints3D.cs" />187 <Compile Include="Dimensions\OccupiedPoints2D.cs" />188 <Compile Include="Dimensions\OccupiedPoints.cs" />189 181 <Compile Include="Encodings\GroupingVector\GroupingVectorSwap2Manipulator.cs" /> 190 182 <Compile Include="Encodings\GroupingVector\GroupingVectorSinglePointCrossover.cs" /> … … 211 203 <Compile Include="Encodings\GroupingVector\GroupingVectorManipulator.cs" /> 212 204 <Compile Include="Encodings\GroupingVector\GroupingVectorRandomCreator.cs" /> 205 <Compile Include="Encodings\MultiComponentVector\SequenceBasedMultiComponentVectorCrossover.cs" /> 213 206 <Compile Include="Encodings\MultiComponentVector\BinBasedMultiComponentVectorCrossover.cs" /> 214 <Compile Include="Encodings\MultiComponentVector\SequenceBasedMultiComponentVectorCrossover.cs" />215 207 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\ChangePositionMoveAttribute.cs" /> 216 208 <Compile Include="Encodings\MultiComponentVector\Moves\Triple\Attributes\MCVTripleMoveAttribute.cs" /> … … 241 233 <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorRandomCreator.cs" /> 242 234 <Compile Include="Encodings\MultiComponentVector\ThreeWayMultiComponentVectorManipulator.cs" /> 235 <Compile Include="Encodings\PackingPlans\BinPacking2D.cs" /> 236 <Compile Include="Encodings\PackingPlans\BinPacking3D.cs" /> 237 <Compile Include="Encodings\PackingPlans\BinPacking.cs" /> 243 238 <Compile Include="Encodings\PackingPlans\PackingPlan.cs" /> 244 239 <Compile Include="Encodings\PackingSequence\Moves\Insertion\ExhaustiveInsertionMoveGenerator.cs" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Instances/BPPORLIBParser.cs
r9348 r9596 90 90 91 91 for (int k = 0; k < Items; k++) { 92 if (reader.EndOfStream) throw new InvalidDataException("Unexpected End of Stream .");92 if (reader.EndOfStream) throw new InvalidDataException("Unexpected End of Stream (at line " + k + ")."); 93 93 var valLine = reader.ReadLine(); 94 94 while (String.IsNullOrWhiteSpace(valLine)) valLine = reader.ReadLine(); … … 101 101 } 102 102 103 int problemClassNr = int.Parse(problemClass[0]); 104 Name = (isThreeDimensional ? "3" : "2") + "dbpp_class_0" + problemClassNr; 105 if (!isThreeDimensional) { 106 if (problemClassNr >= 1 && problemClassNr <= 5) 107 Description = "Proposed by Berkey and Wang."; 108 else if (problemClassNr >= 6 && problemClassNr <= 10) 109 Description = "Proposed by Martello and Vigo."; 103 Int32 problemClassNr = -1; 104 if (int.TryParse(problemClass[0], out problemClassNr)) { 105 Name = (isThreeDimensional ? "3" : "2") + "dbpp_class_0" + problemClassNr; 106 if (!isThreeDimensional) { 107 if (problemClassNr >= 1 && problemClassNr <= 5) 108 Description = "Proposed by Berkey and Wang."; 109 else if (problemClassNr >= 6 && problemClassNr <= 10) 110 Description = "Proposed by Martello and Vigo."; 111 } else { 112 if (problemClassNr >= 1 && problemClassNr <= 5) 113 Description = "Proposed by Martello and Vigo."; 114 else if (problemClassNr >= 6 && problemClassNr <= 9) 115 Description = "Proposed by Berkey and Wang."; 116 } 110 117 } else { 111 if (problemClassNr >= 1 && problemClassNr <= 5) 112 Description = "Proposed by Martello and Vigo."; 113 else if (problemClassNr >= 6 && problemClassNr <= 9) 114 Description = "Proposed by Berkey and Wang."; 118 Name = "Unknown"; 119 Description = "<Missing>"; 115 120 } 116 121 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs
r9593 r9596 26 26 /// Plugin class for HeuristicLab.Problems.BinPacking plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.95 63")]28 [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.9593")] 29 29 [PluginFile("HeuristicLab.Problems.BinPacking-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Common", "3.3")] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs
r9593 r9596 55 55 public override ThreeDimensionalPacking Origin { get { return new ThreeDimensionalPacking(0, 0, 0, 0); } } 56 56 public override int MultipliedMeasures { get { return Width * Height * Depth; } } 57 57 58 public override bool EnclosesPoint(ThreeDimensionalPacking myPosition, ThreeDimensionalPacking checkedPoint) { 59 var c = new CuboidDiagonal(myPosition, this); 60 return (c.x1 <= checkedPoint.X && 61 c.x2 >= checkedPoint.X && 62 c.y1 <= checkedPoint.Y && 63 c.y2 >= checkedPoint.Y && 64 c.z1 <= checkedPoint.Z && 65 c.z2 >= checkedPoint.Z); 66 } 58 67 public override bool Encloses(ThreeDimensionalPacking checkedPosition, PackingShape<ThreeDimensionalPacking> checkedShape) { 59 68 return Encloses(checkedPosition, (CuboidPackingShape) checkedShape); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/PackingShape.cs
r9593 r9596 39 39 } 40 40 41 public abstract bool EnclosesPoint(D myPosition, D checkedPoint); 41 42 public abstract bool Encloses(D checkedPosition, PackingShape<D> checkedShape); 42 43 public abstract bool Overlaps(D myPosition, D checkedPosition, PackingShape<D> checkedShape); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs
r9593 r9596 51 51 public override int MultipliedMeasures { get { return Height * Width; } } 52 52 53 public override bool EnclosesPoint(TwoDimensionalPacking myPosition, TwoDimensionalPacking checkedPoint) { 54 var r = new RectangleDiagonal(myPosition, this); 55 return (r.x1 <= checkedPoint.X && 56 r.x2 >= checkedPoint.X && 57 r.y1 <= checkedPoint.Y && 58 r.y2 >= checkedPoint.Y); 59 } 53 60 public override bool Encloses(TwoDimensionalPacking checkedPosition, PackingShape<TwoDimensionalPacking> checkedShape) { 54 61 return Encloses(checkedPosition, (RectangularPackingShape)checkedShape);
Note: See TracChangeset
for help on using the changeset viewer.