Changeset 4722 for trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange
- Timestamp:
- 11/06/10 01:56:04 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/CloningRefactoring (added) merged: 4656-4693,4696-4697,4711-4714,4718-4719
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed
/branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting (added) merged: 4686-4687,4689-4693,4696-4697
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaExhaustiveLambdaInterchangeMoveGenerator.cs
r4352 r4722 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Optimization; 25 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;27 using HeuristicLab.Parameters;28 using System.Collections.Generic;29 28 30 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 34 33 [StorableConstructor] 35 34 private AlbaExhaustiveLambdaInterchangeMoveGenerator(bool deserializing) : base(deserializing) { } 36 37 public AlbaExhaustiveLambdaInterchangeMoveGenerator() 38 : base() { 35 private AlbaExhaustiveLambdaInterchangeMoveGenerator(AlbaExhaustiveLambdaInterchangeMoveGenerator original, Cloner cloner) : base(original, cloner) { } 36 public AlbaExhaustiveLambdaInterchangeMoveGenerator() : base() { } 37 public override IDeepCloneable Clone(Cloner cloner) { 38 return new AlbaExhaustiveLambdaInterchangeMoveGenerator(this, cloner); 39 39 } 40 40 … … 50 50 51 51 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, 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, 57 57 tour2Index, index2, length2, individual)); 58 58 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMove.cs
r4352 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 23 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 using HeuristicLab.Encodings.PermutationEncoding;25 using HeuristicLab.Common;26 using System.Collections.Generic;27 26 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 28 using HeuristicLab.Data;29 27 30 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 31 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.")] 32 30 [StorableClass] 33 public class AlbaLambdaInterchangeMove : Item, IVRPMove {31 public class AlbaLambdaInterchangeMove : Item, IVRPMove { 34 32 [Storable] 35 33 public IVRPEncoding Individual { get; protected set; } 36 34 37 35 [Storable] 38 36 public int Tour1 { get; protected set; } … … 52 50 [Storable] 53 51 public int Length2 { get; protected set; } 54 55 public AlbaLambdaInterchangeMove(): base() { 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() { 56 73 Tour1 = -1; 57 74 Position1 = -1; … … 65 82 } 66 83 67 public AlbaLambdaInterchangeMove(int tour1, int position1, int length1, 84 public AlbaLambdaInterchangeMove(int tour1, int position1, int length1, 68 85 int tour2, int position2, int length2, AlbaEncoding permutation) { 69 70 71 86 Tour1 = tour1; 87 Position1 = position1; 88 Length1 = length1; 72 89 73 74 75 90 Tour2 = tour2; 91 Position2 = position2; 92 Length2 = length2; 76 93 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; 94 this.Individual = permutation.Clone() as AlbaEncoding; 96 95 } 97 96 … … 100 99 public TourEvaluation GetMoveQuality( 101 100 IntValue vehicles, 102 DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, 101 DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, 103 102 DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates, 104 103 DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, 105 104 DoubleValue overloadPenalty, DoubleValue tardinessPenalty, 106 105 ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) { 107 108 109 110 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); 111 110 } 112 111 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveEvaluator.cs
r4352 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab. Encodings.PermutationEncoding;24 using HeuristicLab.Data; 24 25 using HeuristicLab.Parameters; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba; 27 using HeuristicLab.Data;28 28 29 29 namespace HeuristicLab.Problems.VehicleRouting { … … 37 37 [StorableConstructor] 38 38 private AlbaLambdaInterchangeMoveEvaluator(bool deserializing) : base(deserializing) { } 39 39 private AlbaLambdaInterchangeMoveEvaluator(AlbaLambdaInterchangeMoveEvaluator original, Cloner cloner) 40 : base(original, cloner) { 41 } 40 42 public AlbaLambdaInterchangeMoveEvaluator() 41 43 : base() { … … 43 45 } 44 46 47 public override IDeepCloneable Clone(Cloner cloner) { 48 return new AlbaLambdaInterchangeMoveEvaluator(this, cloner); 49 } 45 50 public static TourEvaluation GetMoveQuality(AlbaEncoding individual, AlbaLambdaInterchangeMove move, 46 51 IntValue vehicles, -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveGenerator.cs
r4352 r4722 20 20 #endregion 21 21 22 using System;22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 24 25 using HeuristicLab.Optimization; 26 using HeuristicLab.Parameters; 25 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;27 using HeuristicLab.Parameters;28 using System.Collections.Generic;29 using HeuristicLab.Data;30 28 31 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 51 49 [StorableConstructor] 52 50 protected AlbaLambdaInterchangeMoveGenerator(bool deserializing) : base(deserializing) { } 53 51 protected AlbaLambdaInterchangeMoveGenerator(AlbaLambdaInterchangeMoveGenerator original, Cloner cloner) 52 : base(original, cloner) { 53 } 54 54 public AlbaLambdaInterchangeMoveGenerator() 55 55 : base() { 56 57 58 56 Parameters.Add(new LookupParameter<AlbaLambdaInterchangeMove>("AlbaLambdaInterchangeMove", "The moves that should be generated in subscopes.")); 57 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes.")); 58 Parameters.Add(new ValueParameter<IntValue>("Lambda", "The lambda value.", new IntValue(1))); 59 59 } 60 60 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveMaker.cs
r4352 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; 24 using HeuristicLab.Operators;25 25 using HeuristicLab.Optimization; 26 26 using HeuristicLab.Parameters; 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using System.Collections.Generic;29 28 30 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 46 45 47 46 [StorableConstructor] 48 private AlbaLambdaInterchangeMoveMaker(bool deserializing) : base(deserializing) { } 49 47 protected AlbaLambdaInterchangeMoveMaker(bool deserializing) : base(deserializing) { } 48 protected AlbaLambdaInterchangeMoveMaker(AlbaLambdaInterchangeMoveMaker original, Cloner cloner) 49 : base(original, cloner) { 50 } 50 51 public AlbaLambdaInterchangeMoveMaker() 51 52 : base() { … … 53 54 Parameters.Add(new LookupParameter<AlbaLambdaInterchangeMove>("AlbaLambdaInterchangeMove", "The move to make.")); 54 55 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move.")); 56 } 57 58 public override IDeepCloneable Clone(Cloner cloner) { 59 return new AlbaLambdaInterchangeMoveMaker(this, cloner); 55 60 } 56 61 … … 64 69 public override IOperation Apply() { 65 70 IOperation next = base.Apply(); 66 71 67 72 AlbaLambdaInterchangeMove move = LambdaInterchangeMoveParameter.ActualValue; 68 73 DoubleValue moveQuality = MoveQualityParameter.ActualValue; 69 74 DoubleValue quality = QualityParameter.ActualValue; 70 75 71 76 //perform move 72 77 VRPToursParameter.ActualValue = move.MakeMove(); -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaStochasticLambdaInterchangeMutliMoveGenerator.cs
r4352 r4722 20 20 #endregion 21 21 22 using System;22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 24 25 using HeuristicLab.Optimization; 26 using HeuristicLab.Parameters; 25 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;27 using HeuristicLab.Parameters;28 using System.Collections.Generic;29 using HeuristicLab.Data;30 28 31 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 40 38 get { return (IValueLookupParameter<IntValue>)Parameters["SampleSize"]; } 41 39 } 42 40 43 41 [StorableConstructor] 44 42 private AlbaStochasticLambdaInterchangeMultiMoveGenerator(bool deserializing) : base(deserializing) { } 45 43 private AlbaStochasticLambdaInterchangeMultiMoveGenerator(AlbaStochasticLambdaInterchangeMultiMoveGenerator original, Cloner cloner) : base(original, cloner) { } 46 44 public AlbaStochasticLambdaInterchangeMultiMoveGenerator() 47 45 : base() { 48 49 46 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 47 Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to generate.")); 50 48 } 51 49 public override IDeepCloneable Clone(Cloner cloner) { 50 return new AlbaStochasticLambdaInterchangeMultiMoveGenerator(this, cloner); 51 } 52 52 protected override AlbaLambdaInterchangeMove[] GenerateMoves(AlbaEncoding individual, int lambda) { 53 53 int sampleSize = SampleSizeParameter.ActualValue.Value; -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaStochasticLambdaInterchangeSingleMoveGenerator.cs
r4352 r4722 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Optimization; 27 using HeuristicLab.Parameters; 25 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;27 using HeuristicLab.Parameters;28 using System.Collections.Generic;29 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 30 30 … … 41 41 42 42 #endregion 43 43 44 44 public ILookupParameter<IRandom> RandomParameter { 45 45 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 46 46 } 47 47 48 48 [StorableConstructor] 49 49 private AlbaStochasticLambdaInterchangeSingleMoveGenerator(bool deserializing) : base(deserializing) { } 50 50 private AlbaStochasticLambdaInterchangeSingleMoveGenerator(AlbaStochasticLambdaInterchangeSingleMoveGenerator original, Cloner cloner) 51 : base(original, cloner) { 52 } 51 53 public AlbaStochasticLambdaInterchangeSingleMoveGenerator() 52 54 : base() { 53 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 55 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 56 } 57 58 public override IDeepCloneable Clone(Cloner cloner) { 59 return new AlbaStochasticLambdaInterchangeSingleMoveGenerator(this, cloner); 54 60 } 55 61 … … 81 87 82 88 AlbaLambdaInterchangeMove move = Apply(individual, Cities, lambda, RandomParameter.ActualValue); 83 if (move != null)89 if (move != null) 84 90 moves.Add(move); 85 91
Note: See TracChangeset
for help on using the changeset viewer.