Free cookie consent management tool by TermsFeed Policy Generator

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

#1966: renamed evaluators

Location:
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3
Files:
11 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Analyzers/BestBinPackingSolutionAnalyzer.cs

    r14048 r14050  
    9393      }
    9494      string binUtilKey = "Overall Bin Utilization";
    95       DoubleValue binUtil = BinUtilizationRegularIdenticalBinEvaluator<D, B, I>.CalculateBinUtilization(bestSolution);
     95      DoubleValue binUtil = BinUtilizationEvaluator<D, B, I>.CalculateBinUtilization(bestSolution);
    9696      if (!results.ContainsKey(binUtilKey))
    9797        results.Add(new Result(binUtilKey, binUtil));
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs

    r14048 r14050  
    3737  [Item("PackingPlan", "Represents a concrete solution for a bin-packing problem.")]
    3838  [StorableClass]
    39   public abstract class PackingPlan<D, B, I> :Item, IPackingPlan
     39  public abstract class PackingPlan<D, B, I> : Item, IPackingPlan
    4040    where D : class, IPackingPosition
    4141    where B : PackingShape<D>
     
    7777
    7878    protected PackingPlan(B binMeasures, bool useExtremePoints, bool stackingConstraints)
    79       : base(){
    80         BinMeasures = (B)binMeasures.Clone();
    81         StackingConstraints = stackingConstraints;
    82         UseExtremePoints = useExtremePoints;
    83         BinPackings = new ObservableList<BinPacking<D, B, I>>();
     79      : base() {
     80      BinMeasures = (B)binMeasures.Clone();
     81      StackingConstraints = stackingConstraints;
     82      UseExtremePoints = useExtremePoints;
     83      BinPackings = new ObservableList<BinPacking<D, B, I>>();
    8484    }
    8585
    8686    [StorableConstructor]
    8787    protected PackingPlan(bool deserializing) : base(deserializing) { }
    88     protected PackingPlan(PackingPlan<D,B,I> original, Cloner cloner)
     88    protected PackingPlan(PackingPlan<D, B, I> original, Cloner cloner)
    8989      : base(original, cloner) {
    90         this.BinPackings = new ObservableList<BinPacking<D, B, I>>(original.BinPackings);
    91     }
    92    
     90      this.BinPackings = new ObservableList<BinPacking<D, B, I>>(original.BinPackings);
     91    }
     92
    9393
    9494    public abstract BinPacking<D, B, I> NewBinPacking();
    9595    public void UpdateBinPackings() {
    9696      BinPackings.RemoveAll(x => x.ItemPositions.Count == 0);
    97       BinPackings = new ObservableList<BinPacking<D, B, I>>(BinPackings.OrderByDescending (bp => bp.PackingDensity));
     97      BinPackings = new ObservableList<BinPacking<D, B, I>>(BinPackings.OrderByDescending(bp => bp.PackingDensity));
    9898    }
    9999
     
    139139      UpdateBinPackings();
    140140
    141       var newSolution = new ObservableDictionary<int,ItemList<PackingInformation>> ();
     141      var newSolution = new ObservableDictionary<int, ItemList<PackingInformation>>();
    142142      foreach (var bp in BinPackings) {
    143143        int binIndex = newSolution.Count;
    144144        newSolution[binIndex] = new ItemList<PackingInformation>();
    145145        foreach (var entry in bp.ItemPositions)
    146           newSolution[binIndex].Add(new PackingInformation (entry.Key, entry.Value.Rotated));
     146          newSolution[binIndex].Add(new PackingInformation(entry.Key, entry.Value.Rotated));
    147147      }
    148148      solution.PackingInformations = newSolution;
     
    167167      var temp = new List<int>(remainingIDs);
    168168      foreach (int id in temp) {
    169         foreach (var bp in BinPackings) { 
    170           var position = UseExtremePoints ? bp.FindExtremePointForItem (itemMeasures[id], false, StackingConstraints) : bp.FindPositionBySliding(itemMeasures[id], false);
     169        foreach (var bp in BinPackings) {
     170          var position = UseExtremePoints ? bp.FindExtremePointForItem(itemMeasures[id], false, StackingConstraints) : bp.FindPositionBySliding(itemMeasures[id], false);
    171171          if (position != null) {
    172172            bp.PackItem(id, itemMeasures[id], position);
     
    195195        binIndex++;
    196196      }
    197       solution.GroupingVector = new IntegerVector (newSolution);
     197      solution.GroupingVector = new IntegerVector(newSolution);
    198198    }
    199199    public void Pack(PackingSequenceEncoding solution, ItemList<I> itemMeasures) {
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/BinUtilizationRegularIdenticalBinEvaluator.cs

    r14048 r14050  
    2828
    2929namespace HeuristicLab.Problems.BinPacking {
    30   [Item("Bin-Utilization Regular Identical-Bin Evaluator", "<Description missing> Found in Lee:2010")]
     30  [Item("Bin-Utilization Evaluator", "<Description missing> Found in Lee:2010")] // TODO
    3131  [StorableClass]
    32   public abstract class BinUtilizationRegularIdenticalBinEvaluator<D, B, I> : RegularSimpleRotationIdenticalBinPackingPlanEvaluator<D, B, I>
     32  public abstract class BinUtilizationEvaluator<D, B, I> : EvaluatorBase<D, B, I>
    3333    where D : class, IPackingPosition
    3434    where B : PackingShape<D>
     
    3636
    3737    [StorableConstructor]
    38     protected BinUtilizationRegularIdenticalBinEvaluator(bool deserializing) : base(deserializing) { }
    39     protected BinUtilizationRegularIdenticalBinEvaluator(BinUtilizationRegularIdenticalBinEvaluator<D, B, I> original, Cloner cloner)
     38    protected BinUtilizationEvaluator(bool deserializing) : base(deserializing) { }
     39    protected BinUtilizationEvaluator(BinUtilizationEvaluator<D, B, I> original, Cloner cloner)
    4040      : base(original, cloner) {
    4141    }
    42     public BinUtilizationRegularIdenticalBinEvaluator() : base() { }
     42    public BinUtilizationEvaluator() : base() { }
    4343
    4444    protected override DoubleValue Evaluate() {
     
    4949      ItemList<I> itemMeasures = PackingItemMeasuresParameter.ActualValue;
    5050
     51      // TODO: check and remove code
    5152
    5253      //Check if data is valid
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/PackingPlanEvaluationAlgorithm.cs

    r14048 r14050  
    4444      get { return PackingSolutionDecoderParameter; }
    4545    }
    46     public IValueLookupParameter<IPackingPlanEvaluator> PackingPlanEvaluatorParameter {
    47       get { return (IValueLookupParameter<IPackingPlanEvaluator>)Parameters["PackingPlanEvaluator"]; }
     46    public IValueLookupParameter<IEvaluator> PackingPlanEvaluatorParameter {
     47      get { return (IValueLookupParameter<IEvaluator>)Parameters["PackingPlanEvaluator"]; }
    4848    }
    49     ILookupParameter<IPackingPlanEvaluator> IPackingPlanEvaluationAlgorithm.PackingPlanEvaluatorParameter {
     49    ILookupParameter<IEvaluator> IPackingPlanEvaluationAlgorithm.PackingPlanEvaluatorParameter {
    5050      get { return PackingPlanEvaluatorParameter; }
    5151    }
     
    6262      : base() {
    6363        Parameters.Add(new ValueLookupParameter<IPackingSolutionDecoder>("PackingSolutionDecoder", "The decoding operator that is used to calculate a packing plan from the used representation."));
    64         Parameters.Add(new ValueLookupParameter<IPackingPlanEvaluator>("PackingPlanEvaluator", "The actual packing plan evaluation operator."));
     64        Parameters.Add(new ValueLookupParameter<IEvaluator>("PackingPlanEvaluator", "The actual packing plan evaluation operator."));
    6565        Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
    6666        QualityParameter.Hidden = true;
  • 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}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/PackingRatioEvaluator.cs

    r14049 r14050  
    2828
    2929namespace HeuristicLab.Problems.BinPacking {
    30   [Item("Packing-Ratio Regular Identical-Bin Evaluator", "Represents an evaluation-algorithm for regular-shaped bin-packing problems with identical bins which calculates the ratio between packed and unpacked space. Found in Falkenauer:1996")]
    3130  [StorableClass]
    32   public abstract class PackingRatioRegularIdenticalBinEvaluator<D, B, I> : RegularSimpleRotationIdenticalBinPackingPlanEvaluator<D, B, I>
     31  public abstract class PackingRatioEvaluator<D, B, I> : EvaluatorBase<D, B, I>
    3332    where D : class, IPackingPosition
    3433    where B : PackingShape<D>
     
    3635
    3736    [StorableConstructor]
    38     protected PackingRatioRegularIdenticalBinEvaluator(bool deserializing) : base(deserializing) { }
    39     protected PackingRatioRegularIdenticalBinEvaluator(PackingRatioRegularIdenticalBinEvaluator<D, B, I> original, Cloner cloner)
     37    protected PackingRatioEvaluator(bool deserializing) : base(deserializing) { }
     38    protected PackingRatioEvaluator(PackingRatioEvaluator<D, B, I> original, Cloner cloner)
    4039      : base(original, cloner) {
    4140    }
    42     public PackingRatioRegularIdenticalBinEvaluator() : base() { }
     41    public PackingRatioEvaluator() : base() { }
    4342
    4443    protected override DoubleValue Evaluate() {
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/RegularSimpleRotationIdenticalBinPackingPlanEvaluator.cs

    r14048 r14050  
    5454    }
    5555
    56 
    57 
    58 
    5956    protected bool HasOverlappingOrNotContainedItems(ObservableDictionary<int, D> positions, B binMeasure, ItemList<I> itemMeasures, int nrOfBins) {
    6057      //TODO: Optimize performance by removing unnecessary allocations..
     
    7370          }
    7471        }
    75 
    7672      }
    77 
    7873      return false;
    7974    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj

    r14049 r14050  
    254254    <Compile Include="Evaluators\PackingPlanEvaluationAlgorithm.cs" />
    255255    <Compile Include="Evaluators\PackingPlanEvaluator.cs" />
    256     <Compile Include="Evaluators\PackingRatioRegularIdenticalBinEvaluator.cs" />
    257     <Compile Include="Evaluators\RegularSimpleRotationIdenticalBinPackingPlanEvaluator.cs" />
     256    <Compile Include="Evaluators\PackingRatioEvaluator.cs" />
    258257    <Compile Include="Instances\BPPData.cs" />
    259258    <Compile Include="Instances\BPPInstanceProvider.cs" />
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingPlanEvaluationAlgorithm.cs

    r14046 r14050  
    2626  public interface IPackingPlanEvaluationAlgorithm : ISingleObjectiveEvaluator {
    2727    ILookupParameter<IPackingSolutionDecoder> PackingSolutionDecoderParameter { get; }
    28     ILookupParameter<IPackingPlanEvaluator> PackingPlanEvaluatorParameter { get; }
     28    ILookupParameter<IEvaluator> PackingPlanEvaluatorParameter { get; }
    2929  }
    3030}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingPlanEvaluator.cs

    r14046 r14050  
    2424
    2525namespace HeuristicLab.Problems.BinPacking {
    26   public interface IPackingPlanEvaluator : ISingleObjectiveEvaluator {
     26  public interface IEvaluator : ISingleObjectiveEvaluator {
    2727     ILookupParameter<IPackingPlan> PackingPlanParameter { get; }
    2828  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingMoveEvaluator.cs

    r14048 r14050  
    5555      get { return (IValueLookupParameter<IPackingSolutionDecoder>)Parameters["PackingSolutionDecoder"]; }
    5656    }
    57     public IValueLookupParameter<IPackingPlanEvaluator> PackingPlanEvaluatorParameter {
    58       get { return (IValueLookupParameter<IPackingPlanEvaluator>)Parameters["PackingPlanEvaluator"]; }
     57    public IValueLookupParameter<IEvaluator> PackingPlanEvaluatorParameter {
     58      get { return (IValueLookupParameter<IEvaluator>)Parameters["PackingPlanEvaluator"]; }
    5959    }
    6060    protected ScopeParameter CurrentScopeParameter {
     
    7575      Parameters.Add(new LookupParameter<B>("PackingBinMeasures", "Packing-bin data taken from the bin-packing problem-instance."));
    7676      Parameters.Add(new ValueLookupParameter<IPackingSolutionDecoder>("PackingSolutionDecoder", "The decoding operator that is used to calculate a packing plan from the used representation."));
    77       Parameters.Add(new ValueLookupParameter<IPackingPlanEvaluator>("PackingPlanEvaluator", "The actual packing plan evaluation operator."));
     77      Parameters.Add(new ValueLookupParameter<IEvaluator>("PackingPlanEvaluator", "The actual packing plan evaluation operator."));
    7878      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the decoded solution should be added to."));
    7979      Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
     
    9393      CurrentScopeParameter.ActualValue.Variables.Add(new Variable("PackingPlanAfterMove", packingPlan));
    9494
    95       DoubleValue quality = PackingRatioRegularIdenticalBinEvaluator<D, B, I>.CalculatePackingRatio(packingPlan);
     95      DoubleValue quality = PackingRatioEvaluator<D, B, I>.CalculatePackingRatio(packingPlan);
    9696
    9797      double moveQuality = quality.Value;
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem.cs

    r14049 r14050  
    5555      get { return (IFixedValueParameter<IntValue>)Parameters["LowerBound"]; }
    5656    }
    57     public ValueParameter<IPackingPlanEvaluator> PackingPlanEvaluatorParameter {
    58       get { return (ValueParameter<IPackingPlanEvaluator>)Parameters["PackingPlanEvaluator"]; }
     57    public ValueParameter<IEvaluator> PackingPlanEvaluatorParameter {
     58      get { return (ValueParameter<IEvaluator>)Parameters["PackingPlanEvaluator"]; }
    5959    }
    6060    public IValueParameter<B> PackingBinMeasuresParameter {
     
    7575      set { PackingItemMeasuresParameter.Value = value; }
    7676    }
    77     public IPackingPlanEvaluator PackingPlanEvaluator {
     77    public IEvaluator PackingPlanEvaluator {
    7878      get { return PackingPlanEvaluatorParameter.Value; }
    7979      set { PackingPlanEvaluatorParameter.Value = value; }
     
    106106      Parameters.Add(new FixedValueParameter<IntValue>("LowerBound", "The lower possible number of bins needed to solve this problem (taken from Dell'Amico, Martello and Vigo; 2002)", new IntValue()));
    107107      Parameters.Add(new ValueParameter<B>("PackingBinMeasures", "Packing-bin data defining the measures of the used bins.", new B()));
    108       Parameters.Add(new ValueParameter<IPackingPlanEvaluator>("PackingPlanEvaluator", "The evaluator is used to determine the quality of a solution.", CreateDefaultEvaluator()));
     108      Parameters.Add(new ValueParameter<IEvaluator>("PackingPlanEvaluator", "The evaluator is used to determine the quality of a solution.", CreateDefaultEvaluator()));
    109109      Parameters.Add(new ConstrainedValueParameter<IPackingSolutionDecoder>("PackingSolutionDecoder", "The operator that decodes the representation and creates a packing plan."));
    110110      this.Maximization.Value = true;
     
    142142    protected abstract void RemoveTooBigItems();
    143143    protected abstract void InitializeProblemData();
    144     protected abstract IPackingPlanEvaluator CreateDefaultEvaluator();
     144    protected abstract IEvaluator CreateDefaultEvaluator();
    145145    protected void ApplyHorizontalOrientation() {
    146146      PackingBinMeasures.ApplyHorizontalOrientation();
Note: See TracChangeset for help on using the changeset viewer.