Ignore:
Timestamp:
01/24/18 13:17:00 (3 years ago)
Author:
rhanghof
Message:

#2817:

  • Dealing with stackable items
  • Enhanced the Evaluator
  • Added parameters some paramters to the packing items
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Evaluators/PackingRatioEvaluator.cs

    r15617 r15646  
    8484    }
    8585
     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
    86126    #endregion
    87127  }
Note: See TracChangeset for help on using the changeset viewer.