Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDRearrange/PotvinPDRearrangeMoveTabuMaker.cs @ 12962

Last change on this file since 12962 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 4.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Operators;
26using HeuristicLab.Parameters;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28using HeuristicLab.Problems.VehicleRouting.Interfaces;
29
30namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
31  [Item("PotvinPDRearrangeMoveTabuMaker", "Declares a given rearrange move as tabu.")]
32  [StorableClass]
33  public class PotvinPDRearrangeMoveTabuMaker : TabuMaker, IPotvinPDRearrangeMoveOperator, IPotvinOperator, IVRPMoveOperator {
34    public ILookupParameter<PotvinPDRearrangeMove> PDRearrangeMoveParameter {
35      get { return (ILookupParameter<PotvinPDRearrangeMove>)Parameters["PotvinPDRearrangeMove"]; }
36    }
37    public ILookupParameter VRPMoveParameter {
38      get { return PDRearrangeMoveParameter; }
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    public ILookupParameter<IntValue> PickupViolationsParameter {
57      get { return (ILookupParameter<IntValue>)Parameters["PickupViolations"]; }
58    }
59
60    [StorableConstructor]
61    protected PotvinPDRearrangeMoveTabuMaker(bool deserializing) : base(deserializing) { }
62    protected PotvinPDRearrangeMoveTabuMaker(PotvinPDRearrangeMoveTabuMaker original, Cloner cloner) : base(original, cloner) { }
63    public PotvinPDRearrangeMoveTabuMaker()
64      : base() {
65      Parameters.Add(new LookupParameter<PotvinPDRearrangeMove>("PotvinPDRearrangeMove", "The moves that should be made."));
66      Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The VRP tours considered in the move."));
67      Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance"));
68
69      Parameters.Add(new LookupParameter<DoubleValue>("Distance", "The distance of the individual"));
70      Parameters.Add(new LookupParameter<DoubleValue>("Overload", "The overload of the individual"));
71      Parameters.Add(new LookupParameter<DoubleValue>("Tardiness", "The tardiness of the individual"));
72      Parameters.Add(new LookupParameter<IntValue>("PickupViolations", "The number of pickup violations."));
73    }
74
75    public override IDeepCloneable Clone(Cloner cloner) {
76      return new PotvinPDRearrangeMoveTabuMaker(this, cloner);
77    }
78
79    protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) {
80      PotvinPDRearrangeMove move = PDRearrangeMoveParameter.ActualValue;
81      double baseQuality = moveQuality;
82      if (quality < moveQuality) baseQuality = quality; // we make an uphill move, the lower bound is the solution quality
83
84      double distance = 0;
85      if (DistanceParameter.ActualValue != null)
86        distance = DistanceParameter.ActualValue.Value;
87
88      double overload = 0;
89      if (OverloadParameter.ActualValue != null)
90        overload = OverloadParameter.ActualValue.Value;
91
92      double tardiness = 0;
93      if (TardinessParameter.ActualValue != null)
94        tardiness = TardinessParameter.ActualValue.Value;
95
96      int pickupViolations = 0;
97      if (PickupViolationsParameter.ActualValue != null)
98        pickupViolations = PickupViolationsParameter.ActualValue.Value;
99
100      return new PotvinPDRelocateMoveAttribute(baseQuality, move.Tour, move.City, distance, overload, tardiness, pickupViolations);
101    }
102  }
103}
Note: See TracBrowser for help on using the repository browser.