1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 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.Core;
|
---|
23 | using HeuristicLab.Data;
|
---|
24 | using HeuristicLab.Operators;
|
---|
25 | using HeuristicLab.Optimization;
|
---|
26 | using HeuristicLab.Parameters;
|
---|
27 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
28 | using HeuristicLab.Problems.VehicleRouting.Encodings;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Problems.VehicleRouting {
|
---|
31 | [Item("VRPMoveEvaluator", "A base class for operators which evaluate VRP moves.")]
|
---|
32 | [StorableClass]
|
---|
33 | public abstract class VRPMoveEvaluator : VRPOperator, IVRPMoveEvaluator, IMoveOperator {
|
---|
34 | public override bool CanChangeName {
|
---|
35 | get { return false; }
|
---|
36 | }
|
---|
37 |
|
---|
38 | public ILookupParameter<IVRPEncoding> VRPSolutionParameter {
|
---|
39 | get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPSolution"]; }
|
---|
40 | }
|
---|
41 |
|
---|
42 | public ILookupParameter<DoubleValue> FleetUsageFactor {
|
---|
43 | get { return (ILookupParameter<DoubleValue>)Parameters["FleetUsageFactor"]; }
|
---|
44 | }
|
---|
45 | public ILookupParameter<DoubleValue> TimeFactor {
|
---|
46 | get { return (ILookupParameter<DoubleValue>)Parameters["TimeFactor"]; }
|
---|
47 | }
|
---|
48 | public ILookupParameter<DoubleValue> DistanceFactor {
|
---|
49 | get { return (ILookupParameter<DoubleValue>)Parameters["DistanceFactor"]; }
|
---|
50 | }
|
---|
51 | public ILookupParameter<DoubleValue> OverloadPenalty {
|
---|
52 | get { return (ILookupParameter<DoubleValue>)Parameters["OverloadPenalty"]; }
|
---|
53 | }
|
---|
54 | public ILookupParameter<DoubleValue> TardinessPenalty {
|
---|
55 | get { return (ILookupParameter<DoubleValue>)Parameters["TardinessPenalty"]; }
|
---|
56 | }
|
---|
57 |
|
---|
58 | public ILookupParameter<DoubleValue> QualityParameter {
|
---|
59 | get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
|
---|
60 | }
|
---|
61 | public ILookupParameter<DoubleValue> MoveQualityParameter {
|
---|
62 | get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
|
---|
63 | }
|
---|
64 | public ILookupParameter<DoubleValue> MoveVehcilesUtilizedParameter {
|
---|
65 | get { return (ILookupParameter<DoubleValue>)Parameters["MoveVehiclesUtilized"]; }
|
---|
66 | }
|
---|
67 | public ILookupParameter<DoubleValue> MoveTravelTimeParameter {
|
---|
68 | get { return (ILookupParameter<DoubleValue>)Parameters["MoveTravelTime"]; }
|
---|
69 | }
|
---|
70 | public ILookupParameter<DoubleValue> MoveDistanceParameter {
|
---|
71 | get { return (ILookupParameter<DoubleValue>)Parameters["MoveDistance"]; }
|
---|
72 | }
|
---|
73 | public ILookupParameter<DoubleValue> MoveOverloadParameter {
|
---|
74 | get { return (ILookupParameter<DoubleValue>)Parameters["MoveOverload"]; }
|
---|
75 | }
|
---|
76 | public ILookupParameter<DoubleValue> MoveTardinessParameter {
|
---|
77 | get { return (ILookupParameter<DoubleValue>)Parameters["MoveTardiness"]; }
|
---|
78 | }
|
---|
79 |
|
---|
80 | protected VRPMoveEvaluator()
|
---|
81 | : base() {
|
---|
82 | Parameters.Add(new LookupParameter<IVRPEncoding>("VRPSolution", "The VRP solution."));
|
---|
83 | Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of a VRP solution."));
|
---|
84 | Parameters.Add(new LookupParameter<DoubleValue>("MoveVehiclesUtilized", "The number of vehicles utilized."));
|
---|
85 | Parameters.Add(new LookupParameter<DoubleValue>("MoveTravelTime", "The total travel time."));
|
---|
86 | Parameters.Add(new LookupParameter<DoubleValue>("MoveDistance", "The distance."));
|
---|
87 | Parameters.Add(new LookupParameter<DoubleValue>("MoveOverload", "The overload."));
|
---|
88 | Parameters.Add(new LookupParameter<DoubleValue>("MoveTardiness", "The tardiness."));
|
---|
89 | Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The evaluated quality of a move on a VRP solution."));
|
---|
90 | Parameters.Add(new LookupParameter<DoubleValue>("FleetUsageFactor", "The fleet usage factor considered in the evaluation."));
|
---|
91 | Parameters.Add(new LookupParameter<DoubleValue>("TimeFactor", "The time factor considered in the evaluation."));
|
---|
92 | Parameters.Add(new LookupParameter<DoubleValue>("DistanceFactor", "The distance factor considered in the evaluation."));
|
---|
93 | Parameters.Add(new LookupParameter<DoubleValue>("OverloadPenalty", "The overload penalty considered in the evaluation."));
|
---|
94 | Parameters.Add(new LookupParameter<DoubleValue>("TardinessPenalty", "The tardiness penalty considered in the evaluation."));
|
---|
95 | }
|
---|
96 |
|
---|
97 | protected abstract TourEvaluation GetMoveQuality();
|
---|
98 |
|
---|
99 | public override IOperation Apply() {
|
---|
100 | TourEvaluation tourEval = GetMoveQuality();
|
---|
101 |
|
---|
102 | MoveQualityParameter.ActualValue = new DoubleValue(tourEval.Quality);
|
---|
103 | MoveDistanceParameter.ActualValue = new DoubleValue(tourEval.Distance);
|
---|
104 | MoveVehcilesUtilizedParameter.ActualValue = new DoubleValue(tourEval.VehcilesUtilized);
|
---|
105 | MoveOverloadParameter.ActualValue = new DoubleValue(tourEval.Overload);
|
---|
106 | MoveTardinessParameter.ActualValue = new DoubleValue(tourEval.Tardiness);
|
---|
107 | MoveTravelTimeParameter.ActualValue = new DoubleValue(tourEval.TravelTime);
|
---|
108 |
|
---|
109 | return base.Apply();
|
---|
110 | }
|
---|
111 | }
|
---|
112 | }
|
---|