Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceSpeedUp/HeuristicLab.Problems.VehicleRouting/3.3/MoveEvaluators/VRPMoveEvaluator.cs @ 9283

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

Updated year of copyrights (#1406)

File size: 5.7 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 {
30  [Item("VRPMoveEvaluator", "A base class for operators which evaluate VRP moves.")]
31  [StorableClass]
32  public abstract class VRPMoveEvaluator : VRPOperator, IVRPMoveEvaluator, IMoveOperator {
33    public override bool CanChangeName {
34      get { return false; }
35    }
36
37    public ILookupParameter<IVRPEncoding> VRPToursParameter {
38      get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPTours"]; }
39    }
40
41    public ILookupParameter<DoubleValue> FleetUsageFactor {
42      get { return (ILookupParameter<DoubleValue>)Parameters["EvalFleetUsageFactor"]; }
43    }
44    public ILookupParameter<DoubleValue> TimeFactor {
45      get { return (ILookupParameter<DoubleValue>)Parameters["EvalTimeFactor"]; }
46    }
47    public ILookupParameter<DoubleValue> DistanceFactor {
48      get { return (ILookupParameter<DoubleValue>)Parameters["EvalDistanceFactor"]; }
49    }
50    public ILookupParameter<DoubleValue> OverloadPenalty {
51      get { return (ILookupParameter<DoubleValue>)Parameters["EvalOverloadPenalty"]; }
52    }
53    public ILookupParameter<DoubleValue> TardinessPenalty {
54      get { return (ILookupParameter<DoubleValue>)Parameters["EvalTardinessPenalty"]; }
55    }
56
57    public ILookupParameter<DoubleValue> QualityParameter {
58      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
59    }
60    public ILookupParameter<DoubleValue> MoveQualityParameter {
61      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
62    }
63    public ILookupParameter<DoubleValue> MoveVehcilesUtilizedParameter {
64      get { return (ILookupParameter<DoubleValue>)Parameters["MoveVehiclesUtilized"]; }
65    }
66    public ILookupParameter<DoubleValue> MoveTravelTimeParameter {
67      get { return (ILookupParameter<DoubleValue>)Parameters["MoveTravelTime"]; }
68    }
69    public ILookupParameter<DoubleValue> MoveDistanceParameter {
70      get { return (ILookupParameter<DoubleValue>)Parameters["MoveDistance"]; }
71    }
72    public ILookupParameter<DoubleValue> MoveOverloadParameter {
73      get { return (ILookupParameter<DoubleValue>)Parameters["MoveOverload"]; }
74    }
75    public ILookupParameter<DoubleValue> MoveTardinessParameter {
76      get { return (ILookupParameter<DoubleValue>)Parameters["MoveTardiness"]; }
77    }
78
79    [StorableConstructor]
80    protected VRPMoveEvaluator(bool deserializing) : base(deserializing) { }
81    protected VRPMoveEvaluator(VRPMoveEvaluator original, Cloner cloner) : base(original, cloner) { }
82    protected VRPMoveEvaluator()
83      : base() {
84      Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The VRP tours."));
85      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of a VRP solution."));
86      Parameters.Add(new LookupParameter<DoubleValue>("MoveVehiclesUtilized", "The number of vehicles utilized."));
87      Parameters.Add(new LookupParameter<DoubleValue>("MoveTravelTime", "The total travel time."));
88      Parameters.Add(new LookupParameter<DoubleValue>("MoveDistance", "The distance."));
89      Parameters.Add(new LookupParameter<DoubleValue>("MoveOverload", "The overload."));
90      Parameters.Add(new LookupParameter<DoubleValue>("MoveTardiness", "The tardiness."));
91      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The evaluated quality of a move on a VRP solution."));
92      Parameters.Add(new LookupParameter<DoubleValue>("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation."));
93      Parameters.Add(new LookupParameter<DoubleValue>("EvalTimeFactor", "The time factor considered in the evaluation."));
94      Parameters.Add(new LookupParameter<DoubleValue>("EvalDistanceFactor", "The distance factor considered in the evaluation."));
95      Parameters.Add(new LookupParameter<DoubleValue>("EvalOverloadPenalty", "The overload penalty considered in the evaluation."));
96      Parameters.Add(new LookupParameter<DoubleValue>("EvalTardinessPenalty", "The tardiness penalty considered in the evaluation."));
97    }
98
99    protected abstract TourEvaluation GetMoveQuality();
100
101    public override IOperation Apply() {
102      TourEvaluation tourEval = GetMoveQuality();
103
104      MoveQualityParameter.ActualValue = new DoubleValue(tourEval.Quality);
105      MoveDistanceParameter.ActualValue = new DoubleValue(tourEval.Distance);
106      MoveVehcilesUtilizedParameter.ActualValue = new DoubleValue(tourEval.VehcilesUtilized);
107      MoveOverloadParameter.ActualValue = new DoubleValue(tourEval.Overload);
108      MoveTardinessParameter.ActualValue = new DoubleValue(tourEval.Tardiness);
109      MoveTravelTimeParameter.ActualValue = new DoubleValue(tourEval.TravelTime);
110
111      return base.Apply();
112    }
113  }
114}
Note: See TracBrowser for help on using the repository browser.