Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/Moves/MultiComponentVectorMoveMaker.cs @ 9599

Last change on this file since 9599 was 9563, checked in by jhelm, 12 years ago

#1966: Implemented additional Operator-Wrappers for PackingSequence and GroupingVector; Implemented additional problem-class for Rosenbauer-Problemstatement; Added marker-interfaces for decoder-types;

File size: 4.3 KB
Line 
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
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Operators;
26using HeuristicLab.Optimization;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29using HeuristicLab.Problems.BinPacking.Interfaces;
30
31namespace HeuristicLab.Encodings.PackingEncoding.MultiComponentVector {
32  [Item("MultiComponentVectorMoveMaker", "Peforms a single move on a given multi-component vector and updates the quality.")]
33  [StorableClass]
34  public class MultiComponentVectorMoveMaker : SingleSuccessorOperator, IMoveMaker, IMultiComponentVectorMoveOperator {
35    public override bool CanChangeName {
36      get { return false; }
37    }
38    public ILookupParameter<DoubleValue> QualityParameter {
39      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
40    }
41    public ILookupParameter<DoubleValue> MoveQualityParameter {
42      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
43    }
44    public ILookupParameter<IPackingMove> PackingMoveParameter {
45      get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
46    }
47    public ILookupParameter<MultiComponentVectorEncoding> MultiComponentVectorParameter {
48      get { return (ILookupParameter<MultiComponentVectorEncoding>)Parameters["MultiComponentVector"]; }
49    }
50    public ILookupParameter<IPackingPlan> PackingPlanParameter {
51      get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlan"]; }
52    }
53    public ILookupParameter<IPackingPlan> PackingPlanAfterMoveParameter {
54      get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlanAfterMove"]; }
55    }
56
57    [StorableConstructor]
58    protected MultiComponentVectorMoveMaker(bool deserializing) : base(deserializing) { }
59    protected MultiComponentVectorMoveMaker(MultiComponentVectorMoveMaker original, Cloner cloner) : base(original, cloner) { }
60    public MultiComponentVectorMoveMaker()
61      : base() {
62      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution."));
63      Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
64      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move."));
65      Parameters.Add(new LookupParameter<MultiComponentVectorEncoding>("MultiComponentVector", "The solution as grouping vector."));
66      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlan", "The currently best performing, decoded bin-packing solution represented as generalized packing-plan."));
67      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlanAfterMove", "The moved and decoded bin-packing solution represented as generalized packing-plan."));
68    }
69
70    public override IDeepCloneable Clone(Cloner cloner) {
71      return new MultiComponentVectorMoveMaker(this, cloner);
72    }
73
74    public override IOperation Apply() {
75      IPackingMove move = PackingMoveParameter.ActualValue;
76      MultiComponentVectorEncoding multiComponentVector = MultiComponentVectorParameter.ActualValue;
77      DoubleValue moveQuality = MoveQualityParameter.ActualValue;
78      DoubleValue quality = QualityParameter.ActualValue;
79
80      multiComponentVector.PackingInformations = (move.GetSolutionAfterMove() as MultiComponentVectorEncoding).PackingInformations;
81      PackingPlanParameter.ActualValue = PackingPlanAfterMoveParameter.ActualValue;
82
83      quality.Value = moveQuality.Value;
84
85      return base.Apply();
86    }
87  }
88}
Note: See TracBrowser for help on using the repository browser.