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 |
|
---|
30 | namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
|
---|
31 | [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.")]
|
---|
32 | [StorableClass]
|
---|
33 | public class AlbaLambdaInterchangeMove: Item, IVRPMove {
|
---|
34 | [Storable]
|
---|
35 | public IVRPEncoding Individual { get; protected set; }
|
---|
36 |
|
---|
37 | [Storable]
|
---|
38 | public int Tour1 { get; protected set; }
|
---|
39 |
|
---|
40 | [Storable]
|
---|
41 | public int Position1 { get; protected set; }
|
---|
42 |
|
---|
43 | [Storable]
|
---|
44 | public int Length1 { get; protected set; }
|
---|
45 |
|
---|
46 | [Storable]
|
---|
47 | public int Tour2 { get; protected set; }
|
---|
48 |
|
---|
49 | [Storable]
|
---|
50 | public int Position2 { get; protected set; }
|
---|
51 |
|
---|
52 | [Storable]
|
---|
53 | public int Length2 { get; protected set; }
|
---|
54 |
|
---|
55 | public AlbaLambdaInterchangeMove(): base() {
|
---|
56 | Tour1 = -1;
|
---|
57 | Position1 = -1;
|
---|
58 | Length1 = -1;
|
---|
59 |
|
---|
60 | Tour2 = -1;
|
---|
61 | Position2 = -1;
|
---|
62 | Length2 = -1;
|
---|
63 |
|
---|
64 | Individual = null;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public AlbaLambdaInterchangeMove(int tour1, int position1, int length1,
|
---|
68 | int tour2, int position2, int length2, AlbaEncoding permutation) {
|
---|
69 | Tour1 = tour1;
|
---|
70 | Position1 = position1;
|
---|
71 | Length1 = length1;
|
---|
72 |
|
---|
73 | Tour2 = tour2;
|
---|
74 | Position2 = position2;
|
---|
75 | Length2 = length2;
|
---|
76 |
|
---|
77 | this.Individual = permutation.Clone() as AlbaEncoding;
|
---|
78 | }
|
---|
79 |
|
---|
80 | public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {
|
---|
81 | AlbaLambdaInterchangeMove clone = new AlbaLambdaInterchangeMove();
|
---|
82 |
|
---|
83 | clone.Tour1 = Tour1;
|
---|
84 | clone.Position1 = Position1;
|
---|
85 | clone.Length1 = Length1;
|
---|
86 |
|
---|
87 | clone.Tour2 = Tour2;
|
---|
88 | clone.Position2 = Position2;
|
---|
89 | clone.Length2 = Length2;
|
---|
90 |
|
---|
91 | if (Individual != null)
|
---|
92 | clone.Individual = (AlbaEncoding)cloner.Clone(Individual);
|
---|
93 |
|
---|
94 | cloner.RegisterClonedObject(this, clone);
|
---|
95 | return clone;
|
---|
96 | }
|
---|
97 |
|
---|
98 | #region IVRPMove Members
|
---|
99 |
|
---|
100 | public TourEvaluation GetMoveQuality(
|
---|
101 | IntValue vehicles,
|
---|
102 | DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray,
|
---|
103 | DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates,
|
---|
104 | DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor,
|
---|
105 | DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
|
---|
106 | ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) {
|
---|
107 | return AlbaLambdaInterchangeMoveEvaluator.GetMoveQuality(Individual as AlbaEncoding, this, vehicles,
|
---|
108 | dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
|
---|
109 | coordinates, fleetUsageFactor, timeFactor, distanceFactor,
|
---|
110 | overloadPenalty, tardinessPenalty, distanceMatrix, useDistanceMatrix);
|
---|
111 | }
|
---|
112 |
|
---|
113 | public IVRPEncoding MakeMove() {
|
---|
114 | AlbaLambdaInterchangeMoveMaker.Apply(Individual as AlbaEncoding, this);
|
---|
115 |
|
---|
116 | return Individual;
|
---|
117 | }
|
---|
118 |
|
---|
119 | #endregion
|
---|
120 | }
|
---|
121 | }
|
---|