Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Moves/NMoveMaker.cs @ 7412

Last change on this file since 7412 was 7412, checked in by abeham, 12 years ago

#1614: worked on GQAP and GRASP+PR

File size: 5.2 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.Encodings.IntegerVectorEncoding;
26using HeuristicLab.Operators;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
31  [Item("NMoveMaker", "Performs an n-move.")]
32  [StorableClass]
33  public class NMoveMaker : SingleSuccessorOperator, IGQAPNMoveOperator {
34
35    public ILookupParameter<IntegerVector> AssignmentParameter {
36      get { return (ILookupParameter<IntegerVector>)Parameters["Assignment"]; }
37    }
38    public ILookupParameter<NMove> MoveParameter {
39      get { return (ILookupParameter<NMove>)Parameters["Move"]; }
40    }
41    public ILookupParameter<DoubleValue> QualityParameter {
42      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
43    }
44    public ILookupParameter<DoubleValue> FlowDistanceQualityParameter {
45      get { return (ILookupParameter<DoubleValue>)Parameters["FlowDistanceQuality"]; }
46    }
47    public ILookupParameter<DoubleValue> InstallationQualityParameter {
48      get { return (ILookupParameter<DoubleValue>)Parameters["InstallationQuality"]; }
49    }
50    public ILookupParameter<DoubleValue> OverbookedCapacityParameter {
51      get { return (ILookupParameter<DoubleValue>)Parameters["OverbookedCapacity"]; }
52    }
53    public ILookupParameter<DoubleValue> MoveQualityParameter {
54      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
55    }
56    public ILookupParameter<DoubleValue> MoveFlowDistanceQualityParameter {
57      get { return (ILookupParameter<DoubleValue>)Parameters["MoveFlowDistanceQuality"]; }
58    }
59    public ILookupParameter<DoubleValue> MoveInstallationQualityParameter {
60      get { return (ILookupParameter<DoubleValue>)Parameters["MoveInstallationQuality"]; }
61    }
62    public ILookupParameter<DoubleValue> MoveOverbookedCapacityParameter {
63      get { return (ILookupParameter<DoubleValue>)Parameters["MoveOverbookedCapacity"]; }
64    }
65
66    [StorableConstructor]
67    protected NMoveMaker(bool deserializing) : base(deserializing) { }
68    protected NMoveMaker(NMoveMaker original, Cloner cloner) : base(original, cloner) { }
69    public NMoveMaker()
70      : base() {
71      Parameters.Add(new LookupParameter<IntegerVector>("Assignment", "The equipment-location assignment vector."));
72      Parameters.Add(new LookupParameter<NMove>("Move", "The move to perform."));
73      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The solution quality."));
74      Parameters.Add(new LookupParameter<DoubleValue>("FlowDistanceQuality", "The quality regarding the flow-distance criteria."));
75      Parameters.Add(new LookupParameter<DoubleValue>("InstallationQuality", "The quality regarding the installation costs."));
76      Parameters.Add(new LookupParameter<DoubleValue>("OverbookedCapacity", "The sum of the overbooked capacities relative to the capacity of each location."));
77      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the move if it would be applied."));
78      Parameters.Add(new LookupParameter<DoubleValue>("MoveFlowDistanceQuality", "The quality of the move regarding the flow-distance criteria."));
79      Parameters.Add(new LookupParameter<DoubleValue>("MoveInstallationQuality", "The quality of the move regarding the installation costs."));
80      Parameters.Add(new LookupParameter<DoubleValue>("MoveOverbookedCapacity", "The sum of the overbooked capacities of the move relative to the capacity of each location."));
81    }
82
83    public override IDeepCloneable Clone(Cloner cloner) {
84      return new NMoveMaker(this, cloner);
85    }
86
87    public static void Apply(IntegerVector vector, NMove move) {
88      for (int i = 0; i < move.N; i++) {
89        vector[move.Equipments[i]] = move.Locations[i];
90      }
91    }
92
93    public override IOperation Apply() {
94      Apply(AssignmentParameter.ActualValue, MoveParameter.ActualValue);
95      QualityParameter.ActualValue.Value = MoveQualityParameter.ActualValue.Value;
96      FlowDistanceQualityParameter.ActualValue.Value = MoveFlowDistanceQualityParameter.ActualValue.Value;
97      InstallationQualityParameter.ActualValue.Value = MoveInstallationQualityParameter.ActualValue.Value;
98      OverbookedCapacityParameter.ActualValue.Value = MoveOverbookedCapacityParameter.ActualValue.Value;
99      return base.Apply();
100    }
101  }
102}
Note: See TracBrowser for help on using the repository browser.