[9348] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2012 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 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using System.Text;
|
---|
| 26 | using HeuristicLab.Problems.BinPacking.Interfaces;
|
---|
| 27 | using HeuristicLab.Core;
|
---|
| 28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 29 | using HeuristicLab.Common;
|
---|
| 30 | using HeuristicLab.Operators;
|
---|
| 31 | using HeuristicLab.Parameters;
|
---|
| 32 | using HeuristicLab.Problems.BinPacking.Shapes;
|
---|
| 33 | using HeuristicLab.Problems.BinPacking.PackingPlans;
|
---|
| 34 | using HeuristicLab.Data;
|
---|
| 35 | using HeuristicLab.Collections;
|
---|
| 36 |
|
---|
| 37 | namespace HeuristicLab.Problems.BinPacking.Decoders {
|
---|
| 38 |
|
---|
| 39 | [Item("Single-Bin Packing-Solution Decoder", "An operator to create a concrete single-bin-packing solution from a given encoding-instance.")]
|
---|
| 40 | [StorableClass]
|
---|
| 41 | public abstract class IdenticalBinPackingSolutionDecoder<D, B, I, P> : SingleSuccessorOperator, IPackingSolutionDecoder
|
---|
| 42 | where D : class, IPackingDimensions
|
---|
| 43 | where B : PackingShape<D>, IPackingBin
|
---|
| 44 | where I : PackingShape<D>, IPackingItem
|
---|
| 45 | where P : PackingPlan<D, B, I> {
|
---|
| 46 |
|
---|
| 47 | public ILookupParameter<IRandom> RandomParameter {
|
---|
| 48 | get { return (LookupParameter<IRandom>)Parameters["Random"]; }
|
---|
| 49 | }
|
---|
| 50 | public ILookupParameter<ItemList<I>> PackingItemMeasuresParameter {
|
---|
| 51 | get { return (LookupParameter<ItemList<I>>)Parameters["PackingItemMeasures"]; }
|
---|
| 52 | }
|
---|
| 53 | public ILookupParameter<B> PackingBinMeasuresParameter {
|
---|
| 54 | get { return (LookupParameter<B>)Parameters["PackingBinMeasures"]; }
|
---|
| 55 | }
|
---|
| 56 | public ILookupParameter<IPackingSolutionEncoding> EncodedSolutionParameter {
|
---|
| 57 | get { return (ILookupParameter<IPackingSolutionEncoding>)Parameters["EncodedSolution"]; }
|
---|
| 58 | }
|
---|
| 59 | public ILookupParameter<PackingPlan<D,B,I>> PackingPlanParameter {
|
---|
| 60 | get { return (ILookupParameter<PackingPlan<D, B, I>>)Parameters["PackingPlan"]; }
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | public IdenticalBinPackingSolutionDecoder() : base() {
|
---|
| 65 | Parameters.Add(new LookupParameter<IPackingSolutionEncoding>("EncodedSolution", "The new bin-packing solution represented as encoding."));
|
---|
| 66 | Parameters.Add(new LookupParameter<PackingPlan<D, B, I>>("PackingPlan", "The decoded bin-packing solution represented as generalized packing plan."));
|
---|
| 67 | Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
|
---|
| 68 | Parameters.Add(new LookupParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data taken from the bin-packing problem-instance."));
|
---|
| 69 | Parameters.Add(new LookupParameter<B>("PackingBinMeasures", "Packing-bin data taken from the bin-packing problem-instance."));
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | [StorableConstructor]
|
---|
| 73 | protected IdenticalBinPackingSolutionDecoder(bool deserializing) : base(deserializing) { }
|
---|
| 74 | protected IdenticalBinPackingSolutionDecoder(IdenticalBinPackingSolutionDecoder<D,B,I, P> original, Cloner cloner)
|
---|
| 75 | : base(original, cloner) {
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | protected abstract PackingPlan<D, B, I> CreatePackingPlanFromEncoding(IPackingSolutionEncoding solution);
|
---|
| 79 |
|
---|
| 80 | public override IOperation Apply() {
|
---|
| 81 | PackingPlan<D, B, I> result = CreatePackingPlanFromEncoding(EncodedSolutionParameter.ActualValue);
|
---|
| 82 | PackingPlanParameter.ActualValue = result;
|
---|
| 83 | return base.Apply();
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 | }
|
---|