Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceSpeedUp/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveMaker.cs

Last change on this file was 5445, checked in by swagner, 14 years ago

Updated year of copyrights (#1406)

File size: 6.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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.Optimization;
26using HeuristicLab.Parameters;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
30  [Item("MultiVRPMoveMaker", "Peforms multiple moves on a given VRP encoding and updates the quality.")]
31  [StorableClass]
32  public class LambdaInterchangeMoveMaker : VRPMoveOperator, IMoveMaker, IMultiVRPMoveOperator {
33    public override bool CanChangeName {
34      get { return false; }
35    }
36    public ILookupParameter<DoubleValue> QualityParameter {
37      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
38    }
39    public ILookupParameter<DoubleValue> MoveQualityParameter {
40      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
41    }
42    public ILookupParameter VRPMoveParameter {
43      get { return (ILookupParameter)Parameters["VRPMove"]; }
44    }
45    public ILookupParameter<IRandom> RandomParameter {
46      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
47    }
48
49    public ILookupParameter<DoubleValue> MoveVehcilesUtilizedParameter {
50      get { return (ILookupParameter<DoubleValue>)Parameters["MoveVehiclesUtilized"]; }
51    }
52    public ILookupParameter<DoubleValue> MoveTravelTimeParameter {
53      get { return (ILookupParameter<DoubleValue>)Parameters["MoveTravelTime"]; }
54    }
55    public ILookupParameter<DoubleValue> MoveDistanceParameter {
56      get { return (ILookupParameter<DoubleValue>)Parameters["MoveDistance"]; }
57    }
58    public ILookupParameter<DoubleValue> MoveOverloadParameter {
59      get { return (ILookupParameter<DoubleValue>)Parameters["MoveOverload"]; }
60    }
61    public ILookupParameter<DoubleValue> MoveTardinessParameter {
62      get { return (ILookupParameter<DoubleValue>)Parameters["MoveTardiness"]; }
63    }
64
65    public ILookupParameter<DoubleValue> VehcilesUtilizedParameter {
66      get { return (ILookupParameter<DoubleValue>)Parameters["VehiclesUtilized"]; }
67    }
68    public ILookupParameter<DoubleValue> TravelTimeParameter {
69      get { return (ILookupParameter<DoubleValue>)Parameters["TravelTime"]; }
70    }
71    public ILookupParameter<DoubleValue> DistanceParameter {
72      get { return (ILookupParameter<DoubleValue>)Parameters["Distance"]; }
73    }
74    public ILookupParameter<DoubleValue> OverloadParameter {
75      get { return (ILookupParameter<DoubleValue>)Parameters["Overload"]; }
76    }
77    public ILookupParameter<DoubleValue> TardinessParameter {
78      get { return (ILookupParameter<DoubleValue>)Parameters["Tardiness"]; }
79    }
80
81    [StorableConstructor]
82    protected LambdaInterchangeMoveMaker(bool deserializing) : base(deserializing) { }
83    protected LambdaInterchangeMoveMaker(LambdaInterchangeMoveMaker original, Cloner cloner) : base(original, cloner) { }
84    public override IDeepCloneable Clone(Cloner cloner) {
85      return new LambdaInterchangeMoveMaker(this, cloner);
86    }
87
88    public LambdaInterchangeMoveMaker()
89      : base() {
90      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution."));
91      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move."));
92      Parameters.Add(new LookupParameter<IVRPMove>("VRPMove", "The generated moves."));
93      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
94
95      Parameters.Add(new LookupParameter<DoubleValue>("MoveVehiclesUtilized", "The number of vehicles utilized."));
96      Parameters.Add(new LookupParameter<DoubleValue>("MoveTravelTime", "The total travel time."));
97      Parameters.Add(new LookupParameter<DoubleValue>("MoveDistance", "The distance."));
98      Parameters.Add(new LookupParameter<DoubleValue>("MoveOverload", "The overload."));
99      Parameters.Add(new LookupParameter<DoubleValue>("MoveTardiness", "The tardiness."));
100
101      Parameters.Add(new LookupParameter<DoubleValue>("VehiclesUtilized", "The number of vehicles utilized."));
102      Parameters.Add(new LookupParameter<DoubleValue>("TravelTime", "The total travel time."));
103      Parameters.Add(new LookupParameter<DoubleValue>("Distance", "The distance."));
104      Parameters.Add(new LookupParameter<DoubleValue>("Overload", "The overload."));
105      Parameters.Add(new LookupParameter<DoubleValue>("Tardiness", "The tardiness."));
106
107    }
108
109    public override IOperation Apply() {
110      IOperation next = base.Apply();
111
112      IVRPEncoding solution = VRPToursParameter.ActualValue as IVRPEncoding;
113
114      IVRPMove move = VRPMoveParameter.ActualValue as IVRPMove;
115      DoubleValue moveQuality = MoveQualityParameter.ActualValue;
116      DoubleValue quality = QualityParameter.ActualValue;
117
118      //perform move
119      VRPToursParameter.ActualValue = move.MakeMove();
120
121      quality.Value = moveQuality.Value;
122      VehcilesUtilizedParameter.ActualValue = MoveVehcilesUtilizedParameter.ActualValue;
123      TravelTimeParameter.ActualValue = MoveTravelTimeParameter.ActualValue;
124      DistanceParameter.ActualValue = MoveDistanceParameter.ActualValue;
125      OverloadParameter.ActualValue = MoveOverloadParameter.ActualValue;
126      TardinessParameter.ActualValue = MoveTardinessParameter.ActualValue;
127
128      return next;
129    }
130  }
131}
Note: See TracBrowser for help on using the repository browser.