Changeset 4206 for trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion
- Timestamp:
- 08/13/10 10:28:15 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion
- Files:
-
- 1 added
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/ExhaustiveIntraRouteInversionMoveGenerator.cs
r4204 r4206 29 29 30 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 31 [Item("Exhaustive SimpleLocalSearchMoveGenerator", "Generates all possible simple local search moves from a given AlbaVRP encoding.")]31 [Item("ExhaustiveIntraRouteInversionGenerator", "Generates all possible intra route inversion moves from a given VRP encoding.")] 32 32 [StorableClass] 33 public sealed class Exhaustive SimpleLocalSearchMoveGenerator : SimpleLocalSearchMoveGenerator, IExhaustiveMoveGenerator, IAlbaSimpleLocalSearchMoveOperator {33 public sealed class ExhaustiveIntraRouteInversionGenerator : IntraRouteInversionMoveGenerator, IExhaustiveMoveGenerator, IAlbaIntraRouteInversionMoveOperator { 34 34 [StorableConstructor] 35 private Exhaustive SimpleLocalSearchMoveGenerator(bool deserializing) : base(deserializing) { }35 private ExhaustiveIntraRouteInversionGenerator(bool deserializing) : base(deserializing) { } 36 36 37 public Exhaustive SimpleLocalSearchMoveGenerator()37 public ExhaustiveIntraRouteInversionGenerator() 38 38 : base() { 39 39 } 40 40 41 protected override SimpleLocalSearchMove[] GenerateMoves(AlbaEncoding individual) {42 List< SimpleLocalSearchMove> moves = new List<SimpleLocalSearchMove>();41 protected override IntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual) { 42 List<IntraRouteInversionMove> moves = new List<IntraRouteInversionMove>(); 43 43 44 44 int currentTourStart = 0; … … 55 55 for (int i = 0; i <= tourLength - 4; i++ ) { 56 56 for (int j = i + 2; j <= tourLength - 2; j++) { 57 SimpleLocalSearchMove move = new SimpleLocalSearchMove(57 IntraRouteInversionMove move = new IntraRouteInversionMove( 58 58 currentTourStart + i, 59 59 currentTourStart + j, -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/IntraRouteInversionEvaluator.cs
r4205 r4206 28 28 29 29 namespace HeuristicLab.Problems.VehicleRouting { 30 [Item(" SimpleLocalSearchMoveEvaluator", "Evaluates a simple local search move for the Albarepresentation.")]30 [Item("IntraRouteInversionMoveEvaluator", "Evaluates a intra route inversion move for a VRP representation.")] 31 31 [StorableClass] 32 public sealed class SimpleLocalSearchMoveEvaluator : VRPMoveEvaluator, IAlbaSimpleLocalSearchMoveOperator {33 public ILookupParameter< SimpleLocalSearchMove> SimpleLocalSearchMoveParameter {34 get { return (ILookupParameter< SimpleLocalSearchMove>)Parameters["SimpleLocalSearchMove"]; }32 public sealed class IntraRouteInversionMoveEvaluator : VRPMoveEvaluator, IAlbaIntraRouteInversionMoveOperator { 33 public ILookupParameter<IntraRouteInversionMove> IntraRouteInversionMoveParameter { 34 get { return (ILookupParameter<IntraRouteInversionMove>)Parameters["IntraRouteInversionMove"]; } 35 35 } 36 36 37 37 [StorableConstructor] 38 private SimpleLocalSearchMoveEvaluator(bool deserializing) : base(deserializing) { }38 private IntraRouteInversionMoveEvaluator(bool deserializing) : base(deserializing) { } 39 39 40 public SimpleLocalSearchMoveEvaluator()40 public IntraRouteInversionMoveEvaluator() 41 41 : base() { 42 Parameters.Add(new LookupParameter<SimpleLocalSearchMove>("SimpleLocalSearchMove", "The move to evaluate."));42 Parameters.Add(new LookupParameter<IntraRouteInversionMove>("IntraRouteInversionMove", "The move to evaluate.")); 43 43 } 44 44 45 public static TourEvaluation GetMoveQuality(AlbaEncoding individual, SimpleLocalSearchMove move,45 public static TourEvaluation GetMoveQuality(AlbaEncoding individual, IntraRouteInversionMove move, 46 46 DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, 47 47 DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates, … … 50 50 ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) { 51 51 AlbaEncoding newSolution = individual.Clone() as AlbaEncoding; 52 SimpleLocalSearchMoveMaker.Apply(newSolution, move);52 IntraRouteInversionMoveMaker.Apply(newSolution, move); 53 53 54 54 return VRPEvaluator.Evaluate( … … 60 60 protected override TourEvaluation GetMoveQuality() { 61 61 return GetMoveQuality( 62 VRPToursParameter.ActualValue as AlbaEncoding, SimpleLocalSearchMoveParameter.ActualValue,62 VRPToursParameter.ActualValue as AlbaEncoding, IntraRouteInversionMoveParameter.ActualValue, 63 63 DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue, 64 64 DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue, -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/IntraRouteInversionMove.cs
r4205 r4206 28 28 29 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 30 [Item("InversionMove", "Item that describes a simple local search move on an Alba VRP representation.")]30 [Item("InversionMove", "Item that describes an intra route inversion move on a VRP representation.")] 31 31 [StorableClass] 32 public class SimpleLocalSearchMove : TwoIndexMove, IVRPMove {33 public SimpleLocalSearchMove()32 public class IntraRouteInversionMove : TwoIndexMove, IVRPMove { 33 public IntraRouteInversionMove() 34 34 : base() { 35 35 } 36 36 37 public SimpleLocalSearchMove(int index1, int index2)37 public IntraRouteInversionMove(int index1, int index2) 38 38 : base(index1, index2, null) { 39 39 } 40 40 41 public SimpleLocalSearchMove(int index1, int index2, AlbaEncoding permutation)41 public IntraRouteInversionMove(int index1, int index2, AlbaEncoding permutation) 42 42 : base(index1, index2, permutation) { 43 43 } 44 44 45 45 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) { 46 SimpleLocalSearchMove clone = new SimpleLocalSearchMove(46 IntraRouteInversionMove clone = new IntraRouteInversionMove( 47 47 Index1, Index2); 48 48 … … 63 63 DoubleValue overloadPenalty, DoubleValue tardinessPenalty, 64 64 ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) { 65 return SimpleLocalSearchMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this,65 return IntraRouteInversionMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this, 66 66 dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity, 67 67 coordinates, fleetUsageFactor, timeFactor, distanceFactor, … … 70 70 71 71 public void MakeMove(IRandom random, IVRPEncoding individual) { 72 SimpleLocalSearchMoveMaker.Apply(individual as AlbaEncoding, this);72 IntraRouteInversionMoveMaker.Apply(individual as AlbaEncoding, this); 73 73 } 74 74 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/IntraRouteInversionMoveGenerator.cs
r4204 r4206 29 29 30 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 31 [Item(" SimpleLocalSearchMoveGenerator", "Generates local search moves from a given AlbaVRP encoding.")]31 [Item("IntraRouteInversionMoveGenerator", "Generates intra route inversion moves from a given VRP encoding.")] 32 32 [StorableClass] 33 public abstract class SimpleLocalSearchMoveGenerator : AlbaMoveOperator, IExhaustiveMoveGenerator, IAlbaSimpleLocalSearchMoveOperator { 34 #region IAlbaSimpleLocalSearchMoveOperator Members 35 36 public ILookupParameter<SimpleLocalSearchMove> SimpleLocalSearchMoveParameter { 37 get { return (ILookupParameter<SimpleLocalSearchMove>)Parameters["SimpleLocalSearchMove"]; } 33 public abstract class IntraRouteInversionMoveGenerator : AlbaMoveOperator, IExhaustiveMoveGenerator, IAlbaIntraRouteInversionMoveOperator { 34 public ILookupParameter<IntraRouteInversionMove> IntraRouteInversionMoveParameter { 35 get { return (ILookupParameter<IntraRouteInversionMove>)Parameters["IntraRouteInversionMove"]; } 38 36 } 39 37 … … 42 40 } 43 41 44 #endregion 42 [StorableConstructor] 43 protected IntraRouteInversionMoveGenerator(bool deserializing) : base(deserializing) { } 45 44 46 [StorableConstructor] 47 protected SimpleLocalSearchMoveGenerator(bool deserializing) : base(deserializing) { } 48 49 public SimpleLocalSearchMoveGenerator() 45 public IntraRouteInversionMoveGenerator() 50 46 : base() { 51 Parameters.Add(new LookupParameter< SimpleLocalSearchMove>("SimpleLocalSearchMove", "The moves that should be generated in subscopes."));47 Parameters.Add(new LookupParameter<IntraRouteInversionMove>("IntraRouteInversionMove", "The moves that should be generated in subscopes.")); 52 48 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes.")); 53 49 } 54 50 55 protected abstract SimpleLocalSearchMove[] GenerateMoves(AlbaEncoding individual);51 protected abstract IntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual); 56 52 57 53 public override IOperation Apply() { … … 59 55 60 56 AlbaEncoding individual = VRPToursParameter.ActualValue as AlbaEncoding; 61 SimpleLocalSearchMove[] moves = GenerateMoves(individual);57 IntraRouteInversionMove[] moves = GenerateMoves(individual); 62 58 Scope[] moveScopes = new Scope[moves.Length]; 63 59 for (int i = 0; i < moveScopes.Length; i++) { 64 60 moveScopes[i] = new Scope(i.ToString()); 65 moveScopes[i].Variables.Add(new Variable( SimpleLocalSearchMoveParameter.ActualName, moves[i]));61 moveScopes[i].Variables.Add(new Variable(IntraRouteInversionMoveParameter.ActualName, moves[i])); 66 62 } 67 63 CurrentScopeParameter.ActualValue.SubScopes.AddRange(moveScopes); -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/IntraRouteInversionMoveMaker.cs
r4204 r4206 28 28 29 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 30 [Item(" SimpleLocalSearchMoveMaker", "Peforms a simple local search moves on a given Alba VRP encoding and updates the quality.")]30 [Item("IntraRouteInversionMoveMaker", "Peforms the SLS move on a given VRP encoding and updates the quality. It is implemented as described in Alba, E. and Dorronsoro, B. (2004). Solving the Vehicle Routing Problem by Using Cellular Genetic Algorithms.")] 31 31 [StorableClass] 32 public class SimpleLocalSearchMoveMaker : AlbaMoveMaker, IAlbaSimpleLocalSearchMoveOperator, IMoveMaker {32 public class IntraRouteInversionMoveMaker : AlbaMoveMaker, IAlbaIntraRouteInversionMoveOperator, IMoveMaker { 33 33 public override bool CanChangeName { 34 34 get { return false; } … … 40 40 get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; } 41 41 } 42 public ILookupParameter< SimpleLocalSearchMove> SimpleLocalSearchMoveParameter {43 get { return (ILookupParameter< SimpleLocalSearchMove>)Parameters["SimpleLocalSearchMove"]; }42 public ILookupParameter<IntraRouteInversionMove> IntraRouteInversionMoveParameter { 43 get { return (ILookupParameter<IntraRouteInversionMove>)Parameters["IntraRouteInversionMove"]; } 44 44 } 45 45 46 46 [StorableConstructor] 47 private SimpleLocalSearchMoveMaker(bool deserializing) : base(deserializing) { }47 private IntraRouteInversionMoveMaker(bool deserializing) : base(deserializing) { } 48 48 49 public SimpleLocalSearchMoveMaker()49 public IntraRouteInversionMoveMaker() 50 50 : base() { 51 51 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution.")); 52 Parameters.Add(new LookupParameter< SimpleLocalSearchMove>("SimpleLocalSearchMove", "The move to make."));52 Parameters.Add(new LookupParameter<IntraRouteInversionMove>("IntraRouteInversionMove", "The move to make.")); 53 53 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move.")); 54 54 } 55 55 56 public static void Apply(AlbaEncoding solution, SimpleLocalSearchMove move) {57 SimpleLocalSearchManipulator.Apply(solution, move.Index1, move.Index2);56 public static void Apply(AlbaEncoding solution, IntraRouteInversionMove move) { 57 IntraRouteInversionManipulator.Apply(solution, move.Index1, move.Index2); 58 58 } 59 59 … … 63 63 AlbaEncoding solution = VRPToursParameter.ActualValue as AlbaEncoding; 64 64 65 SimpleLocalSearchMove move = SimpleLocalSearchMoveParameter.ActualValue;65 IntraRouteInversionMove move = IntraRouteInversionMoveParameter.ActualValue; 66 66 DoubleValue moveQuality = MoveQualityParameter.ActualValue; 67 67 DoubleValue quality = QualityParameter.ActualValue; -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/StochasticIntraRouteInversionMutliMoveGenerator.cs
r4204 r4206 30 30 31 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 32 [Item("Stochastic SimpleLocalSearchMultiMoveGenerator", "Generates multiple random simple local search moves from a given AlbaVRP encoding.")]32 [Item("StochasticIntraRouteInversionMultiMoveGenerator", "Generates multiple random intra route inversion moves from a given VRP encoding.")] 33 33 [StorableClass] 34 public sealed class Stochastic SimpleLocalSearchMultiMoveGenerator : SimpleLocalSearchMoveGenerator, IStochasticOperator, IMultiMoveGenerator, IAlbaSimpleLocalSearchMoveOperator {34 public sealed class StochasticIntraRouteInversionMultiMoveGenerator : IntraRouteInversionMoveGenerator, IStochasticOperator, IMultiMoveGenerator, IAlbaIntraRouteInversionMoveOperator { 35 35 public ILookupParameter<IRandom> RandomParameter { 36 36 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } … … 42 42 43 43 [StorableConstructor] 44 private Stochastic SimpleLocalSearchMultiMoveGenerator(bool deserializing) : base(deserializing) { }44 private StochasticIntraRouteInversionMultiMoveGenerator(bool deserializing) : base(deserializing) { } 45 45 46 public Stochastic SimpleLocalSearchMultiMoveGenerator()46 public StochasticIntraRouteInversionMultiMoveGenerator() 47 47 : base() { 48 48 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); … … 50 50 } 51 51 52 protected override SimpleLocalSearchMove[] GenerateMoves(AlbaEncoding individual) {52 protected override IntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual) { 53 53 int sampleSize = SampleSizeParameter.ActualValue.Value; 54 54 55 SimpleLocalSearchMove[] moves = new SimpleLocalSearchMove[sampleSize];55 IntraRouteInversionMove[] moves = new IntraRouteInversionMove[sampleSize]; 56 56 for (int i = 0; i < sampleSize; i++) { 57 moves[i] = Stochastic SimpleLocalSearchSingleMoveGenerator.Apply(57 moves[i] = StochasticIntraRouteInversionSingleMoveGenerator.Apply( 58 58 individual, Cities, RandomParameter.ActualValue); 59 59 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/StochasticIntraRouteInversionSingleMoveGenerator.cs
r4205 r4206 30 30 31 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 32 [Item("Stochastic SimpleLocalSearchSingleMoveGenerator", "Generates one random simple local search move from a given AlbaVRP encoding.")]32 [Item("StochasticIntraRouteInversionSingleMoveGenerator", "Generates one random intra route inversion move from a given VRP encoding.")] 33 33 [StorableClass] 34 public sealed class Stochastic SimpleLocalSearchSingleMoveGenerator : SimpleLocalSearchMoveGenerator,35 IStochasticOperator, ISingleMoveGenerator, IAlba SimpleLocalSearchMoveOperator, IMultiVRPMoveGenerator {34 public sealed class StochasticIntraRouteInversionSingleMoveGenerator : IntraRouteInversionMoveGenerator, 35 IStochasticOperator, ISingleMoveGenerator, IAlbaIntraRouteInversionMoveOperator, IMultiVRPMoveGenerator { 36 36 #region IMultiVRPMoveOperator Members 37 37 38 38 public ILookupParameter VRPMoveParameter { 39 get { return (ILookupParameter)Parameters[" SimpleLocalSearchMove"]; }39 get { return (ILookupParameter)Parameters["IntraRouteInversionMove"]; } 40 40 } 41 41 … … 47 47 48 48 [StorableConstructor] 49 private Stochastic SimpleLocalSearchSingleMoveGenerator(bool deserializing) : base(deserializing) { }49 private StochasticIntraRouteInversionSingleMoveGenerator(bool deserializing) : base(deserializing) { } 50 50 51 public Stochastic SimpleLocalSearchSingleMoveGenerator()51 public StochasticIntraRouteInversionSingleMoveGenerator() 52 52 : base() { 53 53 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 54 54 } 55 55 56 public static SimpleLocalSearchMove Apply(AlbaEncoding individual, int cities, IRandom rand) {56 public static IntraRouteInversionMove Apply(AlbaEncoding individual, int cities, IRandom rand) { 57 57 int index1 = -1; 58 58 int index2 = -1; … … 86 86 } 87 87 88 return new SimpleLocalSearchMove(index1, index2, individual);88 return new IntraRouteInversionMove(index1, index2, individual); 89 89 } 90 90 91 protected override SimpleLocalSearchMove[] GenerateMoves(AlbaEncoding individual) {92 List< SimpleLocalSearchMove> moves = new List<SimpleLocalSearchMove>();91 protected override IntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual) { 92 List<IntraRouteInversionMove> moves = new List<IntraRouteInversionMove>(); 93 93 94 SimpleLocalSearchMove move = Apply(individual, Cities, RandomParameter.ActualValue);94 IntraRouteInversionMove move = Apply(individual, Cities, RandomParameter.ActualValue); 95 95 if(move != null) 96 96 moves.Add(move);
Note: See TracChangeset
for help on using the changeset viewer.