#region License Information
/* HeuristicLab
* Copyright (C) 2002-2012 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HeuristicLab.Problems.BinPacking.Interfaces;
using HeuristicLab.Core;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
using HeuristicLab.Common;
using HeuristicLab.Operators;
using HeuristicLab.Parameters;
using HeuristicLab.Problems.BinPacking.Shapes;
using HeuristicLab.Problems.BinPacking.PackingPlans;
using HeuristicLab.Data;
using HeuristicLab.Collections;
namespace HeuristicLab.Problems.BinPacking.Decoders {
[Item("Single-Bin Packing-Solution Decoder", "An operator to create a concrete single-bin-packing solution from a given encoding-instance.")]
[StorableClass]
public abstract class IdenticalBinPackingSolutionDecoder : SingleSuccessorOperator, IPackingSolutionDecoder
where D : class, IPackingDimensions
where B : PackingShape, IPackingBin
where I : PackingShape, IPackingItem
where P : PackingPlan {
public ILookupParameter RandomParameter {
get { return (LookupParameter)Parameters["Random"]; }
}
public ILookupParameter> PackingItemMeasuresParameter {
get { return (LookupParameter>)Parameters["PackingItemMeasures"]; }
}
public ILookupParameter PackingBinMeasuresParameter {
get { return (LookupParameter)Parameters["PackingBinMeasures"]; }
}
public ILookupParameter EncodedSolutionParameter {
get { return (ILookupParameter)Parameters["EncodedSolution"]; }
}
public ILookupParameter> PackingPlanParameter {
get { return (ILookupParameter>)Parameters["PackingPlan"]; }
}
public IdenticalBinPackingSolutionDecoder() : 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."));
}
[StorableConstructor]
protected IdenticalBinPackingSolutionDecoder(bool deserializing) : base(deserializing) { }
protected IdenticalBinPackingSolutionDecoder(IdenticalBinPackingSolutionDecoder original, Cloner cloner)
: base(original, cloner) {
}
protected abstract PackingPlan CreatePackingPlanFromEncoding(IPackingSolutionEncoding solution);
public override IOperation Apply() {
PackingPlan result = CreatePackingPlanFromEncoding(EncodedSolutionParameter.ActualValue);
PackingPlanParameter.ActualValue = result;
return base.Apply();
}
}
}