[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.Problems.BinPacking.Interfaces;
|
---|
| 25 | using HeuristicLab.Operators;
|
---|
| 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 27 | using HeuristicLab.Common;
|
---|
| 28 | using HeuristicLab.Parameters;
|
---|
| 29 | using HeuristicLab.Data;
|
---|
| 30 | using HeuristicLab.Problems.BinPacking.Shapes;
|
---|
| 31 |
|
---|
| 32 | namespace 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 |
|
---|
[9495] | 70 | protected abstract DoubleValue Evaluate();
|
---|
[9348] | 71 | public override IOperation Apply() {
|
---|
| 72 | QualityParameter.ActualValue = Evaluate();
|
---|
| 73 | return base.Apply();
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | }
|
---|
| 77 | }
|
---|