Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 13792 was 13608, checked in by gkronber, 9 years ago

#1966 refactoring (moved 3d-specific classes into separate project)

File size: 3.0 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.Problems.BinPacking.Interfaces;
25using HeuristicLab.Operators;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27using HeuristicLab.Common;
28using HeuristicLab.Parameters;
29using HeuristicLab.Data;
30using HeuristicLab.Problems.BinPacking.Shapes;
31
32namespace HeuristicLab.Problems.BinPacking.Evaluators {
33  [Item("Packingplan Evaluator", "Represents a evaluator class for standard bin-packing problems.")]
34  [StorableClass]
35  public abstract class PackingPlanEvaluator<D,B,I> : SingleSuccessorOperator, IPackingPlanEvaluator
36    where D : class, IPackingDimensions
37    where B : PackingShape<D>, IPackingBin
38    where I : PackingShape<D>, IPackingItem {
39
40    #region Parameters
41    public ILookupParameter<IRandom> RandomParameter {
42      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
43    }
44    public ILookupParameter<DoubleValue> QualityParameter {
45      get {
46        if (Parameters.ContainsKey("Quality"))
47          return (ILookupParameter<DoubleValue>)Parameters["Quality"];
48        else
49          return null;
50      }
51    }
52    public ILookupParameter<IPackingPlan> PackingPlanParameter {
53      get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlan"]; }
54    }
55    #endregion
56
57    [StorableConstructor]
58    protected PackingPlanEvaluator(bool deserializing) : base(deserializing) { }
59    protected PackingPlanEvaluator(PackingPlanEvaluator<D,B,I> original, Cloner cloner)
60      : base(original, cloner) {
61    }
62    public PackingPlanEvaluator()
63      : base() {
64      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
65      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlan", "The decoded bin-packing solution represented as generalized packing-plan."));
66      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator."));
67    }
68
69
70    protected abstract DoubleValue Evaluate();                                                                       
71    public override IOperation Apply() {
72      QualityParameter.ActualValue = Evaluate();
73      return base.Apply();
74    }
75
76  }
77}
Note: See TracBrowser for help on using the repository browser.