[9348] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[13032] | 3 | * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[9348] | 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 |
|
---|
[13032] | 22 |
|
---|
[9348] | 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;
|
---|
[14050] | 29 | using HeuristicLab.Collections;
|
---|
[9348] | 30 |
|
---|
[14046] | 31 | namespace HeuristicLab.Problems.BinPacking {
|
---|
[9348] | 32 | [Item("Packingplan Evaluator", "Represents a evaluator class for standard bin-packing problems.")]
|
---|
| 33 | [StorableClass]
|
---|
[14050] | 34 | public abstract class EvaluatorBase<D,B,I> : SingleSuccessorOperator, IEvaluator
|
---|
[14048] | 35 | where D : class, IPackingPosition
|
---|
[14045] | 36 | where B : PackingShape<D>
|
---|
[9348] | 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 | }
|
---|
[14050] | 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 | }
|
---|
[9348] | 60 | #endregion
|
---|
| 61 |
|
---|
| 62 | [StorableConstructor]
|
---|
[14050] | 63 | protected EvaluatorBase(bool deserializing) : base(deserializing) { }
|
---|
| 64 | protected EvaluatorBase(EvaluatorBase<D,B,I> original, Cloner cloner)
|
---|
[9348] | 65 | : base(original, cloner) {
|
---|
| 66 | }
|
---|
[14050] | 67 | public EvaluatorBase()
|
---|
[9348] | 68 | : base() {
|
---|
[14050] | 69 | Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value of the solution."));
|
---|
[9348] | 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."));
|
---|
[14050] | 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 |
|
---|
[9348] | 75 | }
|
---|
| 76 |
|
---|
[14128] | 77 | protected abstract double Evaluate();
|
---|
[9348] | 78 | public override IOperation Apply() {
|
---|
[14128] | 79 | QualityParameter.ActualValue = new DoubleValue(Evaluate());
|
---|
[9348] | 80 | return base.Apply();
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 | }
|
---|