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