Changeset 9563 for branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/Abstract
- Timestamp:
- 06/02/13 04:26:26 (12 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/Abstract
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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();
Note: See TracChangeset
for help on using the changeset viewer.