1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2012 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.Common;
|
---|
23 | using HeuristicLab.Core;
|
---|
24 | using HeuristicLab.Data;
|
---|
25 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
26 | using HeuristicLab.Problems.VehicleRouting.Encodings.General;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
|
---|
29 | [Item("InversionMove", "Item that describes a lambda move on a VRP representation. It is implemented as described in Alba, E. and Dorronsoro, B. (2004). Solving the Vehicle Routing Problem by Using Cellular Genetic Algorithms.")]
|
---|
30 | [StorableClass]
|
---|
31 | public class AlbaLambdaInterchangeMove : Item, IVRPMove {
|
---|
32 | [Storable]
|
---|
33 | public IVRPEncoding Individual { get; protected set; }
|
---|
34 |
|
---|
35 | [Storable]
|
---|
36 | public int Tour1 { get; protected set; }
|
---|
37 |
|
---|
38 | [Storable]
|
---|
39 | public int Position1 { get; protected set; }
|
---|
40 |
|
---|
41 | [Storable]
|
---|
42 | public int Length1 { get; protected set; }
|
---|
43 |
|
---|
44 | [Storable]
|
---|
45 | public int Tour2 { get; protected set; }
|
---|
46 |
|
---|
47 | [Storable]
|
---|
48 | public int Position2 { get; protected set; }
|
---|
49 |
|
---|
50 | [Storable]
|
---|
51 | public int Length2 { get; protected set; }
|
---|
52 |
|
---|
53 | [StorableConstructor]
|
---|
54 | protected AlbaLambdaInterchangeMove(bool deserializing) : base(deserializing) { }
|
---|
55 | protected AlbaLambdaInterchangeMove(AlbaLambdaInterchangeMove original, Cloner cloner)
|
---|
56 | : base(original, cloner) {
|
---|
57 | Tour1 = original.Tour1;
|
---|
58 | Position1 = original.Position1;
|
---|
59 | Length1 = original.Length1;
|
---|
60 |
|
---|
61 | Tour2 = original.Tour2;
|
---|
62 | Position2 = original.Position2;
|
---|
63 | Length2 = original.Length2;
|
---|
64 |
|
---|
65 | Individual = cloner.Clone(original.Individual);
|
---|
66 | }
|
---|
67 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
68 | return new AlbaLambdaInterchangeMove(this, cloner);
|
---|
69 | }
|
---|
70 |
|
---|
71 | public AlbaLambdaInterchangeMove()
|
---|
72 | : base() {
|
---|
73 | Tour1 = -1;
|
---|
74 | Position1 = -1;
|
---|
75 | Length1 = -1;
|
---|
76 |
|
---|
77 | Tour2 = -1;
|
---|
78 | Position2 = -1;
|
---|
79 | Length2 = -1;
|
---|
80 |
|
---|
81 | Individual = null;
|
---|
82 | }
|
---|
83 |
|
---|
84 | public AlbaLambdaInterchangeMove(int tour1, int position1, int length1,
|
---|
85 | int tour2, int position2, int length2, AlbaEncoding permutation) {
|
---|
86 | Tour1 = tour1;
|
---|
87 | Position1 = position1;
|
---|
88 | Length1 = length1;
|
---|
89 |
|
---|
90 | Tour2 = tour2;
|
---|
91 | Position2 = position2;
|
---|
92 | Length2 = length2;
|
---|
93 |
|
---|
94 | this.Individual = permutation.Clone() as AlbaEncoding;
|
---|
95 | }
|
---|
96 |
|
---|
97 | #region IVRPMove Members
|
---|
98 |
|
---|
99 | public TourEvaluation GetMoveQuality(
|
---|
100 | IntValue vehicles,
|
---|
101 | DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray,
|
---|
102 | DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates,
|
---|
103 | DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor,
|
---|
104 | DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
|
---|
105 | ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) {
|
---|
106 | return AlbaLambdaInterchangeMoveEvaluator.GetMoveQuality(Individual as AlbaEncoding, this, vehicles,
|
---|
107 | dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
|
---|
108 | coordinates, fleetUsageFactor, timeFactor, distanceFactor,
|
---|
109 | overloadPenalty, tardinessPenalty, distanceMatrix, useDistanceMatrix);
|
---|
110 | }
|
---|
111 |
|
---|
112 | public IVRPEncoding MakeMove() {
|
---|
113 | AlbaLambdaInterchangeMoveMaker.Apply(Individual as AlbaEncoding, this);
|
---|
114 |
|
---|
115 | return Individual;
|
---|
116 | }
|
---|
117 |
|
---|
118 | #endregion
|
---|
119 | }
|
---|
120 | }
|
---|