source: branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/PackingPlanEvaluator.cs @ 14048

Last change on this file since 14048 was 14048, checked in by gkronber, 5 years ago

#1966: renamed *PackingDimension -> PackingPosition

File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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
23using HeuristicLab.Core;
24using HeuristicLab.Operators;
25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
26using HeuristicLab.Common;
27using HeuristicLab.Parameters;
28using HeuristicLab.Data;
29
30
31namespace HeuristicLab.Problems.BinPacking {
32  [Item("Packingplan Evaluator", "Represents a evaluator class for standard bin-packing 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 bin-packing solution represented as generalized packing-plan."));
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}
Note: See TracBrowser for help on using the repository browser.