Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceOverhaul/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift/PotvinPDShiftMove.cs @ 14712

Last change on this file since 14712 was 14711, checked in by gkronber, 8 years ago

#2520

  • renamed StorableClass -> StorableType
  • changed persistence to use GUIDs instead of type names
File size: 3.9 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 System;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Optimization;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27using HeuristicLab.Problems.VehicleRouting.Encodings.General;
28using HeuristicLab.Problems.VehicleRouting.Interfaces;
29
30namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
31  [Item("PotvinPDShiftMove", "Item that describes a shift move on a PDP representation.")]
32  [StorableType("B177DC95-FBBA-4EC4-9FE0-9D09821FCCCC")]
33  public class PotvinPDShiftMove : Item, IVRPMove {
34    [Storable]
35    public IVRPEncoding Individual { get; protected set; }
36
37    [Storable]
38    public int City { get; protected set; }
39
40    [Storable]
41    public int OldTour { get; protected set; }
42
43    [Storable]
44    public int Tour { get; protected set; }
45
46    public PotvinPDShiftMove()
47      : base() {
48      City = -1;
49      Tour = -1;
50
51      Individual = null;
52    }
53
54    public PotvinPDShiftMove(int city, int oldTour, int tour, PotvinEncoding individual) {
55      City = city;
56      OldTour = oldTour;
57      Tour = tour;
58
59      this.Individual = individual.Clone() as PotvinEncoding;
60    }
61
62    public override IDeepCloneable Clone(Cloner cloner) {
63      return new PotvinPDShiftMove(this, cloner);
64    }
65
66    protected PotvinPDShiftMove(PotvinPDShiftMove original, Cloner cloner)
67      : base(original, cloner) {
68      this.City = original.City;
69      this.OldTour = original.OldTour;
70      this.Tour = original.Tour;
71
72      this.Individual = cloner.Clone(Individual) as PotvinEncoding;
73    }
74
75    [StorableConstructor]
76    protected PotvinPDShiftMove(bool deserializing) : base(deserializing) { }
77
78    #region IVRPMove Members
79
80    [ThreadStatic]
81    private static PotvinPDShiftMoveEvaluator moveEvaluator;
82    public VRPMoveEvaluator GetMoveEvaluator() {
83      if (moveEvaluator == null)
84        moveEvaluator = new PotvinPDShiftMoveEvaluator();
85
86      return moveEvaluator;
87    }
88
89    [ThreadStatic]
90    private static PotvinPDShiftMoveMaker moveMaker;
91    public VRPMoveMaker GetMoveMaker() {
92      if (moveMaker == null)
93        moveMaker = new PotvinPDShiftMoveMaker();
94
95      return moveMaker;
96    }
97
98    [ThreadStatic]
99    private static PotvinPDShiftMoveTabuMaker tabuMaker;
100    public ITabuMaker GetTabuMaker() {
101      if (tabuMaker == null)
102        tabuMaker = new PotvinPDShiftMoveTabuMaker();
103
104      return tabuMaker;
105    }
106
107    [ThreadStatic]
108    private static PotvinPDShiftTabuCriterion tabuChecker;
109    public ITabuChecker GetTabuChecker() {
110      if (tabuChecker == null) {
111        tabuChecker = new PotvinPDShiftTabuCriterion();
112        tabuChecker.UseAspirationCriterion.Value = false;
113      }
114
115      return tabuChecker;
116    }
117
118    [ThreadStatic]
119    private static PotvinPDShiftTabuCriterion softTabuChecker;
120    public ITabuChecker GetSoftTabuChecker() {
121      if (softTabuChecker == null) {
122        softTabuChecker = new PotvinPDShiftTabuCriterion();
123        softTabuChecker.UseAspirationCriterion.Value = true;
124      }
125
126      return softTabuChecker;
127    }
128    #endregion
129  }
130}
Note: See TracBrowser for help on using the repository browser.