Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Prins/Manipulators/PrinsManipulator.cs @ 6350

Last change on this file since 6350 was 5445, checked in by swagner, 14 years ago

Updated year of copyrights (#1406)

File size: 4.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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 HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Optimization;
26using HeuristicLab.Parameters;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace 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    protected PrinsManipulator(PrinsManipulator original, Cloner cloner) : base(original, cloner) { }
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      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
64    }
65
66    protected abstract void Manipulate(IRandom random, PrinsEncoding individual);
67
68    public override IOperation Apply() {
69      IVRPEncoding solution = VRPToursParameter.ActualValue;
70      if (!(solution is PrinsEncoding)) {
71        VRPToursParameter.ActualValue = PrinsEncoding.ConvertFrom(solution,
72            Cities,
73            DueTimeParameter.ActualValue,
74            ServiceTimeParameter.ActualValue,
75            ReadyTimeParameter.ActualValue,
76            DemandParameter.ActualValue,
77            CapacityParameter.ActualValue,
78            FleetUsageFactor.ActualValue,
79            TimeFactor.ActualValue,
80            DistanceFactor.ActualValue,
81            OverloadPenalty.ActualValue,
82            TardinessPenalty.ActualValue,
83            CoordinatesParameter.ActualValue,
84            DistanceMatrixParameter,
85            UseDistanceMatrixParameter.ActualValue);
86      }
87
88      Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as PrinsEncoding);
89
90      return base.Apply();
91    }
92  }
93}
Note: See TracBrowser for help on using the repository browser.