Changeset 3200 for trunk/sources/HeuristicLab.Encodings.PermutationEncoding
- Timestamp:
- 03/23/10 02:44:07 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj
r3104 r3200 108 108 <Compile Include="Manipulators\TranslocationManipulator.cs" /> 109 109 <Compile Include="Moves\ThreeIndexMove.cs" /> 110 <Compile Include="Moves\ThreeOpt\ StochasticThreeOptMoveGenerator.cs" />111 <Compile Include="Moves\ThreeOpt\ThreeOptMove.cs" />112 < Compile Include="Moves\ThreeOpt\ThreeOptMoveGenerator.cs" />110 <Compile Include="Moves\ThreeOpt\ThreeOptMove.cs"> 111 <SubType>Code</SubType> 112 </Compile> 113 113 <Compile Include="Moves\TwoOpt\PreventReaddTwoOptTabuMoveEvaluator.cs" /> 114 114 <Compile Include="Moves\TwoOpt\StochasticTwoOptSingleMoveGenerator.cs" /> -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Manipulators/TranslocationManipulator.cs
r3160 r3200 41 41 /// <param name="permutation">The permutation array to manipulate.</param> 42 42 public static void Apply(IRandom random, Permutation permutation) { 43 Permutation original = (Permutation)permutation.Clone();44 43 int breakPoint1, breakPoint2, insertPoint, insertPointLimit; 45 44 … … 51 50 else 52 51 insertPoint = 0; 52 53 Apply(permutation, breakPoint1, breakPoint2, insertPoint); 54 } 55 56 public static void Apply(Permutation permutation, int breakPoint1, int breakPoint2, int insertPoint) { 57 Permutation original = (Permutation)permutation.Clone(); 53 58 54 59 int i = 0; // index in new permutation -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/StochasticThreeOptMoveGenerator.cs
r3074 r3200 30 30 [Item("StochasticThreeOptMoveGenerator", "Randomly samples n from all possible 3-opt moves from a given permutation.")] 31 31 [StorableClass] 32 public class StochasticThreeOptM oveGenerator : ThreeOptMoveGenerator, IStochasticOperator {32 public class StochasticThreeOptMultiMoveGenerator : ThreeOptMoveGenerator, IStochasticOperator, IMultiMoveGenerator { 33 33 public ILookupParameter<IRandom> RandomParameter { 34 34 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 35 35 } 36 p rivateValueLookupParameter<IntValue> SampleSizeParameter {37 get { return ( ValueLookupParameter<IntValue>)Parameters["SampleSize"]; }36 public IValueLookupParameter<IntValue> SampleSizeParameter { 37 get { return (IValueLookupParameter<IntValue>)Parameters["SampleSize"]; } 38 38 } 39 39 … … 43 43 } 44 44 45 public StochasticThreeOptM oveGenerator()45 public StochasticThreeOptMultiMoveGenerator() 46 46 : base() { 47 47 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); … … 51 51 public static ThreeOptMove[] Apply(Permutation permutation, IRandom random, int sampleSize) { 52 52 int length = permutation.Length; 53 /*int totalMoves = (length) * (length - 1) / 2 - 3;54 // FIXME: Remove this comment if ExhaustiveThreeOptMoveGenerator exists, otherwise alter the exception message below.55 if (sampleSize >= totalMoves) throw new InvalidOperationException("StochasticThreeOptMoveGenerator: Sample size (" + sampleSize + ") is larger than the set of all possible moves (" + totalMoves + "), use the ExhaustiveThreeOptMoveGenerator instead.");56 */57 53 ThreeOptMove[] moves = new ThreeOptMove[sampleSize]; 58 54 for (int i = 0; i < sampleSize; i++) { 59 55 int index1, index2, index3; 60 do {61 index1 = random.Next(length - 1);62 index2 = random.Next(index1 + 1, length);63 } while (index2 - index1 == length - 1);64 do {65 index3 = random.Next(length);66 } while (index1 <= index3 && index3 <= index2 + 1);56 index1 = random.Next(length - 1); 57 index2 = random.Next(index1 + 1, length); 58 index3 = length - index2 + index1 - 1; // get insertion point in remaining part 59 if (index3 > 0) 60 index3 = random.Next(index3); 61 else 62 index3 = 0; 67 63 moves[i] = new ThreeOptMove(index1, index2, index3); 68 64 }
Note: See TracChangeset
for help on using the changeset viewer.