Changeset 13412 for branches/PTSP/HeuristicLab.Problems.PTSP/3.3/Moves/TwoPointFiveOpt/StochasticTwoPointFiveMultiMoveGenerator.cs
- Timestamp:
- 11/28/15 23:38:51 (8 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/PTSP/HeuristicLab.Problems.PTSP/3.3/Moves/TwoPointFiveOpt/StochasticTwoPointFiveMultiMoveGenerator.cs
r13408 r13412 24 24 using HeuristicLab.Data; 25 25 using HeuristicLab.Encodings.PermutationEncoding; 26 using HeuristicLab.Operators;27 26 using HeuristicLab.Optimization; 28 27 using HeuristicLab.Parameters; … … 30 29 31 30 namespace HeuristicLab.Problems.PTSP { 32 [Item("Stochastic 25MultiMoveGenerator", "Randomly samples n from all possible inversion and shift moves (2.5-opt) from a given permutation.")]31 [Item("Stochastic 2.5-MultiMoveGenerator", "Randomly samples n from all possible inversion and shift moves (2.5-opt) from a given permutation.")] 33 32 [StorableClass] 34 class Stochastic25MultiMoveGenerator : TwoPointFiveMoveGenerator, IMultiMoveGenerator, IStochasticOperator {33 public sealed class StochasticTwoPointFiveMultiMoveGenerator : TwoPointFiveMoveGenerator, IMultiMoveGenerator, IStochasticOperator { 35 34 public ILookupParameter<IRandom> RandomParameter { 36 35 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } … … 46 45 47 46 [StorableConstructor] 48 pr otected Stochastic25MultiMoveGenerator(bool deserializing) : base(deserializing) { }49 pr otected Stochastic25MultiMoveGenerator(Stochastic25MultiMoveGenerator original, Cloner cloner) : base(original, cloner) { }50 public Stochastic 25MultiMoveGenerator()47 private StochasticTwoPointFiveMultiMoveGenerator(bool deserializing) : base(deserializing) { } 48 private StochasticTwoPointFiveMultiMoveGenerator(StochasticTwoPointFiveMultiMoveGenerator original, Cloner cloner) : base(original, cloner) { } 49 public StochasticTwoPointFiveMultiMoveGenerator() 51 50 : base() { 52 51 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); … … 55 54 56 55 public override IDeepCloneable Clone(Cloner cloner) { 57 return new Stochastic 25MultiMoveGenerator(this, cloner);56 return new StochasticTwoPointFiveMultiMoveGenerator(this, cloner); 58 57 } 59 58 60 59 public static TwoPointFiveMove[] Apply(Permutation permutation, IRandom random, int sampleSize) { 61 int length = permutation.Length; 62 TwoPointFiveMove[] moves = new TwoPointFiveMove[sampleSize]; 63 for (int i = 0; i < sampleSize; i++) { 64 moves[i] = Stochastic25SingleMoveGenerator.Apply(permutation, random); 60 var moves = new TwoPointFiveMove[sampleSize]; 61 for (var i = 0; i < sampleSize; i++) { 62 moves[i] = StochasticTwoPointFiveSingleMoveGenerator.Apply(permutation, random); 65 63 } 66 64 return moves; … … 68 66 69 67 protected override TwoPointFiveMove[] GenerateMoves(Permutation permutation) { 70 IRandom random = RandomParameter.ActualValue; 71 return Apply(permutation, random, SampleSizeParameter.ActualValue.Value); 68 return Apply(permutation, RandomParameter.ActualValue, SampleSizeParameter.ActualValue.Value); 72 69 } 73 70 }
Note: See TracChangeset
for help on using the changeset viewer.