1  #region License Information


2  /* HeuristicLab


3  * Copyright (C) 20022015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)


4  *


5  * This file is part of HeuristicLab.


6  *


7  * HeuristicLab is free software: you can redistribute it and/or modify


8  * it under the terms of the GNU General Public License as published by


9  * the Free Software Foundation, either version 3 of the License, or


10  * (at your option) any later version.


11  *


12  * HeuristicLab is distributed in the hope that it will be useful,


13  * but WITHOUT ANY WARRANTY; without even the implied warranty of


14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the


15  * GNU General Public License for more details.


16  *


17  * You should have received a copy of the GNU General Public License


18  * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.


19  */


20  #endregion


21 


22 


23  using HeuristicLab.Core;


24  using HeuristicLab.Operators;


25  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;


26  using HeuristicLab.Common;


27  using HeuristicLab.Parameters;


28  using HeuristicLab.Data;


29 


30 


31  namespace HeuristicLab.Problems.BinPacking {


32  [Item("Packingplan Evaluator", "Represents a evaluator class for standard binpacking problems.")]


33  [StorableClass]


34  public abstract class PackingPlanEvaluator<D,B,I> : SingleSuccessorOperator, IPackingPlanEvaluator


35  where D : class, IPackingPosition


36  where B : PackingShape<D>


37  where I : PackingShape<D>, IPackingItem {


38 


39  #region Parameters


40  public ILookupParameter<IRandom> RandomParameter {


41  get { return (LookupParameter<IRandom>)Parameters["Random"]; }


42  }


43  public ILookupParameter<DoubleValue> QualityParameter {


44  get {


45  if (Parameters.ContainsKey("Quality"))


46  return (ILookupParameter<DoubleValue>)Parameters["Quality"];


47  else


48  return null;


49  }


50  }


51  public ILookupParameter<IPackingPlan> PackingPlanParameter {


52  get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlan"]; }


53  }


54  #endregion


55 


56  [StorableConstructor]


57  protected PackingPlanEvaluator(bool deserializing) : base(deserializing) { }


58  protected PackingPlanEvaluator(PackingPlanEvaluator<D,B,I> original, Cloner cloner)


59  : base(original, cloner) {


60  }


61  public PackingPlanEvaluator()


62  : base() {


63  Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));


64  Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlan", "The decoded binpacking solution represented as generalized packingplan."));


65  Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator."));


66  }


67 


68 


69  protected abstract DoubleValue Evaluate();


70  public override IOperation Apply() {


71  QualityParameter.ActualValue = Evaluate();


72  return base.Apply();


73  }


74 


75  }


76  }

