Changeset 15646 for branches/2817BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Evaluators/BinUtilizationEvaluator.cs
 Timestamp:
 01/24/18 13:17:00 (3 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/2817BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Evaluators/BinUtilizationEvaluator.cs
r15617 r15646 67 67 } 68 68 69 private static int GetBinCount(Solution solution) { 70 return solution.NrOfBins; 71 } 72 73 private static int GetNumberOfResidualSpaces(Solution solution) { 74 var cnt = 0; 75 foreach (var binPacking in solution.Bins) { 76 foreach (var item in ((BinPacking3D)binPacking).ExtremePoints) { 77 cnt += item.Value.Count(); 78 } 79 } 80 return cnt; 81 } 82 83 public Tuple<int, double, int> Evaluate1(Solution solution) { 84 85 86 var res = Tuple.Create<int, double, int>( 87 GetBinCount(solution), 88 CalculateBinUtilizationFirstBin(solution), 89 GetNumberOfResidualSpaces(solution) 90 ); 91 92 return res; 93 } 94 95 private static double CalculateBinUtilizationFirstBin(Solution solution) { 96 if (solution.NrOfBins <= 0) { 97 return 0.0; 98 } 99 100 double totalUsedSpace = 0; 101 double totalUsableSpace = 0; 102 103 totalUsableSpace += solution.Bins[0].BinShape.Volume; 104 totalUsedSpace += solution.Bins[0].Items.Sum(kvp => kvp.Value.Volume); 105 106 return totalUsedSpace / totalUsableSpace; 107 } 108 109 69 110 #endregion 70 111 }
Note: See TracChangeset
for help on using the changeset viewer.