[3938] | 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 |
|
---|
[4068] | 22 | using HeuristicLab.Core;
|
---|
| 23 | using HeuristicLab.Data;
|
---|
[3938] | 24 | using HeuristicLab.Operators;
|
---|
| 25 | using HeuristicLab.Optimization;
|
---|
| 26 | using HeuristicLab.Parameters;
|
---|
| 27 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[4154] | 28 | using HeuristicLab.Problems.VehicleRouting.Encodings;
|
---|
[3938] | 29 |
|
---|
| 30 | namespace HeuristicLab.Problems.VehicleRouting {
|
---|
| 31 | [Item("VRPMoveEvaluator", "A base class for operators which evaluate VRP moves.")]
|
---|
| 32 | [StorableClass]
|
---|
[4154] | 33 | public abstract class VRPMoveEvaluator : VRPOperator, IVRPMoveEvaluator, IMoveOperator {
|
---|
[3938] | 34 | public override bool CanChangeName {
|
---|
| 35 | get { return false; }
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[4179] | 38 | public ILookupParameter<IVRPEncoding> VRPToursParameter {
|
---|
| 39 | get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPTours"]; }
|
---|
[3938] | 40 | }
|
---|
[4154] | 41 |
|
---|
[3947] | 42 | public ILookupParameter<DoubleValue> FleetUsageFactor {
|
---|
[4179] | 43 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalFleetUsageFactor"]; }
|
---|
[3938] | 44 | }
|
---|
[3947] | 45 | public ILookupParameter<DoubleValue> TimeFactor {
|
---|
[4179] | 46 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalTimeFactor"]; }
|
---|
[3938] | 47 | }
|
---|
[3947] | 48 | public ILookupParameter<DoubleValue> DistanceFactor {
|
---|
[4179] | 49 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalDistanceFactor"]; }
|
---|
[3938] | 50 | }
|
---|
[3947] | 51 | public ILookupParameter<DoubleValue> OverloadPenalty {
|
---|
[4179] | 52 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalOverloadPenalty"]; }
|
---|
[3938] | 53 | }
|
---|
[3947] | 54 | public ILookupParameter<DoubleValue> TardinessPenalty {
|
---|
[4179] | 55 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalTardinessPenalty"]; }
|
---|
[3938] | 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 |
|
---|
[4179] | 80 | [StorableConstructor]
|
---|
| 81 | protected VRPMoveEvaluator(bool deserializing) : base(deserializing) { }
|
---|
| 82 |
|
---|
[3938] | 83 | protected VRPMoveEvaluator()
|
---|
| 84 | : base() {
|
---|
[4179] | 85 | Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The VRP tours."));
|
---|
[3938] | 86 | Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of a VRP solution."));
|
---|
| 87 | Parameters.Add(new LookupParameter<DoubleValue>("MoveVehiclesUtilized", "The number of vehicles utilized."));
|
---|
| 88 | Parameters.Add(new LookupParameter<DoubleValue>("MoveTravelTime", "The total travel time."));
|
---|
| 89 | Parameters.Add(new LookupParameter<DoubleValue>("MoveDistance", "The distance."));
|
---|
| 90 | Parameters.Add(new LookupParameter<DoubleValue>("MoveOverload", "The overload."));
|
---|
| 91 | Parameters.Add(new LookupParameter<DoubleValue>("MoveTardiness", "The tardiness."));
|
---|
| 92 | Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The evaluated quality of a move on a VRP solution."));
|
---|
[4179] | 93 | Parameters.Add(new LookupParameter<DoubleValue>("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation."));
|
---|
| 94 | Parameters.Add(new LookupParameter<DoubleValue>("EvalTimeFactor", "The time factor considered in the evaluation."));
|
---|
| 95 | Parameters.Add(new LookupParameter<DoubleValue>("EvalDistanceFactor", "The distance factor considered in the evaluation."));
|
---|
| 96 | Parameters.Add(new LookupParameter<DoubleValue>("EvalOverloadPenalty", "The overload penalty considered in the evaluation."));
|
---|
| 97 | Parameters.Add(new LookupParameter<DoubleValue>("EvalTardinessPenalty", "The tardiness penalty considered in the evaluation."));
|
---|
[3938] | 98 | }
|
---|
| 99 |
|
---|
| 100 | protected abstract TourEvaluation GetMoveQuality();
|
---|
| 101 |
|
---|
| 102 | public override IOperation Apply() {
|
---|
| 103 | TourEvaluation tourEval = GetMoveQuality();
|
---|
| 104 |
|
---|
| 105 | MoveQualityParameter.ActualValue = new DoubleValue(tourEval.Quality);
|
---|
| 106 | MoveDistanceParameter.ActualValue = new DoubleValue(tourEval.Distance);
|
---|
| 107 | MoveVehcilesUtilizedParameter.ActualValue = new DoubleValue(tourEval.VehcilesUtilized);
|
---|
| 108 | MoveOverloadParameter.ActualValue = new DoubleValue(tourEval.Overload);
|
---|
| 109 | MoveTardinessParameter.ActualValue = new DoubleValue(tourEval.Tardiness);
|
---|
| 110 | MoveTravelTimeParameter.ActualValue = new DoubleValue(tourEval.TravelTime);
|
---|
| 111 |
|
---|
| 112 | return base.Apply();
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 | }
|
---|