#region License Information /* HeuristicLab * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Common; using HeuristicLab.Operators; using HeuristicLab.Parameters; using HeuristicLab.Data; using HeuristicLab.Encodings.PackingEncoding; namespace HeuristicLab.Problems.BinPacking { [Item("Packing-Solution Decoder", "An operator to create a concrete bin packing solution from a given encoding-instance.")] [StorableClass] public abstract class PackingSolutionDecoder : SingleSuccessorOperator, IPackingSolutionDecoder where D : class, IPackingPosition where B : PackingShape where I : PackingShape, IPackingItem { public ILookupParameter RandomParameter { get { return (LookupParameter)Parameters["Random"]; } } private ILookupParameter> PackingItemMeasuresParameter { get { return (LookupParameter>)Parameters["PackingItemMeasures"]; } } private ILookupParameter PackingBinMeasuresParameter { get { return (LookupParameter)Parameters["PackingBinMeasures"]; } } public ILookupParameter EncodedSolutionParameter { get { return (ILookupParameter)Parameters["EncodedSolution"]; } } public ILookupParameter> PackingPlanParameter { get { return (ILookupParameter>)Parameters["PackingPlan"]; } } public ValueParameter StackingConstraintsParameter { get { return (ValueParameter)Parameters["StackingConstraint"]; } } public PackingSolutionDecoder() : base() { Parameters.Add(new LookupParameter("EncodedSolution", "The new bin-packing solution represented as encoding.")); Parameters.Add(new LookupParameter>("PackingPlan", "The decoded bin-packing solution represented as generalized packing plan.")); Parameters.Add(new LookupParameter("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); Parameters.Add(new LookupParameter>("PackingItemMeasures", "Packing-item data taken from the bin-packing problem-instance.")); Parameters.Add(new LookupParameter("PackingBinMeasures", "Packing-bin data taken from the bin-packing problem-instance.")); Parameters.Add(new ValueParameter("StackingConstraint", "A flag determining whether stacking constraints should be enforced or not.", new BoolValue(true))); } [StorableConstructor] protected PackingSolutionDecoder(bool deserializing) : base(deserializing) { } protected PackingSolutionDecoder(PackingSolutionDecoder original, Cloner cloner) : base(original, cloner) { } public abstract PackingPlan CreatePackingPlanFromEncoding(IItem solution, B binMeasures, ItemList itemMeasures); public override IOperation Apply() { PackingPlan result = CreatePackingPlanFromEncoding(EncodedSolutionParameter.ActualValue, PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue); PackingPlanParameter.ActualValue = result; return base.Apply(); } } }