Free cookie consent management tool by TermsFeed Policy Generator

source: branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDRearrange/PotvinPDRearrangeMoveTabuMaker.cs @ 12170

Last change on this file since 12170 was 7791, checked in by svonolfe, 13 years ago

Improved PDP moves (#1177)

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