1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 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 |
|
---|
22 | using System;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Optimization;
|
---|
26 | using HEAL.Attic;
|
---|
27 | using HeuristicLab.Problems.VehicleRouting.Encodings.General;
|
---|
28 | using HeuristicLab.Problems.VehicleRouting.Interfaces;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
|
---|
31 | [Item("PotvinPDExchangeMove", "Item that describes a exchange move on a PDP representation.")]
|
---|
32 | [StorableType("2C3CC022-8F2B-435C-BDAD-ABB9D568FC8E")]
|
---|
33 | public class PotvinPDExchangeMove : 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 | [Storable]
|
---|
47 | public int Replaced { get; protected set; }
|
---|
48 |
|
---|
49 | public PotvinPDExchangeMove()
|
---|
50 | : base() {
|
---|
51 | City = -1;
|
---|
52 | Tour = -1;
|
---|
53 |
|
---|
54 | Individual = null;
|
---|
55 | }
|
---|
56 |
|
---|
57 | public PotvinPDExchangeMove(int city, int oldTour, int tour, int replaced, PotvinEncoding individual) {
|
---|
58 | City = city;
|
---|
59 | OldTour = oldTour;
|
---|
60 | Tour = tour;
|
---|
61 | Replaced = replaced;
|
---|
62 |
|
---|
63 | this.Individual = individual.Clone() as PotvinEncoding;
|
---|
64 | }
|
---|
65 |
|
---|
66 | [StorableConstructor]
|
---|
67 | protected PotvinPDExchangeMove(StorableConstructorFlag _) : base(_) { }
|
---|
68 |
|
---|
69 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
70 | return new PotvinPDExchangeMove(this, cloner);
|
---|
71 | }
|
---|
72 |
|
---|
73 | protected PotvinPDExchangeMove(PotvinPDExchangeMove 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 PotvinPDExchangeMoveEvaluator moveEvaluator;
|
---|
87 | public VRPMoveEvaluator GetMoveEvaluator() {
|
---|
88 | if (moveEvaluator == null)
|
---|
89 | moveEvaluator = new PotvinPDExchangeMoveEvaluator();
|
---|
90 |
|
---|
91 | return moveEvaluator;
|
---|
92 | }
|
---|
93 |
|
---|
94 | [ThreadStatic]
|
---|
95 | private static PotvinPDExchangeMoveMaker moveMaker;
|
---|
96 | public VRPMoveMaker GetMoveMaker() {
|
---|
97 | if (moveMaker == null)
|
---|
98 | moveMaker = new PotvinPDExchangeMoveMaker();
|
---|
99 |
|
---|
100 | return moveMaker;
|
---|
101 | }
|
---|
102 |
|
---|
103 | [ThreadStatic]
|
---|
104 | private static PotvinPDExchangeMoveTabuMaker tabuMaker;
|
---|
105 | public ITabuMaker GetTabuMaker() {
|
---|
106 | if (tabuMaker == null)
|
---|
107 | tabuMaker = new PotvinPDExchangeMoveTabuMaker();
|
---|
108 |
|
---|
109 | return tabuMaker;
|
---|
110 | }
|
---|
111 |
|
---|
112 | [ThreadStatic]
|
---|
113 | private static PotvinPDExchangeTabuCriterion tabuChecker;
|
---|
114 | public ITabuChecker GetTabuChecker() {
|
---|
115 | if (tabuChecker == null) {
|
---|
116 | tabuChecker = new PotvinPDExchangeTabuCriterion();
|
---|
117 | tabuChecker.UseAspirationCriterion.Value = false;
|
---|
118 | }
|
---|
119 |
|
---|
120 | return tabuChecker;
|
---|
121 | }
|
---|
122 |
|
---|
123 | [ThreadStatic]
|
---|
124 | private static PotvinPDExchangeTabuCriterion softTabuChecker;
|
---|
125 | public ITabuChecker GetSoftTabuChecker() {
|
---|
126 | if (softTabuChecker == null) {
|
---|
127 | softTabuChecker = new PotvinPDExchangeTabuCriterion();
|
---|
128 | softTabuChecker.UseAspirationCriterion.Value = true;
|
---|
129 | }
|
---|
130 |
|
---|
131 | return softTabuChecker;
|
---|
132 | }
|
---|
133 |
|
---|
134 | #endregion
|
---|
135 | }
|
---|
136 | }
|
---|