Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/MoveEvaluators/VRPMoveEvaluator.cs @ 3947

Last change on this file since 3947 was 3947, checked in by svonolfe, 14 years ago

Fixed some problems in the VRP implementation (#1039)

File size: 8.0 KB
Line 
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
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Operators;
27using HeuristicLab.Optimization;
28using HeuristicLab.Data;
29using HeuristicLab.Core;
30using HeuristicLab.Parameters;
31using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
32
33namespace HeuristicLab.Problems.VehicleRouting {
34  [Item("VRPMoveEvaluator", "A base class for operators which evaluate VRP moves.")]
35  [StorableClass]
36  public abstract class VRPMoveEvaluator : SingleSuccessorOperator, IVRPMoveEvaluator, IMoveOperator {
37    public override bool CanChangeName {
38      get { return false; }
39    }
40
41    public ILookupParameter<IVRPEncoding> VRPSolutionParameter {
42      get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPSolution"]; }
43    }
44    public ILookupParameter<DoubleMatrix> CoordinatesParameter {
45      get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }
46    }
47    public ILookupParameter<DoubleMatrix> DistanceMatrixParameter {
48      get { return (ILookupParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
49    }
50    public ILookupParameter<BoolValue> UseDistanceMatrixParameter {
51      get { return (ILookupParameter<BoolValue>)Parameters["UseDistanceMatrix"]; }
52    }
53    public ILookupParameter<IntValue> VehiclesParameter {
54      get { return (ILookupParameter<IntValue>)Parameters["Vehicles"]; }
55    }
56    public ILookupParameter<DoubleValue> CapacityParameter {
57      get { return (ILookupParameter<DoubleValue>)Parameters["Capacity"]; }
58    }
59    public ILookupParameter<DoubleArray> DemandParameter {
60      get { return (ILookupParameter<DoubleArray>)Parameters["Demand"]; }
61    }
62    public ILookupParameter<DoubleArray> ReadyTimeParameter {
63      get { return (ILookupParameter<DoubleArray>)Parameters["ReadyTime"]; }
64    }
65    public ILookupParameter<DoubleArray> DueTimeParameter {
66      get { return (ILookupParameter<DoubleArray>)Parameters["DueTime"]; }
67    }
68    public ILookupParameter<DoubleArray> ServiceTimeParameter {
69      get { return (ILookupParameter<DoubleArray>)Parameters["ServiceTime"]; }
70    }
71    public ILookupParameter<DoubleValue> FleetUsageFactor {
72      get { return (ILookupParameter<DoubleValue>)Parameters["FleetUsageFactor"]; }
73    }
74    public ILookupParameter<DoubleValue> TimeFactor {
75      get { return (ILookupParameter<DoubleValue>)Parameters["TimeFactor"]; }
76    }
77    public ILookupParameter<DoubleValue> DistanceFactor {
78      get { return (ILookupParameter<DoubleValue>)Parameters["DistanceFactor"]; }
79    }
80    public ILookupParameter<DoubleValue> OverloadPenalty {
81      get { return (ILookupParameter<DoubleValue>)Parameters["OverloadPenalty"]; }
82    }
83    public ILookupParameter<DoubleValue> TardinessPenalty {
84      get { return (ILookupParameter<DoubleValue>)Parameters["TardinessPenalty"]; }
85    }
86
87    public ILookupParameter<DoubleValue> QualityParameter {
88      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
89    }
90    public ILookupParameter<DoubleValue> MoveQualityParameter {
91      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
92    }
93    public ILookupParameter<DoubleValue> MoveVehcilesUtilizedParameter {
94      get { return (ILookupParameter<DoubleValue>)Parameters["MoveVehiclesUtilized"]; }
95    }
96    public ILookupParameter<DoubleValue> MoveTravelTimeParameter {
97      get { return (ILookupParameter<DoubleValue>)Parameters["MoveTravelTime"]; }
98    }
99    public ILookupParameter<DoubleValue> MoveDistanceParameter {
100      get { return (ILookupParameter<DoubleValue>)Parameters["MoveDistance"]; }
101    }
102    public ILookupParameter<DoubleValue> MoveOverloadParameter {
103      get { return (ILookupParameter<DoubleValue>)Parameters["MoveOverload"]; }
104    }
105    public ILookupParameter<DoubleValue> MoveTardinessParameter {
106      get { return (ILookupParameter<DoubleValue>)Parameters["MoveTardiness"]; }
107    }
108
109    protected VRPMoveEvaluator()
110      : base() {
111      Parameters.Add(new LookupParameter<IVRPEncoding>("VRPSolution", "The VRP solution."));
112      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of a VRP solution."));
113      Parameters.Add(new LookupParameter<DoubleValue>("MoveVehiclesUtilized", "The number of vehicles utilized."));
114      Parameters.Add(new LookupParameter<DoubleValue>("MoveTravelTime", "The total travel time."));
115      Parameters.Add(new LookupParameter<DoubleValue>("MoveDistance", "The distance."));
116      Parameters.Add(new LookupParameter<DoubleValue>("MoveOverload", "The overload."));
117      Parameters.Add(new LookupParameter<DoubleValue>("MoveTardiness", "The tardiness."));
118      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The evaluated quality of a move on a VRP solution."));
119      Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The coordinates of the cities."));
120      Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
121      Parameters.Add(new LookupParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false."));
122      Parameters.Add(new LookupParameter<IntValue>("Vehicles", "The number of vehicles."));
123      Parameters.Add(new LookupParameter<DoubleValue>("Capacity", "The capacity of each vehicle."));
124      Parameters.Add(new LookupParameter<DoubleArray>("Demand", "The demand of each customer."));
125      Parameters.Add(new LookupParameter<DoubleArray>("ReadyTime", "The ready time of each customer."));
126      Parameters.Add(new LookupParameter<DoubleArray>("DueTime", "The due time of each customer."));
127      Parameters.Add(new LookupParameter<DoubleArray>("ServiceTime", "The service time of each customer."));
128      Parameters.Add(new LookupParameter<DoubleValue>("FleetUsageFactor", "The fleet usage factor considered in the evaluation."));
129      Parameters.Add(new LookupParameter<DoubleValue>("TimeFactor", "The time factor considered in the evaluation."));
130      Parameters.Add(new LookupParameter<DoubleValue>("DistanceFactor", "The distance factor considered in the evaluation."));
131      Parameters.Add(new LookupParameter<DoubleValue>("OverloadPenalty", "The overload penalty considered in the evaluation."));
132      Parameters.Add(new LookupParameter<DoubleValue>("TardinessPenalty", "The tardiness penalty considered in the evaluation."));
133    }
134
135    protected abstract TourEvaluation GetMoveQuality();
136
137    public override IOperation Apply() {
138      TourEvaluation tourEval = GetMoveQuality();
139
140      MoveQualityParameter.ActualValue = new DoubleValue(tourEval.Quality);
141      MoveDistanceParameter.ActualValue = new DoubleValue(tourEval.Distance);
142      MoveVehcilesUtilizedParameter.ActualValue = new DoubleValue(tourEval.VehcilesUtilized);
143      MoveOverloadParameter.ActualValue = new DoubleValue(tourEval.Overload);
144      MoveTardinessParameter.ActualValue = new DoubleValue(tourEval.Tardiness);
145      MoveTravelTimeParameter.ActualValue = new DoubleValue(tourEval.TravelTime);
146
147      if (tourEval.Quality < tourEval.Distance) {
148      }
149
150      return base.Apply();
151    }
152  }
153}
Note: See TracBrowser for help on using the repository browser.