Changeset 4690 for branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion
- Timestamp:
- 10/29/10 20:30:20 (14 years ago)
- Location:
- branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaExhaustiveIntraRouteInversionMoveGenerator.cs
r4352 r4690 27 27 using HeuristicLab.Parameters; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 34 35 [StorableConstructor] 35 36 private AlbaExhaustiveIntraRouteInversionGenerator(bool deserializing) : base(deserializing) { } 36 37 private AlbaExhaustiveIntraRouteInversionGenerator(AlbaExhaustiveIntraRouteInversionGenerator original, Cloner cloner) : base(original, cloner) { } 37 38 public AlbaExhaustiveIntraRouteInversionGenerator() 38 39 : base() { 40 } 41 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new AlbaExhaustiveIntraRouteInversionGenerator(this, cloner); 39 44 } 40 45 … … 44 49 int currentTourStart = 0; 45 50 int currentTourEnd = 0; 46 while (currentTourEnd != individual.Length) {51 while (currentTourEnd != individual.Length) { 47 52 currentTourEnd = currentTourStart; 48 while (individual[currentTourEnd] < individual.Cities && 53 while (individual[currentTourEnd] < individual.Cities && 49 54 currentTourEnd < individual.Length) { 50 55 currentTourEnd++; … … 53 58 int tourLength = currentTourEnd - currentTourStart; 54 59 if (tourLength >= 4) { 55 for (int i = 0; i <= tourLength - 4; i++ 60 for (int i = 0; i <= tourLength - 4; i++) { 56 61 for (int j = i + 2; j <= tourLength - 2; j++) { 57 62 AlbaIntraRouteInversionMove move = new AlbaIntraRouteInversionMove( 58 currentTourStart + i, 59 currentTourStart + j, 63 currentTourStart + i, 64 currentTourStart + j, 60 65 individual); 61 66 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaIntraRouteInversionEvaluator.cs
r4352 r4690 26 26 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba; 27 27 using HeuristicLab.Data; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting { … … 37 38 [StorableConstructor] 38 39 private AlbaIntraRouteInversionMoveEvaluator(bool deserializing) : base(deserializing) { } 39 40 private AlbaIntraRouteInversionMoveEvaluator(AlbaIntraRouteInversionMoveEvaluator original, Cloner cloner) : base(original, cloner) { } 40 41 public AlbaIntraRouteInversionMoveEvaluator() 41 42 : base() { 42 Parameters.Add(new LookupParameter<AlbaIntraRouteInversionMove>("AlbaIntraRouteInversionMove", "The move to evaluate.")); 43 Parameters.Add(new LookupParameter<AlbaIntraRouteInversionMove>("AlbaIntraRouteInversionMove", "The move to evaluate.")); 44 } 45 46 public override IDeepCloneable Clone(Cloner cloner) { 47 return new AlbaIntraRouteInversionMoveEvaluator(this, cloner); 43 48 } 44 49 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaIntraRouteInversionMove.cs
r4352 r4690 32 32 public class AlbaIntraRouteInversionMove : TwoIndexMove, IVRPMove { 33 33 public IVRPEncoding Individual { get { return Permutation as AlbaEncoding; } } 34 34 35 [StorableConstructor] 36 protected AlbaIntraRouteInversionMove(bool deserializing) : base(deserializing) { } 37 protected AlbaIntraRouteInversionMove(AlbaIntraRouteInversionMove original, Cloner cloner) 38 : base(original, cloner) { 39 Permutation = cloner.Clone(original.Permutation); 40 } 35 41 public AlbaIntraRouteInversionMove() 36 42 : base() { … … 43 49 public AlbaIntraRouteInversionMove(int index1, int index2, AlbaEncoding permutation) 44 50 : base(index1, index2, permutation) { 45 51 this.Permutation = permutation.Clone() as AlbaEncoding; 46 52 } 47 53 48 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) { 49 AlbaIntraRouteInversionMove clone = new AlbaIntraRouteInversionMove( 50 Index1, Index2); 51 52 if (Permutation != null) 53 clone.Permutation = (AlbaEncoding)cloner.Clone(Permutation); 54 55 cloner.RegisterClonedObject(this, clone); 56 return clone; 54 public override IDeepCloneable Clone(Cloner cloner) { 55 return new AlbaIntraRouteInversionMove(this, cloner); 57 56 } 58 57 … … 61 60 public TourEvaluation GetMoveQuality( 62 61 IntValue vehicles, 63 DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, 62 DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, 64 63 DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates, 65 64 DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, 66 65 DoubleValue overloadPenalty, DoubleValue tardinessPenalty, 67 66 ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) { 68 69 70 71 67 return AlbaIntraRouteInversionMoveEvaluator.GetMoveQuality(Permutation as AlbaEncoding, this, vehicles, 68 dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity, 69 coordinates, fleetUsageFactor, timeFactor, distanceFactor, 70 overloadPenalty, tardinessPenalty, distanceMatrix, useDistanceMatrix); 72 71 } 73 72 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaIntraRouteInversionMoveGenerator.cs
r4352 r4690 27 27 using HeuristicLab.Parameters; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 42 43 [StorableConstructor] 43 44 protected AlbaIntraRouteInversionMoveGenerator(bool deserializing) : base(deserializing) { } 44 45 protected AlbaIntraRouteInversionMoveGenerator(AlbaIntraRouteInversionMoveGenerator original, Cloner cloner) : base(original, cloner) { } 45 46 public AlbaIntraRouteInversionMoveGenerator() 46 47 : base() { 47 48 48 Parameters.Add(new LookupParameter<AlbaIntraRouteInversionMove>("AlbaIntraRouteInversionMove", "The moves that should be generated in subscopes.")); 49 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes.")); 49 50 } 50 51 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaIntraRouteInversionMoveMaker.cs
r4352 r4690 26 26 using HeuristicLab.Parameters; 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 46 47 [StorableConstructor] 47 48 private AlbaIntraRouteInversionMoveMaker(bool deserializing) : base(deserializing) { } 48 49 private AlbaIntraRouteInversionMoveMaker(AlbaIntraRouteInversionMoveMaker original, Cloner cloner) 50 : base(original, cloner) { 51 } 49 52 public AlbaIntraRouteInversionMoveMaker() 50 53 : base() { … … 52 55 Parameters.Add(new LookupParameter<AlbaIntraRouteInversionMove>("AlbaIntraRouteInversionMove", "The move to make.")); 53 56 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move.")); 57 } 58 59 public override IDeepCloneable Clone(Cloner cloner) { 60 return new AlbaIntraRouteInversionMoveMaker(this, cloner); 54 61 } 55 62 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaStochasticIntraRouteInversionMutliMoveGenerator.cs
r4352 r4690 28 28 using System.Collections.Generic; 29 29 using HeuristicLab.Data; 30 using HeuristicLab.Common; 30 31 31 32 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 40 41 get { return (IValueLookupParameter<IntValue>)Parameters["SampleSize"]; } 41 42 } 42 43 43 44 [StorableConstructor] 44 45 private AlbaStochasticIntraRouteInversionMultiMoveGenerator(bool deserializing) : base(deserializing) { } 45 46 private AlbaStochasticIntraRouteInversionMultiMoveGenerator(AlbaStochasticIntraRouteInversionMultiMoveGenerator original, Cloner cloner) : base(original, cloner) { } 46 47 public AlbaStochasticIntraRouteInversionMultiMoveGenerator() 47 48 : base() { 48 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 49 Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to generate.")); 49 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 50 Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to generate.")); 51 } 52 53 public override IDeepCloneable Clone(Cloner cloner) { 54 return new AlbaStochasticIntraRouteInversionMultiMoveGenerator(this, cloner); 50 55 } 51 56 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaStochasticIntraRouteInversionSingleMoveGenerator.cs
r4352 r4690 28 28 using System.Collections.Generic; 29 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 30 using HeuristicLab.Common; 30 31 31 32 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 41 42 42 43 #endregion 43 44 44 45 public ILookupParameter<IRandom> RandomParameter { 45 46 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 46 47 } 47 48 48 49 [StorableConstructor] 49 50 private AlbaStochasticIntraRouteInversionSingleMoveGenerator(bool deserializing) : base(deserializing) { } 50 51 private AlbaStochasticIntraRouteInversionSingleMoveGenerator(AlbaStochasticIntraRouteInversionSingleMoveGenerator original, Cloner cloner) : base(original, cloner) { } 51 52 public AlbaStochasticIntraRouteInversionSingleMoveGenerator() 52 53 : base() { 53 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 54 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 55 } 56 57 public override IDeepCloneable Clone(Cloner cloner) { 58 return new AlbaStochasticIntraRouteInversionSingleMoveGenerator(this, cloner); 54 59 } 55 60 … … 75 80 76 81 int currentTourEnd = currentTourStart; 77 while (currentTourEnd < individual.Length && 82 while (currentTourEnd < individual.Length && 78 83 individual[currentTourEnd] < individual.Cities) { 79 84 currentTourEnd++; … … 93 98 94 99 AlbaIntraRouteInversionMove move = Apply(individual, Cities, RandomParameter.ActualValue); 95 if (move != null)100 if (move != null) 96 101 moves.Add(move); 97 102
Note: See TracChangeset
for help on using the changeset viewer.