Ignore:
Timestamp:
07/12/16 20:35:19 (5 years ago)
Author:
gkronber
Message:

#1966: renamed evaluators

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/PackingPlanEvaluator.cs

    r14048 r14050  
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Data;
    29 
     29using HeuristicLab.Collections;
    3030
    3131namespace HeuristicLab.Problems.BinPacking {
    3232  [Item("Packingplan Evaluator", "Represents a evaluator class for standard bin-packing problems.")]
    3333  [StorableClass]
    34   public abstract class PackingPlanEvaluator<D,B,I> : SingleSuccessorOperator, IPackingPlanEvaluator
     34  public abstract class EvaluatorBase<D,B,I> : SingleSuccessorOperator, IEvaluator
    3535    where D : class, IPackingPosition
    3636    where B : PackingShape<D>
     
    5252      get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlan"]; }
    5353    }
     54    public ILookupParameter<ItemList<I>> PackingItemMeasuresParameter {
     55      get { return (ILookupParameter<ItemList<I>>)Parameters["PackingItemMeasures"]; }
     56    }
     57    public ILookupParameter<B> PackingBinMeasuresParameter {
     58      get { return (ILookupParameter<B>)Parameters["PackingBinMeasures"]; }
     59    }
    5460    #endregion
    5561
    5662    [StorableConstructor]
    57     protected PackingPlanEvaluator(bool deserializing) : base(deserializing) { }
    58     protected PackingPlanEvaluator(PackingPlanEvaluator<D,B,I> original, Cloner cloner)
     63    protected EvaluatorBase(bool deserializing) : base(deserializing) { }
     64    protected EvaluatorBase(EvaluatorBase<D,B,I> original, Cloner cloner)
    5965      : base(original, cloner) {
    6066    }
    61     public PackingPlanEvaluator()
     67    public EvaluatorBase()
    6268      : base() {
    63       Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
     69      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value of the solution."));
    6470      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlan", "The decoded bin-packing solution represented as generalized packing-plan."));
    6571      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator."));
     72      Parameters.Add(new LookupParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data taken from the bin-packing problem-instance."));
     73      Parameters.Add(new LookupParameter<B>("PackingBinMeasures", "Packing-bin data taken from the bin-packing problem-instance."));
     74
    6675    }
    67 
    6876
    6977    protected abstract DoubleValue Evaluate();                                                                       
     
    7381    }
    7482
     83    protected bool HasOverlappingOrNotContainedItems(ObservableDictionary<int, D> positions, B binMeasure, ItemList<I> itemMeasures, int nrOfBins) {
     84      //TODO: Optimize performance by removing unnecessary allocations..
     85      for (int i = 0; i < itemMeasures.Count; i++) {
     86        I packingItem = itemMeasures[i];
     87        D currentPosition = positions[i];
     88        if (!binMeasure.Encloses(currentPosition, packingItem))
     89          return true;
     90
     91        for (int j = 0; j < itemMeasures.Count; j++) {
     92          D checkedPosition = positions[j];
     93          if (i != j && currentPosition.AssignedBin == checkedPosition.AssignedBin) {
     94            I checkedItem = itemMeasures[j];
     95            if (packingItem.Overlaps(currentPosition, checkedPosition, checkedItem))
     96              return true;
     97          }
     98        }
     99      }
     100      return false;
     101    }
    75102  }
    76103}
Note: See TracChangeset for help on using the changeset viewer.