[4268] | 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.Encodings.PermutationEncoding;
|
---|
| 24 | using HeuristicLab.Parameters;
|
---|
| 25 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 26 | using HeuristicLab.Data;
|
---|
| 27 | using HeuristicLab.Optimization;
|
---|
| 28 |
|
---|
| 29 | namespace HeuristicLab.Problems.VehicleRouting.Encodings.Prins {
|
---|
| 30 | [Item("PrinsManipulator", "An operator which manipulates a VRP representation.")]
|
---|
| 31 | [StorableClass]
|
---|
| 32 | public abstract class PrinsManipulator : VRPManipulator, IStochasticOperator, IPrinsOperator {
|
---|
| 33 | public ILookupParameter<IRandom> RandomParameter {
|
---|
| 34 | get { return (LookupParameter<IRandom>)Parameters["Random"]; }
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | public ILookupParameter<DoubleValue> FleetUsageFactor {
|
---|
| 38 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalFleetUsageFactor"]; }
|
---|
| 39 | }
|
---|
| 40 | public ILookupParameter<DoubleValue> TimeFactor {
|
---|
| 41 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalTimeFactor"]; }
|
---|
| 42 | }
|
---|
| 43 | public ILookupParameter<DoubleValue> DistanceFactor {
|
---|
| 44 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalDistanceFactor"]; }
|
---|
| 45 | }
|
---|
| 46 | public ILookupParameter<DoubleValue> OverloadPenalty {
|
---|
| 47 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalOverloadPenalty"]; }
|
---|
| 48 | }
|
---|
| 49 | public ILookupParameter<DoubleValue> TardinessPenalty {
|
---|
| 50 | get { return (ILookupParameter<DoubleValue>)Parameters["EvalTardinessPenalty"]; }
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | [StorableConstructor]
|
---|
| 54 | protected PrinsManipulator(bool deserializing) : base(deserializing) { }
|
---|
| 55 |
|
---|
| 56 | public PrinsManipulator()
|
---|
| 57 | : base() {
|
---|
| 58 | Parameters.Add(new LookupParameter<DoubleValue>("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation."));
|
---|
| 59 | Parameters.Add(new LookupParameter<DoubleValue>("EvalTimeFactor", "The time factor considered in the evaluation."));
|
---|
| 60 | Parameters.Add(new LookupParameter<DoubleValue>("EvalDistanceFactor", "The distance factor considered in the evaluation."));
|
---|
| 61 | Parameters.Add(new LookupParameter<DoubleValue>("EvalOverloadPenalty", "The overload penalty considered in the evaluation."));
|
---|
| 62 | Parameters.Add(new LookupParameter<DoubleValue>("EvalTardinessPenalty", "The tardiness penalty considered in the evaluation."));
|
---|
| 63 |
|
---|
| 64 | Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | protected abstract void Manipulate(IRandom random, PrinsEncoding individual);
|
---|
| 68 |
|
---|
| 69 | public override IOperation Apply() {
|
---|
| 70 | IVRPEncoding solution = VRPToursParameter.ActualValue;
|
---|
| 71 | if (!(solution is PrinsEncoding)) {
|
---|
| 72 | VRPToursParameter.ActualValue = PrinsEncoding.ConvertFrom(solution,
|
---|
| 73 | Cities,
|
---|
| 74 | DueTimeParameter.ActualValue,
|
---|
| 75 | ServiceTimeParameter.ActualValue,
|
---|
| 76 | ReadyTimeParameter.ActualValue,
|
---|
| 77 | DemandParameter.ActualValue,
|
---|
| 78 | CapacityParameter.ActualValue,
|
---|
| 79 | FleetUsageFactor.ActualValue,
|
---|
| 80 | TimeFactor.ActualValue,
|
---|
| 81 | DistanceFactor.ActualValue,
|
---|
| 82 | OverloadPenalty.ActualValue,
|
---|
| 83 | TardinessPenalty.ActualValue,
|
---|
| 84 | CoordinatesParameter.ActualValue,
|
---|
| 85 | DistanceMatrixParameter,
|
---|
| 86 | UseDistanceMatrixParameter.ActualValue);
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as PrinsEncoding);
|
---|
| 90 |
|
---|
| 91 | return base.Apply();
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | }
|
---|