Changeset 15646 for branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Evaluators
- Timestamp:
- 01/24/18 13:17:00 (7 years ago)
- Location:
- branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Evaluators
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2817-BinPackingSpeedup/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 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Evaluators/IEvaluator.cs
r15617 r15646 21 21 22 22 using HeuristicLab.Core; 23 using System; 23 24 24 25 namespace HeuristicLab.Problems.BinPacking3D { … … 34 35 /// <returns>Returns the value of the evaluated solution depending on the implementation</returns> 35 36 double Evaluate(Solution solution); 37 38 /// <summary> 39 /// Returns a tuple of (number of bins, bin utilization, number of residual spaces) 40 /// </summary> 41 /// <param name="solution"></param> 42 /// <returns></returns> 43 Tuple<int, double, int> Evaluate1(Solution solution); 36 44 } 37 45 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Evaluators/PackingRatioEvaluator.cs
r15617 r15646 84 84 } 85 85 86 private static int GetBinCount(Solution solution) { 87 return solution.NrOfBins; 88 } 89 90 private static int GetNumberOfResidualSpaces(Solution solution) { 91 var cnt = 0; 92 foreach (var binPacking in solution.Bins) { 93 foreach (var item in ((BinPacking3D)binPacking).ExtremePoints) { 94 cnt += item.Value.Count(); 95 } 96 } 97 return cnt; 98 } 99 100 public Tuple<int, double, int> Evaluate1(Solution solution) { 101 102 103 var res = Tuple.Create<int, double, int>( 104 GetBinCount(solution), 105 CalculateBinUtilizationFirstBin(solution), 106 GetNumberOfResidualSpaces(solution) 107 ); 108 109 return res; 110 } 111 112 private static double CalculateBinUtilizationFirstBin(Solution solution) { 113 if (solution.NrOfBins <= 0) { 114 return 0.0; 115 } 116 117 double totalUsedSpace = 0; 118 double totalUsableSpace = 0; 119 120 totalUsableSpace += solution.Bins[0].BinShape.Volume; 121 totalUsedSpace += solution.Bins[0].Items.Sum(kvp => kvp.Value.Volume); 122 123 return totalUsedSpace / totalUsableSpace; 124 } 125 86 126 #endregion 87 127 }
Note: See TracChangeset
for help on using the changeset viewer.