Changeset 9563
- Timestamp:
- 06/02/13 04:26:26 (12 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3
- Files:
-
- 86 added
- 6 deleted
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Analyzers/BestBinPackingSolutionAnalyzer.cs
r9440 r9563 34 34 using HeuristicLab.Encodings.PackingEncoding.PackingPlan; 35 35 using HeuristicLab.Problems.BinPacking.Shapes; 36 using HeuristicLab.Problems.BinPacking.Evaluators; 36 37 37 38 namespace HeuristicLab.Problems.BinPacking.Analyzers { … … 40 41 public class BestBinPackingSolutionAnalyzer<D, B, I> : BinPackingAnalyzer<D, B, I>, IStochasticOperator 41 42 where D : class, IPackingDimensions 42 where B : PackingShape<D>, IPackingBin 43 where I : PackingShape<D>, IPackingItem {43 where B : PackingShape<D>, IPackingBin, IRegularPackingShape 44 where I : PackingShape<D>, IPackingItem, IRegularPackingShape { 44 45 45 46 protected BestBinPackingSolutionAnalyzer(BestBinPackingSolutionAnalyzer<D,B,I> original, Cloner cloner) … … 93 94 bestSolution.Quality.Value = qualities[i].Value; 94 95 bestSolution.PackingItemPositions = new ObservableDictionary<int, D> (solutions[i].PackingItemPositions); 96 bestSolution.PackingBinMeasures = new ObservableDictionary<int, B>(solutions[i].PackingBinMeasures); 95 97 } 96 98 } 99 string binUtilKey = "Overall Bin Utilization"; 100 DoubleValue binUtil = BinUtilizationRegularIdenticalBinEvaluator<D, B, I>.CalculateBinUtilization(bestSolution); 101 if (!results.ContainsKey("Overall Bin Utilization")) 102 results.Add(new Result(binUtilKey, binUtil)); 103 else 104 results[binUtilKey].Value = binUtil; 97 105 98 106 return base.Apply(); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftFunctions.cs
r9495 r9563 8 8 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 9 9 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 10 using HeuristicLab.Encodings.PermutationEncoding; 10 11 using HeuristicLab.Problems.BinPacking.Dimensions; 11 12 using HeuristicLab.Problems.BinPacking.Interfaces; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftGroupingVectorDecoder.cs
r9495 r9563 44 44 TwoDimensionalPacking, 45 45 RectangularPackingBin, 46 RectangularPackingItem> {46 RectangularPackingItem>, I2DGVDecoder { 47 47 48 48 public BottomLeftGroupingVectorDecoder() … … 60 60 61 61 62 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {62 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 63 63 64 64 var solution = encodedSolution as GroupingVectorEncoding; … … 66 66 67 67 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures, itemMeasures); 69 69 70 70 result.PackingItemPositions = BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftMultiComponentVectorDecoder.cs
r9495 r9563 44 44 TwoDimensionalPacking, 45 45 RectangularPackingBin, 46 RectangularPackingItem> {46 RectangularPackingItem>, I2DMCVDecoder { 47 47 48 48 public BottomLeftMultiComponentVectorDecoder() … … 60 60 61 61 62 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {62 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 63 63 64 64 var solution = encodedSolution as MultiComponentVectorEncoding; … … 66 66 67 67 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures, itemMeasures); 69 69 70 70 result.PackingItemPositions = BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftPackingSequenceDecoder.cs
r9495 r9563 43 43 TwoDimensionalPacking, 44 44 RectangularPackingBin, 45 RectangularPackingItem> {45 RectangularPackingItem>, I2DPSDecoder { 46 46 47 47 public BottomLeftPackingSequenceDecoder() … … 59 59 60 60 61 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {61 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 62 62 63 63 var solution = encodedSolution as PackingSequenceEncoding; … … 65 65 66 66 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 67 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);67 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures, itemMeasures); 68 68 69 69 result.PackingItemPositions = BottomLeftFunctions.BottomLeftPacking (solution, binMeasures, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointGroupingVectorDecoder2D.cs
r9495 r9563 44 44 TwoDimensionalPacking, 45 45 RectangularPackingBin, 46 RectangularPackingItem> {46 RectangularPackingItem>, I2DGVDecoder { 47 47 48 48 public ExtremePointGroupingVectorDecoder2D () … … 67 67 } 68 68 69 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {69 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 70 70 71 71 var solution = encodedSolution as GroupingVectorEncoding; 72 72 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); 73 73 74 return Decode(solution, PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);74 return Decode(solution, binMeasures, itemMeasures); 75 75 } 76 76 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointMultiComponentVectorDecoder2D.cs
r9495 r9563 45 45 TwoDimensionalPacking, 46 46 RectangularPackingBin, 47 RectangularPackingItem> {47 RectangularPackingItem>, I2DMCVDecoder { 48 48 49 49 public ExtremePointMultiComponentVectorDecoder2D () … … 68 68 } 69 69 70 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {70 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 71 71 72 72 var solution = encodedSolution as MultiComponentVectorEncoding; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointPackingSequenceDecoder2D.cs
r9495 r9563 43 43 TwoDimensionalPacking, 44 44 RectangularPackingBin, 45 RectangularPackingItem> {45 RectangularPackingItem>, I2DPSDecoder { 46 46 47 47 public ExtremePointPackingSequenceDecoder2D () … … 58 58 59 59 60 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {60 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 61 61 62 62 var solution = encodedSolution as PackingSequenceEncoding; … … 64 64 65 65 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 66 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);66 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures, itemMeasures); 67 67 68 result.PackingItemPositions = ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, PackingItemMeasuresParameter.ActualValue, PackingBinMeasuresParameter.ActualValue);68 result.PackingItemPositions = ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures); 69 69 70 70 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointsFunctions2D.cs
r9495 r9563 8 8 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 9 9 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 10 using HeuristicLab.Encodings.PermutationEncoding; 10 11 using HeuristicLab.Problems.BinPacking.Dimensions; 11 12 using HeuristicLab.Problems.BinPacking.Interfaces; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftFunctions.cs
r9495 r9563 8 8 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 9 9 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 10 using HeuristicLab.Encodings.PermutationEncoding; 10 11 using HeuristicLab.Problems.BinPacking.Dimensions; 11 12 using HeuristicLab.Problems.BinPacking.Interfaces; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftGroupingVectorDecoder.cs
r9495 r9563 43 43 ThreeDimensionalPacking, 44 44 CuboidPackingBin, 45 CuboidPackingItem> {45 CuboidPackingItem>, I3DGVDecoder { 46 46 47 47 public DeepestBottomLeftGroupingVectorDecoder() … … 59 59 60 60 61 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {61 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 62 62 63 63 var solution = encodedSolution as GroupingVectorEncoding; … … 65 65 66 66 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>( 67 PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);67 binMeasures, itemMeasures); 68 68 69 69 ObservableDictionary<int, ThreeDimensionalPacking> packingPositions = DeepestBottomLeftFunctions.DeepestLeftBottomPacking( 70 70 solution, 71 PackingBinMeasuresParameter.ActualValue,72 PackingItemMeasuresParameter.ActualValue);71 binMeasures, 72 itemMeasures); 73 73 74 74 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftMultiComponentVectorDecoder.cs
r9495 r9563 44 44 ThreeDimensionalPacking, 45 45 CuboidPackingBin, 46 CuboidPackingItem> {46 CuboidPackingItem>, I3DMCVDecoder { 47 47 48 48 public DeepestBottomLeftMultiComponentVectorDecoder() … … 60 60 61 61 62 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {62 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 63 63 64 64 var solution = encodedSolution as MultiComponentVectorEncoding; … … 66 66 67 67 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 68 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);68 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures, itemMeasures); 69 69 70 70 result.PackingItemPositions = DeepestBottomLeftFunctions.DeepestLeftBottomPacking (solution, binMeasures, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftPackingSequenceDecoder.cs
r9495 r9563 43 43 ThreeDimensionalPacking, 44 44 CuboidPackingBin, 45 CuboidPackingItem> {45 CuboidPackingItem>, I3DPSDecoder { 46 46 47 47 public DeepestBottomLeftPackingSequenceDecoder() … … 59 59 60 60 61 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {61 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 62 62 63 63 var solution = encodedSolution as PackingSequenceEncoding; … … 65 65 66 66 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 67 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);67 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures, itemMeasures); 68 68 69 69 result.PackingItemPositions = DeepestBottomLeftFunctions.DeepestLeftBottomPacking (solution, binMeasures, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointGroupingVectorDecoder3D.cs
r9495 r9563 44 44 ThreeDimensionalPacking, 45 45 CuboidPackingBin, 46 CuboidPackingItem> {46 CuboidPackingItem>, I3DGVDecoder { 47 47 48 48 public ExtremePointGroupingVectorDecoder3D () … … 67 67 } 68 68 69 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {69 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 70 70 71 71 var solution = encodedSolution as GroupingVectorEncoding; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointMultiComponentVectorDecoder3D.cs
r9495 r9563 45 45 ThreeDimensionalPacking, 46 46 CuboidPackingBin, 47 CuboidPackingItem> {47 CuboidPackingItem>, I3DMCVDecoder { 48 48 49 49 public ExtremePointMultiComponentVectorDecoder3D () … … 68 68 } 69 69 70 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {70 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 71 71 72 72 var solution = encodedSolution as MultiComponentVectorEncoding; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointPackingSequenceDecoder3D.cs
r9495 r9563 43 43 ThreeDimensionalPacking, 44 44 CuboidPackingBin, 45 CuboidPackingItem> {45 CuboidPackingItem>, I3DPSDecoder { 46 46 47 47 public ExtremePointPackingSequenceDecoder3D () … … 58 58 59 59 60 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {60 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 61 61 62 62 var solution = encodedSolution as PackingSequenceEncoding; … … 64 64 65 65 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 66 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);66 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures, itemMeasures); 67 67 68 result.PackingItemPositions = ExtremePointsFunctions3D.ExtremePointBasedPacking(solution, PackingItemMeasuresParameter.ActualValue, PackingBinMeasuresParameter.ActualValue);68 result.PackingItemPositions = ExtremePointsFunctions3D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures); 69 69 70 70 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointsFunctions3D.cs
r9495 r9563 9 9 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 10 10 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 11 using HeuristicLab.Encodings.PermutationEncoding; 11 12 using HeuristicLab.Problems.BinPacking.Dimensions; 12 13 using HeuristicLab.Problems.BinPacking.Interfaces; … … 221 222 return FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePoints, occupiedPoints, itemPositions, false); 222 223 } 224 public static ThreeDimensionalPacking FindExtremePointForItemUsingMaterialAndWeightConstraint(int itemIndex, ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures, 225 HashSet<ThreeDimensionalPacking> extremePoints, List<int[, ,]> occupiedPoints, ObservableDictionary<int, ThreeDimensionalPacking> itemPositions, bool rotated) { 226 227 var itemFromList = itemMeasures[itemIndex]; 228 CuboidPackingItem item = new CuboidPackingItem( 229 rotated ? itemFromList.Depth : itemFromList.Width, 230 itemFromList.Height, 231 rotated ? itemFromList.Width : itemFromList.Depth, 232 itemFromList.TargetBin, itemFromList.Weight, itemFromList.Material); 233 234 int epIndex = 0; 235 while (epIndex < extremePoints.Count && 236 (!DeepestBottomLeftFunctions.IsPositionFeasible(binMeasures, extremePoints.ElementAt(epIndex).AssignedBin, item, extremePoints.ElementAt(epIndex), itemPositions, itemMeasures) || 237 !IsStaticStable(occupiedPoints[extremePoints.ElementAt(epIndex).AssignedBin], item, extremePoints.ElementAt(epIndex)) || 238 !WeightIsSupported(occupiedPoints[extremePoints.ElementAt(epIndex).AssignedBin], item, extremePoints.ElementAt(epIndex), itemMeasures))) { epIndex++; } 239 240 if (epIndex < extremePoints.Count) { 241 var result = extremePoints.ElementAt(epIndex); 242 result.Rotated = rotated; 243 return result; 244 } 245 return null; 246 } 223 247 public static ThreeDimensionalPacking FindExtremePointForItem(int itemIndex, ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures, 224 248 HashSet<ThreeDimensionalPacking> extremePoints, List<int[,,]> occupiedPoints, ObservableDictionary<int, ThreeDimensionalPacking> itemPositions, bool rotated) { … … 228 252 rotated ? itemFromList.Depth : itemFromList.Width, 229 253 itemFromList.Height, 230 rotated ? itemFromList.Width : itemFromList.Depth, 254 rotated ? itemFromList.Width : itemFromList.Depth, 231 255 itemFromList.TargetBin); 232 256 … … 280 304 return false; 281 305 } 306 public static bool WeightIsSupported(int[, ,] occupiedPoints, CuboidPackingItem item, ThreeDimensionalPacking ep, ItemList<CuboidPackingItem> items) { 307 //Static stability is given, if item is placed on the ground 308 if (ep.Y == 0) 309 return true; 310 311 if (items[occupiedPoints[ep.X, ep.Y - 1, ep.Z]].SupportsStacking(item) 312 && items[occupiedPoints[ep.X + item.Width - 1, ep.Y - 1, ep.Z]].SupportsStacking(item) 313 && items[occupiedPoints[ep.X, ep.Y - 1, ep.Z + item.Depth - 1]].SupportsStacking(item) 314 && items[occupiedPoints[ep.X + item.Width - 1, ep.Y - 1, ep.Z + item.Depth - 1]].SupportsStacking(item)) 315 return true; 316 317 //int groundCount = 0; 318 //for (int x = ep.X; x < ep.X + item.Width - 1; x++) { 319 // for (int z = ep.Z; z < ep.Z + item.Depth - 1; z++) { 320 // if (occupiedPoints[x,ep.Y-1, z] != -1) 321 // groundCount++; 322 // } 323 //} 324 //double stableGround = (double)(groundCount) / (double)(item.Width * item.Depth); 325 //if (stableGround > 0.75) 326 // return true; 327 328 return false; 329 } 282 330 public static List<int[, ,]> OccupyPointsForNewItem(List<int[, ,]> occupiedPoints, CuboidPackingItem newItem, ThreeDimensionalPacking position, int itemIndex) { 283 331 int width = position.Rotated ? newItem.Depth : newItem.Width; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ISOContainerMultiComponentVectorDecoder3D.cs
r9495 r9563 40 40 41 41 namespace HeuristicLab.Problems.BinPacking.Decoders { 42 [Item("I dentical bin, three dimensional, extreme points baseddecoder for the MultiComponentVector encoding.", "<Description missing...>")]42 [Item("ISO container decoder for the MultiComponentVector encoding.", "<Description missing...>")] 43 43 [StorableClass] 44 public class ISOContainerMultiComponentVectorDecoder3D : IdenticalBinPackingSolutionDecoder<44 public class ISOContainerMultiComponentVectorDecoder3D : PackingSolutionDecoder< 45 45 ThreeDimensionalPacking, 46 46 CuboidPackingBin, 47 CuboidPackingItem, 48 MultipleBinSizePackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>> { 47 CuboidPackingItem>, I3DMCVDecoder { 49 48 50 49 public ISOContainerMultiComponentVectorDecoder3D () … … 60 59 } 61 60 62 public static MultipleBinSizePackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {61 public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 63 62 64 MultipleBinSizePackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result =65 new MultipleBinSizePackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(new ObservableDictionary<int, CuboidPackingBin>(), itemMeasures);63 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 64 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(new ObservableDictionary<int, CuboidPackingBin>(), itemMeasures); 66 65 67 66 #region Preperations 68 67 int nrOfBins = solution.NrOfBins; 69 70 //Get all indexes of items for every bin according to grouping-vector 68 71 69 Dictionary<int, List<PackingInformation>> unpackedItemIndexesPerBin = new Dictionary<int, List<PackingInformation>>(); 72 Dictionary<int, HashSet<ThreeDimensionalPacking>> extremePointsForBin = new Dictionary<int, HashSet<ThreeDimensionalPacking>>(); 70 Dictionary<int, HashSet<ThreeDimensionalPacking>> extremePointsForBin = new Dictionary<int, HashSet<ThreeDimensionalPacking>>(); 71 ObservableDictionary<int, CuboidPackingBin> resultingBinMeasures = new ObservableDictionary<int, CuboidPackingBin>(); 73 72 var occupiedPoints = new List<int[, ,]>(); 74 73 … … 79 78 extremePointsForBin[i].Add(new ThreeDimensionalPacking(i, 0, 0, 0, false)); 80 79 occupiedPoints = ExtremePointsFunctions3D.IncreaseBinCountForOccupiedPoints(occupiedPoints, binMeasures); 80 resultingBinMeasures[i] = new CuboidPackingBin(binMeasures.Width, binMeasures.Height, binMeasures.Depth); 81 81 } 82 82 … … 95 95 var item = itemMeasures[itemIndex]; 96 96 97 extremePointsForBin[binNr] = ExtremePointsFunctions3D.OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, binMeasures); 98 var positionFound = ExtremePointsFunctions3D.FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 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 99 105 if (positionFound != null) { 100 106 extremePointsForBin[binNr].Remove(positionFound); 101 107 itemPositions[itemIndex] = positionFound; 102 108 occupiedPoints = ExtremePointsFunctions3D.OccupyPointsForNewItem(occupiedPoints, item, positionFound, itemIndex); 103 extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, binMeasures);109 extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, resultingBinMeasures[binNr]); 104 110 } else { 105 111 remainingItems.Add(unpackedItems[i]); 106 //solution.PackingInformations[binNr].Remove(unpackedItems[i]);112 solution.PackingInformations[binNr].Remove(unpackedItems[i]); 107 113 } 108 114 } … … 119 125 var item = itemMeasures[itemIndex]; 120 126 121 extremePointsForBin[binNr] = ExtremePointsFunctions3D.OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, binMeasures); 122 var positionFound = ExtremePointsFunctions3D.FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 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 123 136 if (positionFound != null) { 124 137 extremePointsForBin[binNr].Remove(positionFound); 125 138 itemPositions[itemIndex] = positionFound; 126 139 occupiedPoints = ExtremePointsFunctions3D.OccupyPointsForNewItem(occupiedPoints, item, positionFound, itemIndex); 127 extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, binMeasures);140 extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, resultingBinMeasures[binNr]); 128 141 remainingItems.Remove(unpackedItems[i]); 129 //solution.PackingInformations[binNr].Add(unpackedItems[i]);142 solution.PackingInformations[binNr].Add(unpackedItems[i]); 130 143 } 131 144 } … … 134 147 extremePointsForBin[nrOfBins].Add(new ThreeDimensionalPacking(nrOfBins, 0, 0, 0, false)); 135 148 occupiedPoints = ExtremePointsFunctions3D.IncreaseBinCountForOccupiedPoints(occupiedPoints, binMeasures); 136 //solution.PackingInformations[nrOfBins] = new ItemList<PackingInformation>(); 149 resultingBinMeasures[nrOfBins] = new CuboidPackingBin(binMeasures.Width, binMeasures.Height, binMeasures.Depth); 150 solution.PackingInformations[nrOfBins] = new ItemList<PackingInformation>(); 137 151 nrOfBins++; 138 152 } 139 153 } 140 154 141 return itemPositions; 142 143 155 result.PackingItemPositions = itemPositions; 156 result.PackingBinMeasures = resultingBinMeasures; 144 157 return result; 145 158 } 146 159 147 protected override MultipleBinSizePackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IPackingSolutionEncoding encodedSolution) { 160 private static List<int[, ,]> DoubleDepthForBinNr(List<int[, ,]> occupiedPoints, ref ObservableDictionary<int, CuboidPackingBin> binMeasures, int binNr) { 161 var oldDepth = binMeasures[binNr].Depth; 162 binMeasures[binNr].Depth = binMeasures[binNr].Depth * 2; 163 var newBinOccupation = new int[binMeasures[binNr].Width, binMeasures[binNr].Height, binMeasures[binNr].Depth]; 164 for (int w = 0; w < binMeasures[binNr].Width; w++) { 165 for (int h = 0; h < binMeasures[binNr].Height; h++) { 166 for (int d = 0; d < binMeasures[binNr].Depth; d++) { 167 if (d < oldDepth) 168 newBinOccupation[w, h, d] = occupiedPoints[binNr][w, h, d]; 169 else 170 newBinOccupation[w, h, d] = -1; 171 } 172 } 173 } 174 175 occupiedPoints[binNr] = newBinOccupation; 176 return occupiedPoints; 177 } 178 179 180 181 182 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 148 183 149 184 var solution = encodedSolution as MultiComponentVectorEncoding; 150 185 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector"); 151 186 152 return Decode(solution, PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);187 return Decode(solution, binMeasures, itemMeasures); 153 188 } 154 189 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/PackingSolutionDecoder.cs
r9495 r9563 47 47 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 48 48 } 49 p ublicILookupParameter<ItemList<I>> PackingItemMeasuresParameter {49 private ILookupParameter<ItemList<I>> PackingItemMeasuresParameter { 50 50 get { return (LookupParameter<ItemList<I>>)Parameters["PackingItemMeasures"]; } 51 51 } 52 p ublicILookupParameter<B> PackingBinMeasuresParameter {52 private ILookupParameter<B> PackingBinMeasuresParameter { 53 53 get { return (LookupParameter<B>)Parameters["PackingBinMeasures"]; } 54 54 } 55 public ILookupParameter<I PackingSolutionEncoding> EncodedSolutionParameter {56 get { return (ILookupParameter<I PackingSolutionEncoding>)Parameters["EncodedSolution"]; }55 public ILookupParameter<IItem> EncodedSolutionParameter { 56 get { return (ILookupParameter<IItem>)Parameters["EncodedSolution"]; } 57 57 } 58 58 public ILookupParameter<PackingPlan<D,B,I>> PackingPlanParameter { … … 62 62 63 63 public PackingSolutionDecoder() : base() { 64 Parameters.Add(new LookupParameter<I PackingSolutionEncoding>("EncodedSolution", "The new bin-packing solution represented as encoding."));64 Parameters.Add(new LookupParameter<IItem>("EncodedSolution", "The new bin-packing solution represented as encoding.")); 65 65 Parameters.Add(new LookupParameter<PackingPlan<D, B, I>>("PackingPlan", "The decoded bin-packing solution represented as generalized packing plan.")); 66 66 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); … … 75 75 } 76 76 77 public abstract PackingPlan<D, B, I> CreatePackingPlanFromEncoding(I PackingSolutionEncodingsolution, B binMeasures, ItemList<I> itemMeasures);77 public abstract PackingPlan<D, B, I> CreatePackingPlanFromEncoding(IItem solution, B binMeasures, ItemList<I> itemMeasures); 78 78 79 79 public override IOperation Apply() { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/GroupingVectorCrossover.cs
r9348 r9563 30 30 [Item("Grouping Vector Crossover", "An operator which crosses two GroupingVector representations.")] 31 31 [StorableClass] 32 public class GroupingVectorCrossover : PackingSolutionCrossover, IGroupingVectorOperator {32 public abstract class GroupingVectorCrossover : PackingSolutionCrossover, IGroupingVectorOperator { 33 33 34 34 [StorableConstructor] … … 40 40 ChildParameter.ActualName = "GroupingVector"; 41 41 } 42 public override IDeepCloneable Clone(Cloner cloner) {43 return new GroupingVectorCrossover(this, cloner);44 }45 42 46 public GroupingVectorEncoding Cross(IRandom random, GroupingVectorEncoding parent1, GroupingVectorEncoding parent2) { 47 GroupingVectorEncoding result = new GroupingVectorEncoding(); 48 result.GroupingVector = SinglePointCrossover.Apply(random, parent1.GroupingVector, parent2.GroupingVector); 49 return result; 50 } 43 public abstract GroupingVectorEncoding Cross(IRandom random, GroupingVectorEncoding parent1, GroupingVectorEncoding parent2); 51 44 52 45 public override IOperation Apply() { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/GroupingVectorRandomCreator.cs
r9440 r9563 68 68 } 69 69 70 protected override I PackingSolutionEncodingCreateSolution() {70 protected override IItem CreateSolution() { 71 71 return Apply(PackingItemsParameter.ActualValue.Value, LowerBoundParameter.ActualValue.Value, RandomParameter.ActualValue); 72 72 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/MultiComponentVectorEncoding.cs
r9495 r9563 46 46 return nrOfItems; 47 47 } 48 } 48 } 49 49 50 50 [StorableConstructor] … … 64 64 : base() { 65 65 PackingInformations = new ObservableDictionary<int, ItemList<PackingInformation>>(); 66 } 66 } 67 67 68 68 public override string ToString() { … … 95 95 return PackingInformations.GetHashCode(); 96 96 } 97 97 98 } 98 99 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/MultiComponentVectorRandomCreator.cs
r9495 r9563 76 76 } 77 77 78 protected override I PackingSolutionEncodingCreateSolution() {78 protected override IItem CreateSolution() { 79 79 return Apply(PackingItemsParameter.ActualValue.Value, LowerBoundParameter.ActualValue.Value, RandomParameter.ActualValue, SortedSequenceParameter.Value.Value); 80 80 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs
r9495 r9563 35 35 36 36 namespace HeuristicLab.Encodings.PackingEncoding.PackingPlan { 37 //RegularPackingPlan defines that the packingItems have to be parallel to the packingBin in every moment38 //SimpleRotation defines that the items may be rotated39 // only in one dimension,40 // only once and41 // only by 90degree42 // so that parallelism to the correlating bin is ensured43 //This definition implies that the floor of the (3D) objects never changes (what may be a wanted constraint in most cases..)44 37 [Item("PackingPlan", "Represents a concrete solution for a bin-packing problem.")] 45 38 [StorableClass] … … 85 78 public PackingPlan(B binMeasures, ItemList<I> itemMeasures) 86 79 : base() { 87 this.PackingItemMeasures = itemMeasures;80 this.PackingItemMeasures = new ItemList<I> (itemMeasures); 88 81 this.PackingBinMeasures = new ObservableDictionary<int, B>(); 89 82 this.PackingBinMeasures[0] = binMeasures; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceCrossover.cs
r9348 r9563 29 29 [Item("PackingSequenceCrossover", "An operator which crosses two PackingSequence representations.")] 30 30 [StorableClass] 31 public class PackingSequenceCrossover : PackingSolutionCrossover, IPackingSequenceOperator {31 public abstract class PackingSequenceCrossover : PackingSolutionCrossover, IPackingSequenceOperator { 32 32 33 33 [StorableConstructor] … … 39 39 ChildParameter.ActualName = "PackingSequence"; 40 40 } 41 public override IDeepCloneable Clone(Cloner cloner) {42 return new PackingSequenceCrossover(this, cloner);43 }44 41 45 public PackingSequenceEncoding Cross(IRandom random, PackingSequenceEncoding parent1, PackingSequenceEncoding parent2) { 46 PackingSequenceEncoding result = new PackingSequenceEncoding(); 47 result.PackingSequence = CosaCrossover.Apply(random, parent1.PackingSequence, parent2.PackingSequence); 48 return result; 49 } 42 public abstract PackingSequenceEncoding Cross(IRandom random, PackingSequenceEncoding parent1, PackingSequenceEncoding parent2); 50 43 51 44 public override IOperation Apply() { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceEncoding.cs
r9348 r9563 30 30 [Item("Packing Sequence Encoding", "Represents an encoding for a bin packing problem using permutation of item-indexes to define the packing sequence.")] 31 31 [StorableClass] 32 public class PackingSequenceEncoding : Item, IPackingSolutionEncoding {32 public class PackingSequenceEncoding : Item, IPackingSolutionEncoding { 33 33 34 34 [Storable] … … 39 39 protected PackingSequenceEncoding(PackingSequenceEncoding original, Cloner cloner) 40 40 : base(original, cloner) { 41 41 this.PackingSequence = cloner.Clone(original.PackingSequence); 42 42 } 43 43 public override IDeepCloneable Clone(Cloner cloner) { … … 53 53 StringBuilder sb = new StringBuilder(); 54 54 sb.Append("[ "); 55 sb.Append(PackingSequence.ToString() + " \n"); 55 sb.Append(PackingSequence.ToString() + " \n"); 56 56 sb.Append("]"); 57 57 return sb.ToString(); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceManipulator.cs
r9348 r9563 30 30 [Item("PackingSequenceManipulator", "An operator which manipulates a PackingSequence representation.")] 31 31 [StorableClass] 32 public class PackingSequenceManipulator : PackingSolutionManipulator, IPackingSequenceOperator {32 public abstract class PackingSequenceManipulator : PackingSolutionManipulator, IPackingSequenceOperator { 33 33 [StorableConstructor] 34 34 protected PackingSequenceManipulator(bool deserializing) : base(deserializing) { } … … 38 38 EncodedSolutionParameter.ActualName = "PackingSequence"; 39 39 } 40 public override IDeepCloneable Clone(Cloner cloner) {41 return new PackingSequenceManipulator(this, cloner);42 }43 40 44 protected void Manipulate(IRandom random, PackingSequenceEncoding individual) { 45 Swap2Manipulator.Apply(random, individual.PackingSequence); 46 } 41 protected abstract void Manipulate(IRandom random, PackingSequenceEncoding individual); 47 42 48 43 public override IOperation Apply() { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceRandomCreator.cs
r9348 r9563 60 60 public static PackingSequenceEncoding Apply(int items, IRandom random) { 61 61 var solution = new PackingSequenceEncoding(); 62 63 64 62 solution.PackingSequence = new Permutation(PermutationTypes.Absolute, items, random); 63 return solution; 64 } 65 65 66 protected override I PackingSolutionEncodingCreateSolution() {66 protected override IItem CreateSolution() { 67 67 return Apply(PackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue); 68 68 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSolutionCreator.cs
r9348 r9563 32 32 public abstract class PackingSolutionCreator : SingleSuccessorOperator, IPackingSolutionCreator { 33 33 34 public ILookupParameter<I PackingSolutionEncoding> EncodedSolutionParameter {35 get { return (ILookupParameter<I PackingSolutionEncoding>)Parameters["EncodedPackingSolution"]; }34 public ILookupParameter<IItem> EncodedSolutionParameter { 35 get { return (ILookupParameter<IItem>)Parameters["EncodedPackingSolution"]; } 36 36 } 37 37 … … 41 41 public PackingSolutionCreator() 42 42 : base() { 43 Parameters.Add(new LookupParameter<I PackingSolutionEncoding>("EncodedPackingSolution", "The new bin packing solution candidate."));43 Parameters.Add(new LookupParameter<IItem>("EncodedPackingSolution", "The new bin packing solution candidate.")); 44 44 } 45 45 … … 49 49 } 50 50 51 protected abstract I PackingSolutionEncodingCreateSolution();51 protected abstract IItem CreateSolution(); 52 52 } 53 53 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/Abstract/BinUtilizationRegularIdenticalBinEvaluator.cs
r9495 r9563 66 66 67 67 //if (itemPositionsAreValid) 68 return CalculateBinUtilization(plan as SingleBinSizePackingPlan<D, B, I>, binMeasure, itemMeasures);68 return CalculateBinUtilization(plan as PackingPlan<D, B, I>); 69 69 70 70 //return quality; 71 71 } 72 72 73 public static DoubleValue CalculateBinUtilization( SingleBinSizePackingPlan<D, B, I> plan, B binMeasure, ItemList<I> itemMeasures) {73 public static DoubleValue CalculateBinUtilization(PackingPlan<D, B, I> plan) { 74 74 int nrOfBins = plan.NrOfBins; 75 75 double result = 0; 76 76 77 double usableSpace = binMeasure.MultipliedMeasures; 77 //for (int i = 0; i < nrOfBins; i++) { 78 // double usableSpace = plan.GetPackingBinMeasuresForBinNr(i).MultipliedMeasures; 79 // var indexes = plan.PackingItemPositions.Select((Value, Index) => new { Value, Index }).Where(s => s.Value.Value.AssignedBin == i).Select(s => s.Index); 80 // var packedItemsInThisBin = plan.PackingItemMeasures.Select((Value, Index) => new { Value, Index }).Where(s => indexes.Contains(s.Index)); 81 // double usedSpaceInThisBin = packedItemsInThisBin.Select(s => s.Value.MultipliedMeasures).Sum(); 82 // result += (usedSpaceInThisBin / usableSpace); 83 //} 84 85 //result = result / nrOfBins; 86 //return new DoubleValue (result); 87 88 double totalUsedSpace = 0; 89 double totalUsableSpace = 0; 90 78 91 for (int i = 0; i < nrOfBins; i++) { 92 double usableSpace = plan.GetPackingBinMeasuresForBinNr(i).MultipliedMeasures; 79 93 var indexes = plan.PackingItemPositions.Select((Value, Index) => new { Value, Index }).Where(s => s.Value.Value.AssignedBin == i).Select(s => s.Index); 80 var packedItemsInThisBin = itemMeasures.Select((Value, Index) => new { Value, Index }).Where(s => indexes.Contains(s.Index));94 var packedItemsInThisBin = plan.PackingItemMeasures.Select((Value, Index) => new { Value, Index }).Where(s => indexes.Contains(s.Index)); 81 95 double usedSpaceInThisBin = packedItemsInThisBin.Select(s => s.Value.MultipliedMeasures).Sum(); 82 result += (usedSpaceInThisBin / usableSpace); 96 //result += (usedSpaceInThisBin / usableSpace); 97 totalUsableSpace += usableSpace; 98 totalUsedSpace += usedSpaceInThisBin; 83 99 } 84 100 85 result = result / nrOfBins;86 return new DoubleValue 101 result = totalUsedSpace / totalUsableSpace; 102 return new DoubleValue(result); 87 103 } 88 104 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/Abstract/PackingRatioRegularIdenticalBinEvaluator.cs
r9473 r9563 66 66 67 67 //if (itemPositionsAreValid) 68 return CalculatePackingRatio(plan as PackingPlan<D, B, I> , binMeasure, itemMeasures);68 return CalculatePackingRatio(plan as PackingPlan<D, B, I>); 69 69 70 70 //return quality; … … 80 80 k.......a constant, k>1. 81 81 */ 82 public static DoubleValue CalculatePackingRatio(PackingPlan<D, B, I> plan , B binMeasure, ItemList<I> itemMeasures) {82 public static DoubleValue CalculatePackingRatio(PackingPlan<D, B, I> plan) { 83 83 int nrOfBins = plan.NrOfBins; 84 84 double result = 0; 85 85 86 86 //C 87 double usableSpace = binMeasure.MultipliedMeasures;87 //double usableSpace = binMeasure.MultipliedMeasures; 88 88 //nrOfBins = N 89 89 for (int i = 0; i < nrOfBins; i++) { 90 //C 91 double usableSpace = plan.GetPackingBinMeasuresForBinNr(0).MultipliedMeasures;//plan.GetPackingBinMeasuresForBinNr(i).MultipliedMeasures; 90 92 var indexes = plan.PackingItemPositions.Select((Value, Index) => new { Value, Index }).Where(s => s.Value.Value.AssignedBin == i).Select(s => s.Index); 91 var packedItemsInThisBin = itemMeasures.Select((Value, Index) => new { Value, Index }).Where(s => indexes.Contains(s.Index));93 var packedItemsInThisBin = plan.PackingItemMeasures.Select((Value, Index) => new { Value, Index }).Where(s => indexes.Contains(s.Index)); 92 94 //Fi 93 95 double usedSpaceInThisBin = packedItemsInThisBin.Select(s => s.Value.MultipliedMeasures).Sum(); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj
r9495 r9563 181 181 <Compile Include="Decoders\3D\DBL\DeepestBottomLeftPackingSequenceDecoder.cs" /> 182 182 <Compile Include="Decoders\2D\BL\BottomLeftPackingSequenceDecoder.cs" /> 183 <Compile Include="Decoders\3D\EP\ISOContainerMultiComponentVectorDecoder3D.cs" /> 183 184 <Compile Include="Decoders\PackingSolutionDecoder.cs" /> 184 <Compile Include="Encodings\GroupingVector\Moves\SingleGrouping\SingleGroupingMoveSoftTabuCriterion.cs" /> 185 <Compile Include="Encodings\GroupingVector\Moves\SingleGrouping\ExhaustiveSingleGroupingMoveGenerator.cs" /> 186 <Compile Include="Encodings\GroupingVector\Moves\SingleGrouping\SingleGroupingMove.cs" /> 187 <Compile Include="Encodings\GroupingVector\Moves\SingleGrouping\SingleGroupingMoveAttribute.cs" /> 188 <Compile Include="Encodings\GroupingVector\Moves\SingleGrouping\SingleGroupingMoveGenerator.cs" /> 189 <Compile Include="Encodings\GroupingVector\Moves\SingleGrouping\SingleGroupingMoveMaker.cs" /> 190 <Compile Include="Encodings\GroupingVector\Moves\SingleGrouping\SingleGroupingTabuMaker.cs" /> 191 <Compile Include="Encodings\GroupingVector\Moves\SingleGrouping\SingleGroupingMoveHardTabuCriterion.cs" /> 192 <Compile Include="Encodings\GroupingVector\Moves\SingleGrouping\StochasticSingleGroupingMoveGenerator.cs" /> 193 <Compile Include="Encodings\GroupingVector\UniformGroupingVectorManipulator.cs" /> 185 <Compile Include="Encodings\GroupingVector\GroupingVectorSwap2Manipulator.cs" /> 186 <Compile Include="Encodings\GroupingVector\GroupingVectorSinglePointCrossover.cs" /> 187 <Compile Include="Encodings\GroupingVector\GroupingVectorDiscreteCrossover.cs" /> 188 <Compile Include="Encodings\GroupingVector\Moves\GroupingMove.cs" /> 189 <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveAttribute.cs" /> 190 <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\ExhaustiveSwapGroupingMoveGenerator.cs" /> 191 <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\SwapGroupingMove.cs" /> 192 <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\SwapGroupingMoveAttribute.cs" /> 193 <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\SwapGroupingMoveGenerator.cs" /> 194 <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveMaker.cs" /> 195 <Compile Include="Encodings\GroupingVector\Moves\GroupingTabuMaker.cs" /> 196 <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\StochasticSwapGroupingMoveGenerator.cs" /> 197 <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveSoftTabuCriterion.cs" /> 198 <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ExhaustiveChangeGroupingMoveGenerator.cs" /> 199 <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ChangeGroupingMove.cs" /> 200 <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ChangeGroupingMoveAttribute.cs" /> 201 <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ChangeGroupingMoveGenerator.cs" /> 202 <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveHardTabuCriterion.cs" /> 203 <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\StochasticChangeGroupingMoveGenerator.cs" /> 204 <Compile Include="Encodings\GroupingVector\GroupingVectorOnePositionManipulator.cs" /> 194 205 <Compile Include="Encodings\GroupingVector\GroupingVectorCrossover.cs" /> 195 206 <Compile Include="Encodings\GroupingVector\GroupingVectorEncoding.cs" /> 196 207 <Compile Include="Encodings\GroupingVector\GroupingVectorManipulator.cs" /> 197 208 <Compile Include="Encodings\GroupingVector\GroupingVectorRandomCreator.cs" /> 198 <Compile Include="Encodings\MultiComponentVector\SequencePreservingMultiComponentVectorCrossover.cs" /> 199 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Attributes\ChangePositionMoveAttribute.cs" /> 200 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Attributes\MCVTripleMoveAttribute.cs" /> 201 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Attributes\SwapPositionMoveAttribute.cs" /> 202 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Attributes\SingleGroupingMoveAttribute.cs" /> 203 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Attributes\MultiComponentVectorMoveAttribute.cs" /> 204 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Attributes\SingleItemRotationMoveAttribute.cs" /> 205 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\StochasticMCVTripleMoveGenerator.cs" /> 206 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\ExhaustiveMCVTripleMoveGenerator.cs" /> 207 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Moves\ChangePositionMove.cs" /> 208 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Moves\MCVTripleMove.cs" /> 209 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\MultiComponentVectorMoveHardTabuCriterion.cs" /> 210 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Moves\MultiComponentVectorMove.cs" /> 211 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Moves\SwapPositionMove.cs" /> 212 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Moves\SingleItemRotationMove.cs" /> 213 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\ExhaustiveMultiComponentVectorMoveGenerator.cs" /> 214 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\Moves\SingleGroupingMove.cs" /> 215 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\MultiComponentVectorMoveGenerator.cs" /> 216 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\MultiComponentVectorMoveSoftTabuCriterion.cs" /> 217 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\MultiComponentVectorMoveMaker.cs" /> 218 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\MultiComponentVectorTabuMaker.cs" /> 219 <Compile Include="Encodings\MultiComponentVector\Moves\ThreeWay\StochasticMultiComponentVectorMoveGenerator.cs" /> 209 <Compile Include="Encodings\MultiComponentVector\BinBasedMultiComponentVectorCrossover.cs" /> 210 <Compile Include="Encodings\MultiComponentVector\SequenceBasedMultiComponentVectorCrossover.cs" /> 211 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\ChangePositionMoveAttribute.cs" /> 212 <Compile Include="Encodings\MultiComponentVector\Moves\Triple\Attributes\MCVTripleMoveAttribute.cs" /> 213 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\SwapPositionMoveAttribute.cs" /> 214 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\SingleGroupingMoveAttribute.cs" /> 215 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveAttribute.cs" /> 216 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\SingleItemRotationMoveAttribute.cs" /> 217 <Compile Include="Encodings\MultiComponentVector\Moves\Triple\StochasticMCVTripleMoveGenerator.cs" /> 218 <Compile Include="Encodings\MultiComponentVector\Moves\Triple\ExhaustiveMCVTripleMoveGenerator.cs" /> 219 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\ChangePositionMove.cs" /> 220 <Compile Include="Encodings\MultiComponentVector\Moves\Triple\Moves\MCVTripleMove.cs" /> 221 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveHardTabuCriterion.cs" /> 222 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMove.cs" /> 223 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\SwapPositionMove.cs" /> 224 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\SingleItemRotationMove.cs" /> 225 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\ExhaustiveMultiComponentVectorMoveGenerator.cs" /> 226 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\SingleGroupingMove.cs" /> 227 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveGenerator.cs" /> 228 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveSoftTabuCriterion.cs" /> 229 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveMaker.cs" /> 230 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorTabuMaker.cs" /> 231 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\StochasticMultiComponentVectorMoveGenerator.cs" /> 220 232 <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorEncoding.cs"> 221 233 <SubType>Code</SubType> … … 226 238 <Compile Include="Encodings\MultiComponentVector\ThreeWayMultiComponentVectorManipulator.cs" /> 227 239 <Compile Include="Encodings\PackingPlans\PackingPlan.cs" /> 228 <Compile Include="Encodings\PackingSequence\PackingSequenceCrossover.cs" /> 229 <Compile Include="Encodings\PackingSequence\PackingSequenceManipulator.cs" /> 230 <Compile Include="Encodings\PackingSequence\PackingSequenceEncoding.cs" /> 240 <Compile Include="Encodings\PackingSequence\Moves\Insertion\ExhaustiveInsertionMoveGenerator.cs" /> 241 <Compile Include="Encodings\PackingSequence\Moves\Insertion\StochasticInsertionMoveGenerator.cs" /> 242 <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMove.cs" /> 243 <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMoveAttribute.cs" /> 244 <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMoveGenerator.cs" /> 245 <Compile Include="Encodings\PackingSequence\PackingSequenceInsertionManipulator.cs" /> 246 <Compile Include="Encodings\PackingSequence\PackingSequenceSwap2Manipulator.cs" /> 247 <Compile Include="Encodings\PackingSequence\PackingSequencePartiallyMatchedCrossover.cs" /> 248 <Compile Include="Encodings\PackingSequence\PackingSequenceOrderCrossover.cs" /> 249 <Compile Include="Encodings\PackingSequence\Moves\SequenceMove.cs" /> 250 <Compile Include="Encodings\PackingSequence\Moves\SequenceMoveAttribute.cs" /> 251 <Compile Include="Encodings\PackingSequence\Moves\GroupingMoveHardTabuCriterion.cs" /> 252 <Compile Include="Encodings\PackingSequence\Moves\GroupingMoveMaker.cs" /> 253 <Compile Include="Encodings\PackingSequence\Moves\GroupingMoveSoftTabuCriterion.cs" /> 254 <Compile Include="Encodings\PackingSequence\Moves\SequenceTabuMaker.cs" /> 255 <Compile Include="Encodings\PackingSequence\Moves\Swap2\ExhaustiveSwap2MoveGenerator.cs" /> 256 <Compile Include="Encodings\PackingSequence\Moves\Swap2\StochasticSwap2MoveGenerator.cs" /> 257 <Compile Include="Encodings\PackingSequence\Moves\Swap2\Swap2Move.cs" /> 258 <Compile Include="Encodings\PackingSequence\Moves\Swap2\Swap2MoveAttribute.cs" /> 259 <Compile Include="Encodings\PackingSequence\Moves\Swap2\Swap2MoveGenerator.cs" /> 260 <Compile Include="Encodings\PackingSequence\PackingSequenceCrossover.cs"> 261 <SubType>Code</SubType> 262 </Compile> 263 <Compile Include="Encodings\PackingSequence\PackingSequenceEncoding.cs"> 264 <SubType>Code</SubType> 265 </Compile> 266 <Compile Include="Encodings\PackingSequence\PackingSequenceManipulator.cs"> 267 <SubType>Code</SubType> 268 </Compile> 231 269 <Compile Include="Encodings\PackingSequence\PackingSequenceRandomCreator.cs" /> 232 270 <Compile Include="Encodings\PackingSolutionCreator.cs" /> … … 235 273 <Compile Include="Evaluators\2D\PackingRatioRectangularIdenticalBinEvaluator.cs" /> 236 274 <Compile Include="Evaluators\3D\PackingRatioCuboidIdenticalBinEvaluator.cs" /> 275 <Compile Include="Evaluators\Abstract\BinUtilizationRegularIdenticalBinEvaluator.cs" /> 237 276 <Compile Include="Evaluators\Abstract\PackingRatioRegularIdenticalBinEvaluator.cs" /> 238 277 <Compile Include="Evaluators\Abstract\RegularSimpleRotationIdenticalBinPackingPlanEvaluator.cs" /> … … 245 284 <Compile Include="Instances\BPPORLIBParser.cs" /> 246 285 <Compile Include="Instances\BPPORLIBDataDescriptor.cs" /> 286 <Compile Include="Instances\RealBPPData.cs" /> 287 <Compile Include="Interfaces\DecoderInterfaces\I2DMCVDecoder.cs" /> 288 <Compile Include="Interfaces\DecoderInterfaces\I3DMCVDecoder.cs" /> 289 <Compile Include="Interfaces\DecoderInterfaces\I2DGVDecoder.cs" /> 290 <Compile Include="Interfaces\DecoderInterfaces\I3DGVDecoder.cs" /> 291 <Compile Include="Interfaces\DecoderInterfaces\I2DPSDecoder.cs" /> 292 <Compile Include="Interfaces\DecoderInterfaces\I3DPSDecoder.cs" /> 293 <Compile Include="Interfaces\IPackingSequenceMoveOperator.cs" /> 247 294 <Compile Include="Interfaces\I3DOperator.cs" /> 248 295 <Compile Include="Interfaces\I2DOperator.cs" /> … … 265 312 <Compile Include="Interfaces\IPackingShape.cs" /> 266 313 <Compile Include="Interfaces\IPackingDimensions.cs" /> 314 <Compile Include="MoveEvaluators\PackingMoveEvaluator2DPS.cs" /> 315 <Compile Include="MoveEvaluators\PackingMoveEvaluator3DPS.cs" /> 267 316 <Compile Include="MoveEvaluators\PackingMoveEvaluator.cs" /> 268 317 <Compile Include="MoveEvaluators\PackingMoveEvaluator2DGV.cs"> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingItem.cs
r9348 r9563 30 30 public interface IPackingItem : IPackingShape { 31 31 void AddTargetBinMeasures(int[] targetBinMeasures); 32 double Weight { get; set; } 33 int Material { get; set; } 34 /// <summary> 35 /// Returns if the "other" item can be stacked on this item. 36 /// </summary> 37 /// <param name="other"></param> 38 /// <returns></returns> 39 bool SupportsStacking (IPackingItem other); 32 40 } 33 41 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingSolutionCreator.cs
r9348 r9563 29 29 namespace HeuristicLab.Problems.BinPacking.Interfaces { 30 30 public interface IPackingSolutionCreator : ISolutionCreator{ 31 ILookupParameter<I PackingSolutionEncoding> EncodedSolutionParameter { get; }31 ILookupParameter<IItem> EncodedSolutionParameter { get; } 32 32 } 33 33 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/MoveEvaluators/PackingMoveEvaluator.cs
r9495 r9563 98 98 CurrentScopeParameter.ActualValue.Variables.Add(new Variable("PackingPlanAfterMove", packingPlan)); 99 99 100 DoubleValue quality = PackingRatioRegularIdenticalBinEvaluator<D, B, I>.CalculatePackingRatio( 101 packingPlan, PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue); 100 DoubleValue quality = PackingRatioRegularIdenticalBinEvaluator<D, B, I>.CalculatePackingRatio(packingPlan); 102 101 103 102 double moveQuality = quality.Value; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingItem/CuboidPackingItem.cs
r9348 r9563 38 38 39 39 public CuboidPackingBin TargetBin { get; set; } 40 public double Weight { get; set; } 41 public int Material { get; set; } 42 public bool SupportsStacking(IPackingItem other) { 43 return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight)); 44 } 40 45 41 46 [StorableConstructor] … … 43 48 protected CuboidPackingItem(CuboidPackingItem original, Cloner cloner) 44 49 : base(original, cloner) { 50 this.Weight = original.Weight; 51 this.Material = original.Material; 45 52 } 46 53 public override IDeepCloneable Clone(Cloner cloner) { … … 51 58 } 52 59 60 public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin, double weight, int material) : this(width, height, depth, targetBin) { this.Weight = weight; this.Material = material; } 53 61 public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin) : base(width, height, depth) { this.TargetBin = new CuboidPackingBin(targetBin.Width, targetBin.Height, targetBin.Depth); } 54 62 … … 56 64 TargetBin = new CuboidPackingBin(targetBinMeasures[0], targetBinMeasures[1], targetBinMeasures[2]); 57 65 } 66 67 public override string ToString() { 68 return String.Format("CuboidPackingItem ({0}, {1}, {2}; w={3}, m={4})", this.Width, this.Height, this.Depth, this.Weight,this.Material); 69 } 58 70 } 59 71 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingItem/RectangularPackingItem.cs
r9348 r9563 37 37 public class RectangularPackingItem : RectangularPackingShape, IPackingItem{ 38 38 39 public RectangularPackingBin TargetBin { get; set; } 39 public RectangularPackingBin TargetBin { get; set; } 40 public double Weight { get; set; } 41 public int Material { get; set; } 42 public bool SupportsStacking(IPackingItem other) { 43 return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight)); 44 } 40 45 41 46 [StorableConstructor] … … 43 48 protected RectangularPackingItem(RectangularPackingItem original, Cloner cloner) 44 49 : base(original, cloner) { 50 this.Weight = original.Weight; 51 this.Material = original.Material; 45 52 } 46 53 public override IDeepCloneable Clone(Cloner cloner) { … … 48 55 } 49 56 public RectangularPackingItem() : base() { 50 51 57 } 52 58 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs
r9495 r9563 26 26 /// Plugin class for HeuristicLab.Problems.BinPacking plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.94 73")]28 [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.9495")] 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/Problem/CuboidIdenticalBinPackingProblem.cs
r9495 r9563 44 44 using HeuristicLab.Problems.Instances; 45 45 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 46 using HeuristicLab.PluginInfrastructure; 46 47 47 48 namespace HeuristicLab.Problems.BinPacking.Problem { … … 112 113 } 113 114 public CuboidIdenticalBinPackingProblem() : base( 114 new PackingPlanEvaluationAlgorithm<P ackingSequenceEncoding, ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>()) {115 new PackingPlanEvaluationAlgorithm<Permutation, ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>()) { 115 116 } 116 117 … … 121 122 Operators.RemoveAll(op => typeof(I2DOperator).IsAssignableFrom(op.GetType())); 122 123 123 if (SolutionCreator is PackingSequenceRandomCreator) { 124 PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder3D(); 125 } else if (SolutionCreator is GroupingVectorRandomCreator) { 126 PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder3D(); 127 } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 128 PackingSolutionDecoder = new ExtremePointMultiComponentVectorDecoder3D(); 124 PackingSolutionDecoderParameter.ValidValues.Clear(); 125 if (SolutionCreator is PackingSequenceRandomCreator) { 126 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DPSDecoder>()); 127 //PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder3D(); 128 } else if (SolutionCreator is GroupingVectorRandomCreator) { 129 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DGVDecoder>()); 130 //PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder3D(); 131 } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 132 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DMCVDecoder>()); 133 //PackingSolutionDecoder = ApplicationManager.Manager.GetInstances<ExtremePointMultiComponentVectorDecoder3D>().First(); 129 134 } else { 130 135 string error = "The given problem does not support the selected solution-creator."; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/ISOContainerBinPackingProblem.cs
r9495 r9563 49 49 [StorableClass] 50 50 [Creatable("Problems")] 51 public class ISOContainerBinPackingProblem : RegularIdenticalBinPackingProblem<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> { 51 public class ISOContainerBinPackingProblem : CuboidIdenticalBinPackingProblem { 52 52 53 53 54 #region Default Instance 54 private static readonly BPPData DefaultInstance = newBPPData() {55 Name = "3D BPP Default Instance",56 Description = "The default instance for 3D Bin Packing .",55 private static readonly RealBPPData DefaultInstance = new RealBPPData() { 56 Name = "3D BPP with weigthed items Default Instance", 57 Description = "The default instance for 3D Bin Packing Problem with weighted items.", 57 58 BinMeasures = new int[] {25,25,35}, 58 59 ItemMeasures = new int[][] { … … 99 100 new int[] {9,11,9} 100 101 }, 101 Items = 30 102 Items = 30, 103 ItemWeights = new double[] { 104 12*5*10, 105 10*18*20, 106 9*7*7, 107 21*12*4, 108 8*8*12, 109 3*6*14, 110 20*4*9, 111 5*9*8, 112 7*17*3, 113 13*20*15, 114 9*11*9, 115 10*18*20, 116 9*7*7, 117 21*12*4, 118 8*8*12, 119 3*6*14, 120 20*4*9, 121 5*9*8, 122 7*17*3, 123 13*20*15, 124 9*11*9, 125 10*18*20, 126 9*7*7, 127 21*12*4, 128 8*8*12, 129 3*6*14, 130 20*4*9, 131 5*9*8, 132 7*17*3, 133 13*20*15, 134 9*11*9 135 }, 136 ItemMaterials = new int[] { 137 1, 138 0, 139 0, 140 1, 141 0, 142 0, 143 1, 144 1, 145 0, 146 1, 147 1, 148 0, 149 0, 150 1, 151 0, 152 0, 153 1, 154 1, 155 0, 156 1, 157 1, 158 0, 159 0, 160 1, 161 0, 162 0, 163 1, 164 1, 165 0, 166 1, 167 1, 168 169 } 102 170 }; 103 171 #endregion … … 111 179 return new ISOContainerBinPackingProblem(this, cloner); 112 180 } 113 public ISOContainerBinPackingProblem() : base(114 new PackingPlanEvaluationAlgorithm<PackingSequenceEncoding, ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>()) {181 public ISOContainerBinPackingProblem() 182 : base() { 115 183 } 116 184 … … 119 187 #region Helpers 120 188 protected override void InitializeDecoder() { 121 if (SolutionCreator is PackingSequenceRandomCreator) { 122 PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder3D(); 123 } else if (SolutionCreator is GroupingVectorRandomCreator) { 124 PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder3D(); 125 } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 126 PackingSolutionDecoder = new ExtremePointMultiComponentVectorDecoder3D(); 189 Operators.RemoveAll(op => typeof(I2DOperator).IsAssignableFrom(op.GetType())); 190 191 PackingSolutionDecoderParameter.ValidValues.Clear(); 192 if (SolutionCreator is MultiComponentVectorRandomCreator) { 193 PackingSolutionDecoderParameter.ValidValues.Add(new ISOContainerMultiComponentVectorDecoder3D()); 127 194 } else { 128 195 string error = "The given problem does not support the selected solution-creator."; … … 131 198 } 132 199 133 protected override IPackingPlanEvaluator CreateDefaultEvaluator() {134 return new PackingRatioCuboidIdenticalBinEvaluator();135 }136 137 200 protected override void InitializeProblemData() { 138 201 Load(DefaultInstance); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/RectangularIdenticalBinPackingProblem.cs
r9495 r9563 108 108 } 109 109 public RectangularIdenticalBinPackingProblem() : base( 110 new PackingPlanEvaluationAlgorithm<P ackingSequenceEncoding, TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>()) {110 new PackingPlanEvaluationAlgorithm<Permutation, TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>()) { 111 111 } 112 112 … … 116 116 Operators.RemoveAll(op => typeof(I3DOperator).IsAssignableFrom(op.GetType())); 117 117 118 if (SolutionCreator is PackingSequenceRandomCreator) { 119 PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder2D(); 120 } else if (SolutionCreator is GroupingVectorRandomCreator) { 121 PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder2D(); 122 } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 123 PackingSolutionDecoder = new ExtremePointMultiComponentVectorDecoder2D(); 118 PackingSolutionDecoderParameter.ValidValues.Clear(); 119 if (SolutionCreator is PackingSequenceRandomCreator) { 120 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DPSDecoder>()); 121 //PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder2D(); 122 } else if (SolutionCreator is GroupingVectorRandomCreator) { 123 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DGVDecoder>()); 124 //PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder2D(); 125 } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 126 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DMCVDecoder>()); 127 //PackingSolutionDecoder = new ExtremePointMultiComponentVectorDecoder2D(); 124 128 } else { 125 129 string error = "The given problem does not support the selected solution-creator."; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/RegularIdenticalBinPackingProblem.cs
r9495 r9563 56 56 get { return (ValueParameter<B>)Parameters["PackingBinMeasures"]; } 57 57 } 58 public OptionalValueParameter<IPackingSolutionDecoder> PackingSolutionDecoderParameter {59 get { return ( OptionalValueParameter<IPackingSolutionDecoder>)Parameters["PackingSolutionDecoder"]; }58 public ConstrainedValueParameter<IPackingSolutionDecoder> PackingSolutionDecoderParameter { 59 get { return (ConstrainedValueParameter<IPackingSolutionDecoder>)Parameters["PackingSolutionDecoder"]; } 60 60 } 61 61 #endregion … … 85 85 Parameters.Add(new ValueParameter<B>("PackingBinMeasures", "Packing-bin data defining the measures of the used bins.", new B())); 86 86 Parameters.Add(new ValueParameter<IPackingPlanEvaluator>("PackingPlanEvaluator", "The evaluator is used to determine the quality of a solution.", CreateDefaultEvaluator())); 87 Parameters.Add(new OptionalValueParameter<IPackingSolutionDecoder>("PackingSolutionDecoder", "The operator that decodes the representation and creates a packing plan."));87 Parameters.Add(new ConstrainedValueParameter<IPackingSolutionDecoder>("PackingSolutionDecoder", "The operator that decodes the representation and creates a packing plan.")); 88 88 this.Maximization.Value = true; 89 89 InitializeProblemInstance(); … … 232 232 233 233 #region Problem instance handling 234 public void Load(BPPData data) { 234 public virtual void Load(BPPData data) { 235 var realData = data as RealBPPData; 235 236 var binData = new B(); 236 237 binData.InitializeFromMeasures (data.BinMeasures); … … 241 242 item.InitializeFromMeasures(data.ItemMeasures[j]); 242 243 item.AddTargetBinMeasures(data.BinMeasures); 244 if (realData != null) { 245 item.Weight = realData.ItemWeights[j]; 246 item.Material = realData.ItemMaterials[j]; 247 } 243 248 itemData.Add(item); 244 249 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs
r9440 r9563 130 130 //Using "Clustered-Area-Height"-comparison as descr 131 131 132 int result = this.MultipliedMeasures.CompareTo(other.MultipliedMeasures); 132 int result = (this.Width * this.Depth).CompareTo (other.Width * other.Depth); 133 134 if (result == 0) 135 result = this.MultipliedMeasures.CompareTo(other.MultipliedMeasures); 133 136 //if (result == 0) { 134 137 // result = this.Depth.CompareTo(other.Depth) + this.Width.CompareTo(other.Width); 135 138 // if (result == 0) { 136 139 // result = this.Width.CompareTo(other.Width); 137 138 140 if (result == 0) 141 result = this.Height.CompareTo(other.Height); 139 142 // } 140 143 //}
Note: See TracChangeset
for help on using the changeset viewer.