[3938] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[7259] | 3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[3938] | 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 |
|
---|
[4722] | 22 | using HeuristicLab.Common;
|
---|
[4068] | 23 | using HeuristicLab.Core;
|
---|
| 24 | using HeuristicLab.Data;
|
---|
[3938] | 25 | using HeuristicLab.Optimization;
|
---|
| 26 | using HeuristicLab.Parameters;
|
---|
| 27 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 28 |
|
---|
| 29 | namespace HeuristicLab.Problems.VehicleRouting {
|
---|
| 30 | [Item("VRPMoveEvaluator", "A base class for operators which evaluate VRP moves.")]
|
---|
| 31 | [StorableClass]
|
---|
[4154] | 32 | public abstract class VRPMoveEvaluator : VRPOperator, IVRPMoveEvaluator, IMoveOperator {
|
---|
[3938] | 33 | public override bool CanChangeName {
|
---|
| 34 | get { return false; }
|
---|
| 35 | }
|
---|
| 36 |
|
---|
[4179] | 37 | public ILookupParameter<IVRPEncoding> VRPToursParameter {
|
---|
| 38 | get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPTours"]; }
|
---|
[3938] | 39 | }
|
---|
[4722] | 40 |
|
---|
[3947] | 41 | public ILookupParameter<DoubleValue> FleetUsageFactor {
|
---|
[4179] | 42 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalFleetUsageFactor"]; }
|
---|
[3938] | 43 | }
|
---|
[3947] | 44 | public ILookupParameter<DoubleValue> TimeFactor {
|
---|
[4179] | 45 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalTimeFactor"]; }
|
---|
[3938] | 46 | }
|
---|
[3947] | 47 | public ILookupParameter<DoubleValue> DistanceFactor {
|
---|
[4179] | 48 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalDistanceFactor"]; }
|
---|
[3938] | 49 | }
|
---|
[3947] | 50 | public ILookupParameter<DoubleValue> OverloadPenalty {
|
---|
[4179] | 51 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalOverloadPenalty"]; }
|
---|
[3938] | 52 | }
|
---|
[3947] | 53 | public ILookupParameter<DoubleValue> TardinessPenalty {
|
---|
[4179] | 54 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalTardinessPenalty"]; }
|
---|
[3938] | 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 |
|
---|
[4179] | 79 | [StorableConstructor]
|
---|
| 80 | protected VRPMoveEvaluator(bool deserializing) : base(deserializing) { }
|
---|
[4722] | 81 | protected VRPMoveEvaluator(VRPMoveEvaluator original, Cloner cloner) : base(original, cloner) { }
|
---|
[3938] | 82 | protected VRPMoveEvaluator()
|
---|
| 83 | : base() {
|
---|
[4179] | 84 | Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The VRP tours."));
|
---|
[3938] | 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."));
|
---|
[4179] | 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."));
|
---|
[3938] | 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 | }
|
---|