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/Solution.cs

    r15617 r15646  
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2525using HeuristicLab.Problems.BinPacking;
     26using System;
    2627
    2728namespace HeuristicLab.Problems.BinPacking3D {
     
    3940      return new Solution(this, cloner);
    4041    }
     42
     43    public bool IsBetterThan(Solution other, IEvaluator evaluator, bool problemMaximization = true) {
     44      var evaluatedThis = evaluator.Evaluate1(this);
     45
     46      if (double.IsInfinity(evaluatedThis.Item2) || double.IsNaN(evaluatedThis.Item2)) {
     47        return false;
     48      }
     49
     50      if (other == null) {
     51        return true;
     52      }
     53
     54      var evaluatedOther = evaluator.Evaluate1(other);
     55      if (evaluatedThis.Item1 < evaluatedOther.Item1) {
     56        return true;
     57      } else if (evaluatedThis.Item1 > evaluatedOther.Item1) {
     58        return false;
     59      }
     60     
     61      if (evaluatedThis.Item2 > evaluatedOther.Item2) {
     62        return true;
     63      }
     64      if (evaluatedThis.Item2 < evaluatedOther.Item2) {
     65        return false;
     66      }
     67
     68      if (evaluatedThis.Item3 > evaluatedOther.Item3) {
     69        return false;
     70      }
     71      return true;
     72
     73    }
    4174  }
    4275}
Note: See TracChangeset for help on using the changeset viewer.