Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/GroupingMoveMaker.cs @ 13032

Last change on this file since 13032 was 13032, checked in by gkronber, 9 years ago

#1966:

  • removed unused using
  • added/updated license headers
File size: 4.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Joseph Helm and 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.GroupingVector {
32  [Item("Grouping Move Maker", "Peforms a grouping move on a given grouping vector and updates the quality.")]
33  [StorableClass]
34  public class GroupingMoveMaker : SingleSuccessorOperator, IMoveMaker, IGroupingVectorMoveOperator {
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<GroupingVectorEncoding> GroupingVectorParameter {
48      get { return (ILookupParameter<GroupingVectorEncoding>)Parameters["GroupingVector"]; }
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 GroupingMoveMaker(bool deserializing) : base(deserializing) { }
59    protected GroupingMoveMaker(GroupingMoveMaker original, Cloner cloner) : base(original, cloner) { }
60    public GroupingMoveMaker()
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<GroupingVectorEncoding>("GroupingVector", "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 GroupingMoveMaker(this, cloner);
72    }
73
74    public override IOperation Apply() {
75      IPackingMove move = PackingMoveParameter.ActualValue;
76      GroupingVectorEncoding groupingVector = GroupingVectorParameter.ActualValue;
77      DoubleValue moveQuality = MoveQualityParameter.ActualValue;
78      DoubleValue quality = QualityParameter.ActualValue;
79
80      groupingVector.GroupingVector = (move.GetSolutionAfterMove() as GroupingVectorEncoding).GroupingVector;
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.