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