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 HeuristicLab.Common;
|
---|
23 | using HeuristicLab.Core;
|
---|
24 | using HeuristicLab.Data;
|
---|
25 | using HeuristicLab.Operators;
|
---|
26 | using HeuristicLab.Optimization;
|
---|
27 | using HeuristicLab.Parameters;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 | using HeuristicLab.Problems.BinPacking.Interfaces;
|
---|
30 |
|
---|
31 | namespace HeuristicLab.Encodings.PackingEncoding.GroupingVector {
|
---|
32 | [Item("Single Grouping Move Maker", "Peforms a single grouping move on a given grouping vector and updates the quality.")]
|
---|
33 | [StorableClass]
|
---|
34 | public class SingleGroupingMoveMaker : 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 SingleGroupingMoveMaker(bool deserializing) : base(deserializing) { }
|
---|
59 | protected SingleGroupingMoveMaker(SingleGroupingMoveMaker original, Cloner cloner) : base(original, cloner) { }
|
---|
60 | public SingleGroupingMoveMaker()
|
---|
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 SingleGroupingMoveMaker(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 | }
|
---|