Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingSolutionDecoder.cs @ 15785

Last change on this file since 15785 was 14151, checked in by gkronber, 8 years ago

#1966: added abstract problem and move evaluator classes and implemented 2d bin packing problem based on integer vector encoding

File size: 4.0 KB
RevLine 
[9495]1#region License Information
2/* HeuristicLab
[13032]3 * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[9495]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
[9495]23using HeuristicLab.Core;
24using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
25using HeuristicLab.Common;
26using HeuristicLab.Operators;
27using HeuristicLab.Parameters;
28using HeuristicLab.Data;
29
[14046]30namespace HeuristicLab.Problems.BinPacking {
[9495]31
32  [Item("Packing-Solution Decoder", "An operator to create a concrete bin packing solution from a given encoding-instance.")]
33  [StorableClass]
34  public abstract class PackingSolutionDecoder<D, B, I> : SingleSuccessorOperator, IPackingSolutionDecoder
[14048]35    where D : class, IPackingPosition
[14045]36    where B : PackingShape<D>
[9495]37    where I : PackingShape<D>, IPackingItem {
38
39    public ILookupParameter<IRandom> RandomParameter {
40      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
41    }
[9563]42    private ILookupParameter<ItemList<I>> PackingItemMeasuresParameter {
[9495]43      get { return (LookupParameter<ItemList<I>>)Parameters["PackingItemMeasures"]; }
44    }
[9563]45    private ILookupParameter<B> PackingBinMeasuresParameter {
[9495]46      get { return (LookupParameter<B>)Parameters["PackingBinMeasures"]; }
47    }
[9563]48    public ILookupParameter<IItem> EncodedSolutionParameter {
49      get { return (ILookupParameter<IItem>)Parameters["EncodedSolution"]; }
[9495]50    }
[14151]51    public ILookupParameter<PackingPlan<D, B, I>> PackingPlanParameter {
[9495]52      get { return (ILookupParameter<PackingPlan<D, B, I>>)Parameters["PackingPlan"]; }
53    }
[9596]54    public ValueParameter<BoolValue> StackingConstraintsParameter {
55      get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; }
56    }
[9495]57
58
[14151]59    public PackingSolutionDecoder()
60      : base() {
[9563]61      Parameters.Add(new LookupParameter<IItem>("EncodedSolution", "The new bin-packing solution represented as encoding."));
[9495]62      Parameters.Add(new LookupParameter<PackingPlan<D, B, I>>("PackingPlan", "The decoded bin-packing solution represented as generalized packing plan."));
63      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
64      Parameters.Add(new LookupParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data taken from the bin-packing problem-instance."));
65      Parameters.Add(new LookupParameter<B>("PackingBinMeasures", "Packing-bin data taken from the bin-packing problem-instance."));
[13613]66      Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stacking constraints should be enforced or not.", new BoolValue(true)));
[9495]67    }
68
69    [StorableConstructor]
70    protected PackingSolutionDecoder(bool deserializing) : base(deserializing) { }
[14151]71    protected PackingSolutionDecoder(PackingSolutionDecoder<D, B, I> original, Cloner cloner)
[9495]72      : base(original, cloner) {
73    }
74
[9563]75    public abstract PackingPlan<D, B, I> CreatePackingPlanFromEncoding(IItem solution, B binMeasures, ItemList<I> itemMeasures);
[9495]76
77    public override IOperation Apply() {
78      PackingPlan<D, B, I> result = CreatePackingPlanFromEncoding(EncodedSolutionParameter.ActualValue, PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);
79      PackingPlanParameter.ActualValue = result;
80      return base.Apply();
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.