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("PotvinPDRearrangeMove", "Item that describes a rearrange move on a PDP representation.")]
|
---|
35 | [StorableClass]
|
---|
36 | public class PotvinPDRearrangeMove: 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 Tour { get; protected set; }
|
---|
45 |
|
---|
46 | public PotvinPDRearrangeMove(): base() {
|
---|
47 | City = -1;
|
---|
48 | Tour = -1;
|
---|
49 |
|
---|
50 | Individual = null;
|
---|
51 | }
|
---|
52 |
|
---|
53 | public PotvinPDRearrangeMove(int city, int tour, PotvinEncoding individual) {
|
---|
54 | City = city;
|
---|
55 | Tour = tour;
|
---|
56 |
|
---|
57 | this.Individual = individual.Clone() as PotvinEncoding;
|
---|
58 | }
|
---|
59 |
|
---|
60 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
61 | return new PotvinPDRearrangeMove(this, cloner);
|
---|
62 | }
|
---|
63 |
|
---|
64 | protected PotvinPDRearrangeMove(PotvinPDRearrangeMove original, Cloner cloner)
|
---|
65 | : base(original, cloner) {
|
---|
66 | this.City = original.City;
|
---|
67 | this.Tour = original.Tour;
|
---|
68 |
|
---|
69 | this.Individual = cloner.Clone(Individual) as PotvinEncoding;
|
---|
70 | }
|
---|
71 |
|
---|
72 | [StorableConstructor]
|
---|
73 | protected PotvinPDRearrangeMove(bool deserializing) : base(deserializing) { }
|
---|
74 |
|
---|
75 | #region IVRPMove Members
|
---|
76 |
|
---|
77 | [ThreadStatic]
|
---|
78 | private static PotvinPDRearrangeMoveEvaluator moveEvaluator;
|
---|
79 | public VRPMoveEvaluator GetMoveEvaluator() {
|
---|
80 | if(moveEvaluator == null)
|
---|
81 | moveEvaluator = new PotvinPDRearrangeMoveEvaluator();
|
---|
82 |
|
---|
83 | return moveEvaluator;
|
---|
84 | }
|
---|
85 |
|
---|
86 | [ThreadStatic]
|
---|
87 | private static PotvinPDRearrangeMoveMaker moveMaker;
|
---|
88 | public VRPMoveMaker GetMoveMaker() {
|
---|
89 | if (moveMaker == null)
|
---|
90 | moveMaker = new PotvinPDRearrangeMoveMaker();
|
---|
91 |
|
---|
92 | return moveMaker;
|
---|
93 | }
|
---|
94 |
|
---|
95 | [ThreadStatic]
|
---|
96 | private static PotvinPDRearrangeMoveTabuMaker tabuMaker;
|
---|
97 | public ITabuMaker GetTabuMaker() {
|
---|
98 | if (tabuMaker == null)
|
---|
99 | tabuMaker = new PotvinPDRearrangeMoveTabuMaker();
|
---|
100 |
|
---|
101 | return tabuMaker;
|
---|
102 | }
|
---|
103 |
|
---|
104 | [ThreadStatic]
|
---|
105 | private static PotvinPDRearrangeTabuCriterion tabuChecker;
|
---|
106 | public ITabuChecker GetTabuChecker() {
|
---|
107 | if (tabuChecker == null) {
|
---|
108 | tabuChecker = new PotvinPDRearrangeTabuCriterion();
|
---|
109 | tabuChecker.UseAspirationCriterion.Value = false;
|
---|
110 | }
|
---|
111 |
|
---|
112 | return tabuChecker;
|
---|
113 | }
|
---|
114 |
|
---|
115 | [ThreadStatic]
|
---|
116 | private static PotvinPDRearrangeTabuCriterion softTabuChecker;
|
---|
117 | public ITabuChecker GetSoftTabuChecker() {
|
---|
118 | if (softTabuChecker == null) {
|
---|
119 | softTabuChecker = new PotvinPDRearrangeTabuCriterion();
|
---|
120 | softTabuChecker.UseAspirationCriterion.Value = true;
|
---|
121 | }
|
---|
122 |
|
---|
123 | return softTabuChecker;
|
---|
124 | }
|
---|
125 |
|
---|
126 | #endregion
|
---|
127 | }
|
---|
128 | }
|
---|