Changeset 9495 for branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP
- Timestamp:
- 05/15/13 22:23:36 (12 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointGroupingVectorDecoder2D.cs
r9440 r9495 41 41 [Item("Identical bin, two dimensional, extreme points based decoder for the GroupingVector encoding.", "<Description missing...>")] 42 42 [StorableClass] 43 public class ExtremePointGroupingVectorDecoder2D : IdenticalBinPackingSolutionDecoder<43 public class ExtremePointGroupingVectorDecoder2D : PackingSolutionDecoder< 44 44 TwoDimensionalPacking, 45 45 RectangularPackingBin, 46 RectangularPackingItem, 47 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>> { 46 RectangularPackingItem> { 48 47 49 48 public ExtremePointGroupingVectorDecoder2D () … … 68 67 } 69 68 70 p rotected override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IPackingSolutionEncoding encodedSolution) {69 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IPackingSolutionEncoding encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 71 70 72 71 var solution = encodedSolution as GroupingVectorEncoding; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointMultiComponentVectorDecoder2D.cs
r9440 r9495 42 42 [Item("Identical bin, two dimensional, extreme points based decoder for the MultiComponentVector encoding.", "<Description missing...>")] 43 43 [StorableClass] 44 public class ExtremePointMultiComponentVectorDecoder2D : IdenticalBinPackingSolutionDecoder<44 public class ExtremePointMultiComponentVectorDecoder2D : PackingSolutionDecoder< 45 45 TwoDimensionalPacking, 46 46 RectangularPackingBin, 47 RectangularPackingItem, 48 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>> { 47 RectangularPackingItem> { 49 48 50 49 public ExtremePointMultiComponentVectorDecoder2D () … … 69 68 } 70 69 71 p rotected override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IPackingSolutionEncoding encodedSolution) {70 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IPackingSolutionEncoding encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 72 71 73 72 var solution = encodedSolution as MultiComponentVectorEncoding; 74 73 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector"); 75 74 76 return Decode(solution, PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);75 return Decode(solution, binMeasures, itemMeasures); 77 76 } 78 77 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointPackingSequenceDecoder2D.cs
r9440 r9495 40 40 [Item("Identical bin, two dimensional, extreme points based decoder for the PackingSequence encoding.", "<Description missing...>")] 41 41 [StorableClass] 42 public class ExtremePointPackingSequenceDecoder2D : IdenticalBinPackingSolutionDecoder<42 public class ExtremePointPackingSequenceDecoder2D : PackingSolutionDecoder< 43 43 TwoDimensionalPacking, 44 44 RectangularPackingBin, 45 RectangularPackingItem, 46 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>> { 45 RectangularPackingItem> { 47 46 48 47 public ExtremePointPackingSequenceDecoder2D () … … 59 58 60 59 61 p rotected override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IPackingSolutionEncoding encodedSolution) {60 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IPackingSolutionEncoding encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 62 61 63 62 var solution = encodedSolution as PackingSequenceEncoding; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointsFunctions2D.cs
r9440 r9495 24 24 25 25 #region Preperations 26 int nrOfBins = solution.PackingInformations.Max(x => x.AssignedBin) + 1;26 int nrOfBins = solution.NrOfBins; 27 27 28 28 //Get all indexes of items for every bin according to grouping-vector … … 32 32 33 33 for (int i = 0; i < nrOfBins; i++) { 34 unpackedItemIndexesPerBin[i] = solution.PackingInformations 35 .Where(pi => pi.AssignedBin == i) 36 .ToList(); 34 unpackedItemIndexesPerBin[i] = new List<PackingInformation> (solution.PackingInformations[i]); 37 35 38 36 extremePointsForBin[i] = new HashSet<TwoDimensionalPacking>(); … … 52 50 var unpackedItems = unpackedItemIndexesPerBin[binNr]; 53 51 for (int i = 0; i < unpackedItems.Count; i++) { 54 var itemIndex = unpackedItems[i].ItemI ndex;52 var itemIndex = unpackedItems[i].ItemID; 55 53 var item = itemMeasures[itemIndex]; 56 54 57 extremePointsForBin[binNr] = new HashSet<TwoDimensionalPacking>(extremePointsForBin[binNr].OrderBy(ep => ep.AssignedBin).ThenBy(ep => ShortestPossibleSideFromEP(ep, occupiedPoints, binMeasures)));55 extremePointsForBin[binNr] = OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, binMeasures); 58 56 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 59 57 if (positionFound != null) { … … 62 60 occupiedPoints = OccupyPointsForNewItem(occupiedPoints, item, positionFound, itemIndex); 63 61 extremePointsForBin[binNr] = GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, binMeasures); 64 } else 62 } else { 65 63 remainingItems.Add(unpackedItems[i]); 64 solution.PackingInformations[binNr].Remove(unpackedItems[i]); 65 } 66 66 } 67 67 } … … 74 74 //Iterate over all the remaining items 75 75 for (int i = 0; i < unpackedItems.Count; i++) { 76 var itemIndex = unpackedItems[i].ItemI ndex;76 var itemIndex = unpackedItems[i].ItemID; 77 77 var item = itemMeasures[itemIndex]; 78 78 79 extremePointsForBin[binNr] = new HashSet<TwoDimensionalPacking>(extremePointsForBin[binNr].OrderBy(ep => ep.AssignedBin).ThenBy(ep => ShortestPossibleSideFromEP(ep, occupiedPoints, binMeasures)));79 extremePointsForBin[binNr] = OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, binMeasures); 80 80 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 81 81 if (positionFound != null) { … … 85 85 extremePointsForBin[binNr] = GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, binMeasures); 86 86 remainingItems.Remove(unpackedItems[i]); 87 solution.PackingInformations[binNr].Add(unpackedItems[i]); 87 88 } 88 89 } … … 91 92 extremePointsForBin[nrOfBins].Add(new TwoDimensionalPacking(nrOfBins, 0, 0, false)); 92 93 occupiedPoints = IncreaseBinCountForOccupiedPoints(occupiedPoints, binMeasures); 94 solution.PackingInformations[nrOfBins] = new ItemList<PackingInformation>(); 93 95 nrOfBins++; 94 96 } … … 136 138 var item = itemMeasures[itemIndex]; 137 139 138 extremePointsForBin[binNr] = new HashSet<TwoDimensionalPacking>(extremePointsForBin[binNr].OrderBy(ep => ep.AssignedBin).ThenBy(ep => ShortestPossibleSideFromEP(ep, occupiedPoints, binMeasures)));140 extremePointsForBin[binNr] = OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, binMeasures); 139 141 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions); 140 142 if (positionFound != null) { … … 159 161 var item = itemMeasures[itemIndex]; 160 162 161 extremePointsForBin[binNr] = new HashSet<TwoDimensionalPacking>(extremePointsForBin[binNr].OrderBy(ep => ep.AssignedBin).ThenBy(ep => ShortestPossibleSideFromEP(ep, occupiedPoints, binMeasures)));163 extremePointsForBin[binNr] = OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, binMeasures); 162 164 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions); 163 165 if (positionFound != null) { … … 197 199 foreach (int itemIndex in solution.PackingSequence) { 198 200 var item = itemMeasures[itemIndex]; 199 extremePoints = new HashSet<TwoDimensionalPacking>(extremePoints.OrderBy(ep => ep.AssignedBin).ThenBy(ep => ShortestPossibleSideFromEP(ep, occupiedPoints, binMeasures)));201 extremePoints = OrderExtremePoints(extremePoints, occupiedPoints, binMeasures); 200 202 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePoints, occupiedPoints, itemPositions); 201 203 if (positionFound != null) { … … 296 298 return extremePoints; 297 299 } 300 301 public static HashSet<TwoDimensionalPacking> OrderExtremePoints(HashSet<TwoDimensionalPacking> hashSet, List<int[,]> occupiedPoints, RectangularPackingBin binMeasures) { 302 return new HashSet<TwoDimensionalPacking>(hashSet.OrderBy(ep => ep.AssignedBin).ThenBy(ep => ep.X).ThenBy(ep => ep.Y).ThenBy(ep => ShortestPossibleSideFromEP(ep, occupiedPoints, binMeasures))); 303 } 298 304 private static int ShortestPossibleSideFromEP(TwoDimensionalPacking ep, List<int[,]> occupiedPoints, RectangularPackingBin binMeasures) { 299 305 int shortestSide = int.MaxValue;
Note: See TracChangeset
for help on using the changeset viewer.