Changeset 3232 for trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/TwoOpt/StochasticInversionSingleMoveGenerator.cs
- Timestamp:
- 03/29/10 18:49:55 (14 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/TwoOpt/StochasticInversionSingleMoveGenerator.cs
r3229 r3232 28 28 29 29 namespace HeuristicLab.Encodings.PermutationEncoding { 30 [Item("Stochastic TwoOptSingleMoveGenerator", "Randomly samples a single from all possible 2-opt moves (inversion) from a given permutation.")]30 [Item("StochasticInversionSingleMoveGenerator", "Randomly samples a single from all possible inversion moves (2-opt) from a given permutation.")] 31 31 [StorableClass] 32 public class Stochastic TwoOptSingleMoveGenerator : TwoOptMoveGenerator, IStochasticOperator, ISingleMoveGenerator {32 public class StochasticInversionSingleMoveGenerator : InversionMoveGenerator, IStochasticOperator, ISingleMoveGenerator { 33 33 public ILookupParameter<IRandom> RandomParameter { 34 34 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 35 35 } 36 36 37 public Stochastic TwoOptSingleMoveGenerator()37 public StochasticInversionSingleMoveGenerator() 38 38 : base() { 39 39 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 40 40 } 41 41 42 public static TwoOptMove Apply(Permutation permutation, IRandom random) {42 public static InversionMove Apply(Permutation permutation, IRandom random) { 43 43 int length = permutation.Length; 44 44 int index1 = random.Next(length - 1); 45 45 int index2 = random.Next(index1 + 1, length); 46 return new TwoOptMove(index1, index2);;46 return new InversionMove(index1, index2);; 47 47 } 48 48 49 protected override TwoOptMove[] GenerateMoves(Permutation permutation) {49 protected override InversionMove[] GenerateMoves(Permutation permutation) { 50 50 IRandom random = RandomParameter.ActualValue; 51 return new TwoOptMove[] { Apply(permutation, random) };51 return new InversionMove[] { Apply(permutation, random) }; 52 52 } 53 53 }
Note: See TracChangeset
for help on using the changeset viewer.