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

Last change on this file since 6773 was 6773, checked in by svonolfe, 8 years ago

Added moves for pickup and delivery problems (#1177)

File size: 4.4 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
58    [StorableConstructor]
59    protected PotvinPDRearrangeMoveTabuMaker(bool deserializing) : base(deserializing) { }
60    protected PotvinPDRearrangeMoveTabuMaker(PotvinPDRearrangeMoveTabuMaker original, Cloner cloner) : base(original, cloner) { }
61    public PotvinPDRearrangeMoveTabuMaker()
62      : base() {
63        Parameters.Add(new LookupParameter<PotvinPDRearrangeMove>("PotvinPDRearrangeMove", "The moves that should be made."));
64        Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The VRP tours considered in the move."));
65        Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance"));
66
67        Parameters.Add(new LookupParameter<DoubleValue>("Distance", "The distance of the individual"));
68        Parameters.Add(new LookupParameter<DoubleValue>("Overload", "The overload of the individual"));
69        Parameters.Add(new LookupParameter<DoubleValue>("Tardiness", "The tardiness of the individual"));
70    }
71
72    public override IDeepCloneable Clone(Cloner cloner) {
73      return new PotvinPDRearrangeMoveTabuMaker(this, cloner);
74    }
75
76    protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) {
77      PotvinPDRearrangeMove move = PDRearrangeMoveParameter.ActualValue;
78      double baseQuality = moveQuality;
79      if (quality < moveQuality) baseQuality = quality; // we make an uphill move, the lower bound is the solution quality
80
81      double distance = 0;
82      if (DistanceParameter.ActualValue != null)
83        distance = DistanceParameter.ActualValue.Value;
84
85      double overload = 0;
86      if (OverloadParameter.ActualValue != null)
87        overload = OverloadParameter.ActualValue.Value;
88
89      double tardiness = 0;
90      if (TardinessParameter.ActualValue != null)
91        tardiness = TardinessParameter.ActualValue.Value;
92
93      return new PotvinPDRelocateMoveAttribute(baseQuality, move.Tour, move.City, distance, overload, tardiness);
94    }
95  }
96}
Note: See TracBrowser for help on using the repository browser.