Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BinPacking/old files/evaluators/EvaluatorBase.cs @ 15636

Last change on this file since 15636 was 14146, checked in by gkronber, 8 years ago

#1966: new implementation for 2d bin packing problem with permutation encoding

File size: 3.5 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;
29using HeuristicLab.Collections;
30
31namespace HeuristicLab.Problems.BinPacking {
32  [Item("Packingplan Evaluator", "Represents a evaluator class for standard bin-packing problems.")]
33  [StorableClass]
34  public abstract class EvaluatorBase<D,B,I> : SingleSuccessorOperator, IEvaluator
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    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    }
60    #endregion
61
62    [StorableConstructor]
63    protected EvaluatorBase(bool deserializing) : base(deserializing) { }
64    protected EvaluatorBase(EvaluatorBase<D,B,I> original, Cloner cloner)
65      : base(original, cloner) {
66    }
67    public EvaluatorBase()
68      : base() {
69      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value of the solution."));
70      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlan", "The decoded bin-packing solution represented as generalized packing-plan."));
71      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
75    }
76
77    protected abstract double Evaluate();                                                                       
78    public override IOperation Apply() {
79      QualityParameter.ActualValue = new DoubleValue(Evaluate());
80      return base.Apply();
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.