Free cookie consent management tool by TermsFeed Policy Generator

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

#2817:

  • Dealing with stackable items
  • Enhanced the Evaluator
  • Added parameters some paramters to the packing items
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  
    6767    }
    6868
     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
    69110    #endregion
    70111  }
  • branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Evaluators/IEvaluator.cs

    r15617 r15646  
    2121
    2222using HeuristicLab.Core;
     23using System;
    2324
    2425namespace HeuristicLab.Problems.BinPacking3D {
     
    3435    /// <returns>Returns the value of the evaluated solution depending on the implementation</returns>
    3536    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);
    3644  }
    3745}
  • 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.