Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3/Operators/Moves/Exchange/PotvinPDExchangeMove.cs @ 8670

Last change on this file since 8670 was 8670, checked in by svonolfe, 12 years ago

Added first version of the dynamic vehicle routing addon (#1955)

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