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