Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1966_HeuristicLab.BinPacking/old files/GroupingVector/Moves/GroupingMoveMaker.cs @ 16147

Last change on this file since 16147 was 14046, checked in by gkronber, 8 years ago

#1966: unified namespaces

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;
30
31
32namespace HeuristicLab.Encodings.PackingEncoding.GroupingVector {
33  [Item("Grouping Move Maker", "Peforms a grouping move on a given grouping vector and updates the quality.")]
34  [StorableClass]
35  public class GroupingMoveMaker : SingleSuccessorOperator, IMoveMaker, IGroupingVectorMoveOperator {
36    public override bool CanChangeName {
37      get { return false; }
38    }
39    public ILookupParameter<DoubleValue> QualityParameter {
40      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
41    }
42    public ILookupParameter<DoubleValue> MoveQualityParameter {
43      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
44    }
45    public ILookupParameter<IPackingMove> PackingMoveParameter {
46      get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
47    }
48    public ILookupParameter<GroupingVectorEncoding> GroupingVectorParameter {
49      get { return (ILookupParameter<GroupingVectorEncoding>)Parameters["GroupingVector"]; }
50    }
51    public ILookupParameter<IPackingPlan> PackingPlanParameter {
52      get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlan"]; }
53    }
54    public ILookupParameter<IPackingPlan> PackingPlanAfterMoveParameter {
55      get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlanAfterMove"]; }
56    }
57
58    [StorableConstructor]
59    protected GroupingMoveMaker(bool deserializing) : base(deserializing) { }
60    protected GroupingMoveMaker(GroupingMoveMaker original, Cloner cloner) : base(original, cloner) { }
61    public GroupingMoveMaker()
62      : base() {
63      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution."));
64      Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
65      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move."));
66      Parameters.Add(new LookupParameter<GroupingVectorEncoding>("GroupingVector", "The solution as grouping vector."));
67      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlan", "The currently best performing, decoded bin-packing solution represented as generalized packing-plan."));
68      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlanAfterMove", "The moved and decoded bin-packing solution represented as generalized packing-plan."));
69    }
70
71    public override IDeepCloneable Clone(Cloner cloner) {
72      return new GroupingMoveMaker(this, cloner);
73    }
74
75    public override IOperation Apply() {
76      IPackingMove move = PackingMoveParameter.ActualValue;
77      GroupingVectorEncoding groupingVector = GroupingVectorParameter.ActualValue;
78      DoubleValue moveQuality = MoveQualityParameter.ActualValue;
79      DoubleValue quality = QualityParameter.ActualValue;
80
81      groupingVector.GroupingVector = (move.GetSolutionAfterMove() as GroupingVectorEncoding).GroupingVector;
82      PackingPlanParameter.ActualValue = PackingPlanAfterMoveParameter.ActualValue;
83
84      quality.Value = moveQuality.Value;
85
86      return base.Apply();
87    }
88  }
89}
Note: See TracBrowser for help on using the repository browser.