Changeset 4690 for branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange
- Timestamp:
- 10/29/10 20:30:20 (14 years ago)
- Location:
- branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaExhaustiveLambdaInterchangeMoveGenerator.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 AlbaExhaustiveLambdaInterchangeMoveGenerator(bool deserializing) : base(deserializing) { } 36 37 public AlbaExhaustiveLambdaInterchangeMoveGenerator() 38 : base() { 37 private AlbaExhaustiveLambdaInterchangeMoveGenerator(AlbaExhaustiveLambdaInterchangeMoveGenerator original, Cloner cloner) : base(original, cloner) { } 38 public AlbaExhaustiveLambdaInterchangeMoveGenerator() : base() { } 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new AlbaExhaustiveLambdaInterchangeMoveGenerator(this, cloner); 39 41 } 40 42 … … 50 52 51 53 for (int length1 = 0; length1 <= Math.Min(lambda, tour1.Cities.Count); length1++) { 52 for (int length2 = 0; length2 <= Math.Min(lambda, tour2.Cities.Count); length2++) {53 if (length1 != 0 || length2 != 0) {54 for (int index1 = 0; index1 < tour1.Cities.Count - length1 + 1; index1++) {55 for (int index2 = 0; index2 < tour2.Cities.Count - length2 + 1; index2++) {56 moves.Add(new AlbaLambdaInterchangeMove(tour1Index, index1, length1, 54 for (int length2 = 0; length2 <= Math.Min(lambda, tour2.Cities.Count); length2++) { 55 if (length1 != 0 || length2 != 0) { 56 for (int index1 = 0; index1 < tour1.Cities.Count - length1 + 1; index1++) { 57 for (int index2 = 0; index2 < tour2.Cities.Count - length2 + 1; index2++) { 58 moves.Add(new AlbaLambdaInterchangeMove(tour1Index, index1, length1, 57 59 tour2Index, index2, length2, individual)); 58 60 } -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMove.cs
r4352 r4690 52 52 [Storable] 53 53 public int Length2 { get; protected set; } 54 54 55 [StorableConstructor] 56 protected AlbaLambdaInterchangeMove(bool deserializing) : base(deserializing) { } 57 protected AlbaLambdaInterchangeMove(AlbaLambdaInterchangeMove original, Cloner cloner) : base(original, cloner) { 58 Tour1 = original.Tour1; 59 Position1 = original.Position1; 60 Length1 = original.Length1; 61 62 Tour2 = original.Tour2; 63 Position2 = original.Position2; 64 Length2 = original.Length2; 65 66 Individual = cloner.Clone(original.Individual); 67 } 68 55 69 public AlbaLambdaInterchangeMove(): base() { 56 70 Tour1 = -1; … … 76 90 77 91 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 92 } 97 93 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveEvaluator.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 AlbaLambdaInterchangeMoveEvaluator(bool deserializing) : base(deserializing) { } 39 40 private AlbaLambdaInterchangeMoveEvaluator(AlbaLambdaInterchangeMoveEvaluator original, Cloner cloner) 41 : base(original, cloner) { 42 } 40 43 public AlbaLambdaInterchangeMoveEvaluator() 41 44 : base() { … … 43 46 } 44 47 48 public override IDeepCloneable Clone(Cloner cloner) { 49 return new AlbaLambdaInterchangeMoveEvaluator(this, cloner); 50 } 45 51 public static TourEvaluation GetMoveQuality(AlbaEncoding individual, AlbaLambdaInterchangeMove move, 46 52 IntValue vehicles, -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveGenerator.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 { … … 51 52 [StorableConstructor] 52 53 protected AlbaLambdaInterchangeMoveGenerator(bool deserializing) : base(deserializing) { } 53 54 protected AlbaLambdaInterchangeMoveGenerator(AlbaLambdaInterchangeMoveGenerator original, Cloner cloner) 55 : base(original, cloner) { 56 } 54 57 public AlbaLambdaInterchangeMoveGenerator() 55 58 : base() { 56 57 58 59 Parameters.Add(new LookupParameter<AlbaLambdaInterchangeMove>("AlbaLambdaInterchangeMove", "The moves that should be generated in subscopes.")); 60 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes.")); 61 Parameters.Add(new ValueParameter<IntValue>("Lambda", "The lambda value.", new IntValue(1))); 59 62 } 60 63 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveMaker.cs
r4352 r4690 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 47 48 [StorableConstructor] 48 49 private AlbaLambdaInterchangeMoveMaker(bool deserializing) : base(deserializing) { } 49 50 protected AlbaLambdaInterchangeMoveMaker(AlbaLambdaInterchangeMoveMaker original, Cloner cloner) 51 : base(original, cloner) { 52 } 50 53 public AlbaLambdaInterchangeMoveMaker() 51 54 : base() { … … 53 56 Parameters.Add(new LookupParameter<AlbaLambdaInterchangeMove>("AlbaLambdaInterchangeMove", "The move to make.")); 54 57 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move.")); 58 } 59 60 public override IDeepCloneable Clone(Cloner cloner) { 61 return new AlbaLambdaInterchangeMoveMaker(this, cloner); 55 62 } 56 63 … … 64 71 public override IOperation Apply() { 65 72 IOperation next = base.Apply(); 66 73 67 74 AlbaLambdaInterchangeMove move = LambdaInterchangeMoveParameter.ActualValue; 68 75 DoubleValue moveQuality = MoveQualityParameter.ActualValue; 69 76 DoubleValue quality = QualityParameter.ActualValue; 70 77 71 78 //perform move 72 79 VRPToursParameter.ActualValue = move.MakeMove(); -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaStochasticLambdaInterchangeMutliMoveGenerator.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 AlbaStochasticLambdaInterchangeMultiMoveGenerator(bool deserializing) : base(deserializing) { } 45 46 private AlbaStochasticLambdaInterchangeMultiMoveGenerator(AlbaStochasticLambdaInterchangeMultiMoveGenerator original, Cloner cloner) : base(original, cloner) { } 46 47 public AlbaStochasticLambdaInterchangeMultiMoveGenerator() 47 48 : base() { 48 49 49 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 50 Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to generate.")); 50 51 } 51 52 public override IDeepCloneable Clone(Cloner cloner) { 53 return new AlbaStochasticLambdaInterchangeMultiMoveGenerator(this, cloner); 54 } 52 55 protected override AlbaLambdaInterchangeMove[] GenerateMoves(AlbaEncoding individual, int lambda) { 53 56 int sampleSize = SampleSizeParameter.ActualValue.Value; -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaStochasticLambdaInterchangeSingleMoveGenerator.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 AlbaStochasticLambdaInterchangeSingleMoveGenerator(bool deserializing) : base(deserializing) { } 50 51 private AlbaStochasticLambdaInterchangeSingleMoveGenerator(AlbaStochasticLambdaInterchangeSingleMoveGenerator original, Cloner cloner) 52 : base(original, cloner) { 53 } 51 54 public AlbaStochasticLambdaInterchangeSingleMoveGenerator() 52 55 : base() { 53 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 56 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 57 } 58 59 public override IDeepCloneable Clone(Cloner cloner) { 60 return new AlbaStochasticLambdaInterchangeSingleMoveGenerator(this, cloner); 54 61 } 55 62 … … 81 88 82 89 AlbaLambdaInterchangeMove move = Apply(individual, Cities, lambda, RandomParameter.ActualValue); 83 if (move != null)90 if (move != null) 84 91 moves.Add(move); 85 92
Note: See TracChangeset
for help on using the changeset viewer.