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.Common;
|
---|
23 | using HeuristicLab.Core;
|
---|
24 | using HeuristicLab.Optimization.Operators;
|
---|
25 | using HeuristicLab.Parameters;
|
---|
26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
27 | using HeuristicLab.Problems.VehicleRouting.Interfaces;
|
---|
28 | using HeuristicLab.Data;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
|
---|
31 | [Item("PotvinPDShiftMoveTabuMaker", "Declares a given shift move as tabu.")]
|
---|
32 | [StorableClass]
|
---|
33 | public class PotvinPDShiftMoveTabuMaker : TabuMaker, IPotvinPDShiftMoveOperator, IPotvinOperator, IVRPMoveOperator {
|
---|
34 | public ILookupParameter<PotvinPDShiftMove> PDShiftMoveParameter {
|
---|
35 | get { return (ILookupParameter<PotvinPDShiftMove>)Parameters["PotvinPDShiftMove"]; }
|
---|
36 | }
|
---|
37 | public ILookupParameter VRPMoveParameter {
|
---|
38 | get { return PDShiftMoveParameter; }
|
---|
39 | }
|
---|
40 | public ILookupParameter<IVRPEncoding> VRPToursParameter {
|
---|
41 | get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPTours"]; }
|
---|
42 | }
|
---|
43 | public ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter {
|
---|
44 | get { return (LookupParameter<IVRPProblemInstance>)Parameters["ProblemInstance"]; }
|
---|
45 | }
|
---|
46 |
|
---|
47 | public ILookupParameter<DoubleValue> DistanceParameter {
|
---|
48 | get { return (ILookupParameter<DoubleValue>)Parameters["Distance"]; }
|
---|
49 | }
|
---|
50 | public ILookupParameter<DoubleValue> OverloadParameter {
|
---|
51 | get { return (ILookupParameter<DoubleValue>)Parameters["Overload"]; }
|
---|
52 | }
|
---|
53 | public ILookupParameter<DoubleValue> TardinessParameter {
|
---|
54 | get { return (ILookupParameter<DoubleValue>)Parameters["Tardiness"]; }
|
---|
55 | }
|
---|
56 |
|
---|
57 | [StorableConstructor]
|
---|
58 | protected PotvinPDShiftMoveTabuMaker(bool deserializing) : base(deserializing) { }
|
---|
59 | protected PotvinPDShiftMoveTabuMaker(PotvinPDShiftMoveTabuMaker original, Cloner cloner) : base(original, cloner) { }
|
---|
60 | public PotvinPDShiftMoveTabuMaker()
|
---|
61 | : base() {
|
---|
62 | Parameters.Add(new LookupParameter<PotvinPDShiftMove>("PotvinPDShiftMove", "The moves that should be made."));
|
---|
63 | Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The VRP tours considered in the move."));
|
---|
64 | Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance"));
|
---|
65 |
|
---|
66 | Parameters.Add(new LookupParameter<DoubleValue>("Distance", "The distance of the individual"));
|
---|
67 | Parameters.Add(new LookupParameter<DoubleValue>("Overload", "The overload of the individual"));
|
---|
68 | Parameters.Add(new LookupParameter<DoubleValue>("Tardiness", "The tardiness of the individual"));
|
---|
69 | }
|
---|
70 |
|
---|
71 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
72 | return new PotvinPDShiftMoveTabuMaker(this, cloner);
|
---|
73 | }
|
---|
74 |
|
---|
75 | protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) {
|
---|
76 | PotvinPDShiftMove move = PDShiftMoveParameter.ActualValue;
|
---|
77 | double baseQuality = moveQuality;
|
---|
78 | if (quality < moveQuality) baseQuality = quality; // we make an uphill move, the lower bound is the solution quality
|
---|
79 |
|
---|
80 | double distance = 0;
|
---|
81 | if (DistanceParameter.ActualValue != null)
|
---|
82 | distance = DistanceParameter.ActualValue.Value;
|
---|
83 |
|
---|
84 | double overload = 0;
|
---|
85 | if (OverloadParameter.ActualValue != null)
|
---|
86 | overload = OverloadParameter.ActualValue.Value;
|
---|
87 |
|
---|
88 | double tardiness = 0;
|
---|
89 | if (TardinessParameter.ActualValue != null)
|
---|
90 | tardiness = TardinessParameter.ActualValue.Value;
|
---|
91 |
|
---|
92 | return new PotvinPDRelocateMoveAttribute(baseQuality, move.OldTour, move.City, distance, overload, tardiness);
|
---|
93 | }
|
---|
94 | }
|
---|
95 | }
|
---|