Ignore:
Timestamp:
07/20/16 14:02:36 (5 years ago)
Author:
gkronber
Message:

#1966: refactoring of bin packing implementation

File:
1 edited

Legend:

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

    r14050 r14128  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.Encodings.PackingEncoding;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Optimization;
     
    3233  [Item("PackingMoveEvaluator", "A base class for operators which evaluate Packing-Solution moves.")]
    3334  [StorableClass]
    34   public abstract class PackingMoveEvaluator<D, B, I> : SingleSuccessorOperator, IPackingMoveEvaluator, IMoveOperator
     35  public abstract class PackingMoveEvaluator<D, B, I, M> : SingleSuccessorOperator, IPackingMoveEvaluator
    3536    where D : class, IPackingPosition
    3637    where B : PackingShape<D>
    37     where I : PackingShape<D>, IPackingItem {     
     38    where I : PackingShape<D>, IPackingItem
     39    where M : IItem {     
    3840    public override bool CanChangeName {
    3941      get { return false; }
     
    6163      get { return (ScopeParameter)Parameters["CurrentScope"]; }
    6264    }
    63     public ILookupParameter<IPackingMove> PackingMoveParameter {
    64       get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
     65    public ILookupParameter<IPackingMove<M>> PackingMoveParameter {
     66      get { return (ILookupParameter<IPackingMove<M>>)Parameters["PackingMove"]; }
    6567    } 
    6668   
    6769    [StorableConstructor]
    6870    protected PackingMoveEvaluator(bool deserializing) : base(deserializing) { }
    69     protected PackingMoveEvaluator(PackingMoveEvaluator<D, B, I> original, Cloner cloner) : base(original, cloner) { }
     71    protected PackingMoveEvaluator(PackingMoveEvaluator<D, B, I, M> original, Cloner cloner) : base(original, cloner) { }
    7072    protected PackingMoveEvaluator()
    7173      : base() {
     
    7779      Parameters.Add(new ValueLookupParameter<IEvaluator>("PackingPlanEvaluator", "The actual packing plan evaluation operator."));
    7880      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the decoded solution should be added to."));
    79       Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
     81      Parameters.Add(new LookupParameter<IPackingMove<M>>("PackingMove", "The move to evaluate."));
    8082    }
    8183
     
    8385
    8486    public override IOperation Apply() {
    85       IPackingMove move = PackingMoveParameter.ActualValue;
    86       IPackingSolutionEncoding newSolution = move.GetSolutionAfterMove();
     87      IPackingMove<M> move = PackingMoveParameter.ActualValue;
     88      var newSolution = move.GetSolutionAfterMove();
    8789      CurrentScopeParameter.ActualValue.Variables.Add(new Variable("MovedSolution", newSolution));
    8890
     
    9395      CurrentScopeParameter.ActualValue.Variables.Add(new Variable("PackingPlanAfterMove", packingPlan));
    9496
    95       DoubleValue quality = PackingRatioEvaluator<D, B, I>.CalculatePackingRatio(packingPlan);
     97      var quality = PackingRatioEvaluator<D, B, I>.CalculatePackingRatio(packingPlan);
    9698
    97       double moveQuality = quality.Value;
     99      double moveQuality = quality;
    98100
    99101      if (MoveQualityParameter.ActualValue == null) MoveQualityParameter.ActualValue = new DoubleValue(moveQuality);
Note: See TracChangeset for help on using the changeset viewer.