Changeset 3231 for trunk/sources/HeuristicLab.Encodings.PermutationEncoding
- Timestamp:
- 03/29/10 17:53:12 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3
- Files:
-
- 2 added
- 1 deleted
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Creators/RandomPermutationCreator.cs
r3160 r3231 47 47 get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; } 48 48 } 49 public IValueParameter<PermutationType> PermutationTypeParameter { 50 get { return (IValueParameter<PermutationType>)Parameters["PermutationType"]; } 51 } 52 53 public PermutationTypes PermutationType { 54 get { return PermutationTypeParameter.Value.Value; } 55 set { PermutationTypeParameter.Value.Value = value; } 56 } 49 57 50 58 public RandomPermutationCreator() … … 53 61 Parameters.Add(new ValueLookupParameter<IntValue>("Length", "The length of the new random permutation.")); 54 62 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The new random permutation.")); 63 Parameters.Add(new ValueParameter<PermutationType>("PermutationType", "The type of the permutation.", new PermutationType(PermutationTypes.RelativeUndirected))); 55 64 } 56 65 57 66 public override IOperation Apply() { 58 PermutationParameter.ActualValue = new Permutation( LengthParameter.ActualValue.Value, RandomParameter.ActualValue);67 PermutationParameter.ActualValue = new Permutation(PermutationType, LengthParameter.ActualValue.Value, RandomParameter.ActualValue); 59 68 return base.Apply(); 60 69 } -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/CosaCrossover.cs
r3160 r3231 84 84 } 85 85 } 86 return new Permutation( result);86 return new Permutation(parent1.PermutationType, result); 87 87 } 88 88 -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/CyclicCrossover.cs
r3160 r3231 90 90 } while (j < length); 91 91 92 return new Permutation( result);92 return new Permutation(parent1.PermutationType, result); 93 93 } 94 94 -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/CyclicCrossover2.cs
r3160 r3231 77 77 } 78 78 } 79 return new Permutation( result);79 return new Permutation(parent1.PermutationType, result); 80 80 } 81 81 -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/EdgeRecombinationCrossover.cs
r3160 r3231 136 136 } 137 137 } 138 return new Permutation( result);138 return new Permutation(parent1.PermutationType, result); 139 139 } 140 140 -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/MaximalPreservativeCrossover.cs
r3160 r3231 117 117 } while (index != breakPoint1); 118 118 119 return new Permutation( result);119 return new Permutation(parent1.PermutationType, result); 120 120 } 121 121 -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/OrderBasedCrossover.cs
r3160 r3231 89 89 } 90 90 } 91 return new Permutation( result);91 return new Permutation(parent1.PermutationType, result); 92 92 } 93 93 -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/OrderCrossover.cs
r3160 r3231 80 80 throw new InvalidOperationException("OrderCrossover: The permutation must consist of numbers in the interval [0;N) with N = length of the permutation."); 81 81 } 82 return new Permutation( result);82 return new Permutation(parent1.PermutationType, result); 83 83 } 84 84 -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/OrderCrossover2.cs
r3160 r3231 72 72 } 73 73 } 74 return new Permutation( result);74 return new Permutation(parent1.PermutationType, result); 75 75 } 76 76 -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/PartiallyMatchedCrossover.cs
r3160 r3231 84 84 } 85 85 86 return new Permutation( result);86 return new Permutation(parent1.PermutationType, result); 87 87 } 88 88 -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/PositionBasedCrossover.cs
r3160 r3231 75 75 } 76 76 77 return new Permutation( result);77 return new Permutation(parent1.PermutationType, result); 78 78 } 79 79 -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj
r3221 r3231 108 108 <Compile Include="Manipulators\TranslocationManipulator.cs" /> 109 109 <Compile Include="Moves\ThreeIndexMove.cs" /> 110 <Compile Include="Moves\ThreeOpt\PreventDeleteThreeOptTabuMoveEvaluator.cs" />111 <Compile Include="Moves\ThreeOpt\PreventReaddThreeOptTabuMoveEvaluator.cs" />112 <Compile Include="Moves\ThreeOpt\PreventReaddDeleteThreeOptTabuMoveEvaluator.cs" />113 <Compile Include="Moves\ThreeOpt\StochasticThreeOptSingleMoveGenerator.cs" />114 110 <Compile Include="Moves\ThreeOpt\Insertion\ExhaustiveInsertionMoveGenerator.cs"> 115 111 <SubType>Code</SubType> 116 112 </Compile> 113 <Compile Include="Moves\ThreeOpt\PreventDeleteThreeOptTabuMoveEvaluator.cs"> 114 <SubType>Code</SubType> 115 </Compile> 116 <Compile Include="Moves\ThreeOpt\PreventReaddDeleteThreeOptTabuMoveEvaluator.cs"> 117 <SubType>Code</SubType> 118 </Compile> 119 <Compile Include="Moves\ThreeOpt\PreventReaddThreeOptTabuMoveEvaluator.cs"> 120 <SubType>Code</SubType> 121 </Compile> 117 122 <Compile Include="Moves\ThreeOpt\StochasticThreeOptMultiMoveGenerator.cs"> 118 123 <SubType>Code</SubType> 119 124 </Compile> 125 <Compile Include="Moves\ThreeOpt\StochasticThreeOptSingleMoveGenerator.cs"> 126 <SubType>Code</SubType> 127 </Compile> 120 128 <Compile Include="Moves\ThreeOpt\ThreeOptMove.cs"> 121 129 <SubType>Code</SubType> … … 127 135 <SubType>Code</SubType> 128 136 </Compile> 129 <Compile Include="Moves\ThreeOpt\ThreeOptTabuMoveAttribute.cs" /> 130 <Compile Include="Moves\ThreeOpt\ThreeOptTabuMoveMaker.cs" /> 131 <Compile Include="Moves\TwoOpt\PreventDeleteTwoOptTabuMoveEvaluator.cs" /> 132 <Compile Include="Moves\TwoOpt\PreventReaddTwoOptTabuMoveEvaluator.cs" /> 133 <Compile Include="Moves\TwoOpt\StochasticTwoOptSingleMoveGenerator.cs" /> 137 <Compile Include="Moves\ThreeOpt\ThreeOptTabuMoveAttribute.cs"> 138 <SubType>Code</SubType> 139 </Compile> 140 <Compile Include="Moves\ThreeOpt\ThreeOptTabuMoveMaker.cs"> 141 <SubType>Code</SubType> 142 </Compile> 143 <Compile Include="Moves\TwoIndexMove.cs"> 144 <SubType>Code</SubType> 145 </Compile> 134 146 <Compile Include="Moves\TwoOpt\ExhaustiveTwoOptMoveGenerator.cs"> 135 147 <SubType>Code</SubType> 136 148 </Compile> 137 <Compile Include="Moves\TwoIndexMove.cs"> 138 <SubType>Code</SubType> 139 </Compile> 140 <Compile Include="Moves\TwoOpt\StochasticTwoOptMultiMoveGenerator.cs" /> 149 <Compile Include="Moves\TwoOpt\PreventDeleteTwoOptTabuMoveEvaluator.cs"> 150 <SubType>Code</SubType> 151 </Compile> 152 <Compile Include="Moves\TwoOpt\PreventReaddDeleteTwoOptTabuMoveEvaluator.cs"> 153 <SubType>Code</SubType> 154 </Compile> 155 <Compile Include="Moves\TwoOpt\PreventReaddTwoOptTabuMoveEvaluator.cs"> 156 <SubType>Code</SubType> 157 </Compile> 158 <Compile Include="Moves\TwoOpt\StochasticTwoOptMultiMoveGenerator.cs"> 159 <SubType>Code</SubType> 160 </Compile> 161 <Compile Include="Moves\TwoOpt\StochasticTwoOptSingleMoveGenerator.cs"> 162 <SubType>Code</SubType> 163 </Compile> 141 164 <Compile Include="Moves\TwoOpt\TwoOptMove.cs"> 142 165 <SubType>Code</SubType> 143 166 </Compile> 144 <Compile Include="Moves\TwoOpt\TwoOptMoveGenerator.cs" /> 167 <Compile Include="Moves\TwoOpt\TwoOptMoveGenerator.cs"> 168 <SubType>Code</SubType> 169 </Compile> 145 170 <Compile Include="Moves\TwoOpt\TwoOptMoveMaker.cs"> 146 171 <SubType>Code</SubType> 147 172 </Compile> 148 <Compile Include="Moves\TwoOpt\TwoOptTabuMoveAttribute.cs" /> 149 <Compile Include="Moves\TwoOpt\PreventReaddDeleteTwoOptTabuMoveEvaluator.cs" /> 150 <Compile Include="Moves\TwoOpt\TwoOptTabuMoveMaker.cs" /> 173 <Compile Include="Moves\TwoOpt\TwoOptTabuMoveAttribute.cs"> 174 <SubType>Code</SubType> 175 </Compile> 176 <Compile Include="Moves\TwoOpt\TwoOptTabuMoveMaker.cs"> 177 <SubType>Code</SubType> 178 </Compile> 151 179 <Compile Include="PermutationManipulator.cs" /> 152 180 <Compile Include="PermutationCrossover.cs" /> 153 181 <Compile Include="Permutation.cs" /> 182 <Compile Include="PermutationType.cs" /> 183 <Compile Include="PermutationTypes.cs" /> 154 184 <Compile Include="Properties\AssemblyInfo.cs" /> 155 185 </ItemGroup> -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Interfaces/IPermutationCreator.cs
r3053 r3231 31 31 IValueLookupParameter<IntValue> LengthParameter { get; } 32 32 ILookupParameter<Permutation> PermutationParameter { get; } 33 IValueParameter<PermutationType> PermutationTypeParameter { get; } 33 34 } 34 35 } -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs
r3160 r3231 25 25 26 26 namespace HeuristicLab.Encodings.PermutationEncoding { 27 [Item("Permutation", "Represents a permutation of integer values.")] 27 28 [StorableClass] 28 [Item("Permutation", "Represents a permutation of integer values.")]29 29 public class Permutation : IntArray { 30 public Permutation() : base() { } 31 public Permutation(int length) 30 [Storable] 31 private PermutationTypes permutationType; 32 /// <summary> 33 /// Gets the type of the permutation (see <see cref="PermutationType"/>). 34 /// </summary> 35 public PermutationTypes PermutationType { 36 get { return permutationType; } 37 } 38 39 public Permutation() : base() { 40 permutationType = PermutationTypes.RelativeUndirected; 41 } 42 public Permutation(PermutationTypes type) : base() { 43 permutationType = type; 44 } 45 46 public Permutation(PermutationTypes type, int length) 32 47 : base(length) { 33 48 for (int i = 0; i < length; i++) 34 49 this[i] = i; 50 permutationType = type; 35 51 } 36 public Permutation( int length, IRandom random)37 : this( length) {52 public Permutation(PermutationTypes type, int length, IRandom random) 53 : this(type, length) { 38 54 Randomize(random); 39 55 } 40 public Permutation(int[] elements) : base(elements) { } 41 public Permutation(IntArray elements) 42 : this(elements.Length) { 56 public Permutation(PermutationTypes type, int[] elements) : base(elements) { 57 permutationType = type; 58 } 59 public Permutation(PermutationTypes type, IntArray elements) : this(type, elements.Length) { 43 60 for (int i = 0; i < array.Length; i++) 44 61 array[i] = elements[i]; … … 46 63 47 64 public override IDeepCloneable Clone(Cloner cloner) { 48 Permutation clone = new Permutation( array);65 Permutation clone = new Permutation(permutationType, array); 49 66 cloner.RegisterClonedObject(this, clone); 50 67 return clone; -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/CosaCrossoverTest.cs
r3063 r3231 93 93 try { 94 94 target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 95 new Permutation( 4), new Permutation(4), new Permutation(4)}));95 new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)})); 96 96 } catch (System.InvalidOperationException) { 97 97 exceptionFired = true; … … 110 110 random.Reset(); 111 111 random.IntNumbers = new int[] { 1 }; 112 parent1 = new Permutation( new int[] { 0, 1, 5, 2, 4, 3 });112 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 5, 2, 4, 3 }); 113 113 Assert.IsTrue(parent1.Validate()); 114 parent2 = new Permutation( new int[] { 3, 0, 2, 1, 4, 5 });114 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 3, 0, 2, 1, 4, 5 }); 115 115 Assert.IsTrue(parent2.Validate()); 116 expected = new Permutation( new int[] { 0, 1, 4, 2, 5, 3 });116 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 4, 2, 5, 3 }); 117 117 Assert.IsTrue(expected.Validate()); 118 118 actual = CosaCrossover.Apply(random, parent1, parent2); … … 122 122 random.Reset(); 123 123 random.IntNumbers = new int[] { 4 }; 124 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });124 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 125 125 Assert.IsTrue(parent1.Validate()); 126 parent2 = new Permutation( new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });126 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 5, 7, 6, 4, 2, 0 }); 127 127 Assert.IsTrue(parent2.Validate()); 128 expected = new Permutation( new int[] { 7, 6, 5, 3, 4, 2, 1, 0 });128 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 7, 6, 5, 3, 4, 2, 1, 0 }); 129 129 Assert.IsTrue(expected.Validate()); 130 130 actual = CosaCrossover.Apply(random, parent1, parent2); … … 134 134 random.Reset(); 135 135 random.IntNumbers = new int[] { 5 }; 136 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });136 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); 137 137 Assert.IsTrue(parent1.Validate()); 138 parent2 = new Permutation( new int[] { 4, 3, 5, 1, 0, 9, 7, 2, 8, 6 });138 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 4, 3, 5, 1, 0, 9, 7, 2, 8, 6 }); 139 139 Assert.IsTrue(parent2.Validate()); 140 expected = new Permutation( new int[] { 7, 6, 2, 3, 4, 5, 1, 0, 9, 8 });140 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 7, 6, 2, 3, 4, 5, 1, 0, 9, 8 }); 141 141 Assert.IsTrue(expected.Validate()); 142 142 actual = CosaCrossover.Apply(random, parent1, parent2); … … 148 148 bool exceptionFired = false; 149 149 try { 150 CosaCrossover.Apply(random, new Permutation( 8), new Permutation(6));150 CosaCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6)); 151 151 } catch (System.ArgumentException) { 152 152 exceptionFired = true; -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/CyclicCrossover2Test.cs
r3063 r3231 71 71 try { 72 72 target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 73 new Permutation( 4), new Permutation(4), new Permutation(4)}));73 new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)})); 74 74 } catch (System.InvalidOperationException) { 75 75 exceptionFired = true; … … 88 88 random.Reset(); 89 89 random.IntNumbers = new int[] { 0 }; 90 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });90 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); 91 91 Assert.IsTrue(parent1.Validate()); 92 parent2 = new Permutation( new int[] { 2, 5, 6, 0, 7, 1, 3, 8, 4, 9 });92 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 5, 6, 0, 7, 1, 3, 8, 4, 9 }); 93 93 Assert.IsTrue(parent2.Validate()); 94 expected = new Permutation( new int[] { 0, 5, 2, 3, 7, 1, 6, 8, 4, 9 });94 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 5, 2, 3, 7, 1, 6, 8, 4, 9 }); 95 95 Assert.IsTrue(expected.Validate()); 96 96 actual = CyclicCrossover2.Apply(random, parent1, parent2); … … 102 102 bool exceptionFired = false; 103 103 try { 104 CyclicCrossover.Apply(random, new Permutation( 8), new Permutation(6));104 CyclicCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6)); 105 105 } catch (System.ArgumentException) { 106 106 exceptionFired = true; -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/CyclicCrossoverTest.cs
r3063 r3231 93 93 try { 94 94 target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 95 new Permutation( 4), new Permutation(4), new Permutation(4)}));95 new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)})); 96 96 } 97 97 catch (System.InvalidOperationException) { … … 111 111 random.Reset(); 112 112 random.DoubleNumbers = new double[] { 0.9 }; 113 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });113 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 114 114 Assert.IsTrue(parent1.Validate()); 115 parent2 = new Permutation( new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });115 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 5, 7, 6, 4, 2, 0 }); 116 116 Assert.IsTrue(parent2.Validate()); 117 expected = new Permutation( new int[] { 0, 1, 5, 3, 6, 4, 2, 7 });117 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 5, 3, 6, 4, 2, 7 }); 118 118 Assert.IsTrue(expected.Validate()); 119 119 actual = CyclicCrossover.Apply(random, parent1, parent2); … … 125 125 bool exceptionFired = false; 126 126 try { 127 CyclicCrossover.Apply(random, new Permutation( 8), new Permutation(6));127 CyclicCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6)); 128 128 } 129 129 catch (System.ArgumentException) { -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/EdgeRecombinationCrossoverTest.cs
r3063 r3231 93 93 try { 94 94 target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 95 new Permutation( 4), new Permutation(4), new Permutation(4)}));95 new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)})); 96 96 } 97 97 catch (System.InvalidOperationException) { … … 112 112 random.IntNumbers = new int[] { 0 }; 113 113 random.DoubleNumbers = new double[] { 0.5, 0, 0, 0 }; 114 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });114 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }); 115 115 Assert.IsTrue(parent1.Validate()); 116 parent2 = new Permutation( new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 });116 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 }); 117 117 Assert.IsTrue(parent2.Validate()); 118 expected = new Permutation( new int[] { 0, 4, 5, 1, 7, 6, 2, 8, 3 });118 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 4, 5, 1, 7, 6, 2, 8, 3 }); 119 119 Assert.IsTrue(expected.Validate()); 120 120 actual = EdgeRecombinationCrossover.Apply(random, parent1, parent2); … … 126 126 bool exceptionFired = false; 127 127 try { 128 EdgeRecombinationCrossover.Apply(random, new Permutation( 8), new Permutation(6));128 EdgeRecombinationCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6)); 129 129 } 130 130 catch (System.ArgumentException) { -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/InsertionManipulatorTest.cs
r3053 r3231 88 88 random.Reset(); 89 89 random.IntNumbers = new int[] { 3, 6 }; 90 parent = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });90 parent = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 91 91 Assert.IsTrue(parent.Validate()); 92 92 93 expected = new Permutation( new int[] { 0, 1, 2, 4, 5, 6, 3, 7 });93 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 4, 5, 6, 3, 7 }); 94 94 Assert.IsTrue(expected.Validate()); 95 95 InsertionManipulator.Apply(random, parent); -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/InversionManipulatorTest.cs
r3053 r3231 88 88 random.Reset(); 89 89 random.IntNumbers = new int[] { 1, 4 }; 90 parent = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });90 parent = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }); 91 91 Assert.IsTrue(parent.Validate()); 92 92 93 expected = new Permutation( new int[] { 0, 4, 3, 2, 1, 5, 6, 7, 8 });93 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 4, 3, 2, 1, 5, 6, 7, 8 }); 94 94 Assert.IsTrue(expected.Validate()); 95 95 InversionManipulator.Apply(random, parent); -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/MaximalPreservativeCrossoverTest.cs
r3063 r3231 93 93 try { 94 94 target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 95 new Permutation( 4), new Permutation(4), new Permutation(4)}));95 new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)})); 96 96 } 97 97 catch (System.InvalidOperationException) { … … 111 111 random.Reset(); 112 112 random.IntNumbers = new int[] { 3, 2 }; 113 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });113 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 114 114 Assert.IsTrue(parent1.Validate()); 115 parent2 = new Permutation( new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });115 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 5, 7, 6, 4, 2, 0 }); 116 116 Assert.IsTrue(parent2.Validate()); 117 expected = new Permutation( new int[] { 1, 0, 2, 3, 4, 5, 7, 6 });117 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 0, 2, 3, 4, 5, 7, 6 }); 118 118 Assert.IsTrue(expected.Validate()); 119 119 actual = MaximalPreservativeCrossover.Apply(random, parent1, parent2); … … 125 125 bool exceptionFired = false; 126 126 try { 127 MaximalPreservativeCrossover.Apply(random, new Permutation( 8), new Permutation(6));127 MaximalPreservativeCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6)); 128 128 } 129 129 catch (System.ArgumentException) { -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/OrderBasedCrossoverTest.cs
r3063 r3231 93 93 try { 94 94 target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 95 new Permutation( 4), new Permutation(4), new Permutation(4)}));95 new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)})); 96 96 } catch (System.InvalidOperationException) { 97 97 exceptionFired = true; … … 110 110 random.Reset(); 111 111 random.IntNumbers = new int[] { 3, 5, 2, 1 }; 112 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });112 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 113 113 Assert.IsTrue(parent1.Validate()); 114 parent2 = new Permutation( new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });114 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 5, 7, 6, 4, 2, 0 }); 115 115 Assert.IsTrue(parent2.Validate()); 116 expected = new Permutation( new int[] { 1, 3, 2, 7, 6, 4, 5, 0 });116 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 2, 7, 6, 4, 5, 0 }); 117 117 actual = OrderBasedCrossover.Apply(random, parent1, parent2); 118 118 Assert.IsTrue(actual.Validate()); … … 122 122 bool exceptionFired = false; 123 123 try { 124 OrderBasedCrossover.Apply(random, new Permutation( 8), new Permutation(6));124 OrderBasedCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6)); 125 125 } catch (System.ArgumentException) { 126 126 exceptionFired = true; -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/OrderCrossover2Test.cs
r3063 r3231 70 70 try { 71 71 target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 72 new Permutation( 4), new Permutation(4), new Permutation(4)}));72 new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)})); 73 73 } catch (System.InvalidOperationException) { 74 74 exceptionFired = true; … … 87 87 random.Reset(); 88 88 random.IntNumbers = new int[] { 5, 7 }; 89 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });89 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); 90 90 Assert.IsTrue(parent1.Validate()); 91 parent2 = new Permutation( new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 });91 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 }); 92 92 Assert.IsTrue(parent2.Validate()); 93 expected = new Permutation( new int[] { 2, 0, 9, 1, 3, 5, 6, 7, 8, 4 });93 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 0, 9, 1, 3, 5, 6, 7, 8, 4 }); 94 94 Assert.IsTrue(expected.Validate()); 95 95 actual = OrderCrossover2.Apply(random, parent1, parent2); … … 101 101 bool exceptionFired = false; 102 102 try { 103 OrderCrossover.Apply(random, new Permutation( 8), new Permutation(6));103 OrderCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6)); 104 104 } catch (System.ArgumentException) { 105 105 exceptionFired = true; -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/OrderCrossoverTest.cs
r3063 r3231 93 93 try { 94 94 target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 95 new Permutation( 4), new Permutation(4), new Permutation(4)}));95 new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)})); 96 96 } catch (System.InvalidOperationException) { 97 97 exceptionFired = true; … … 110 110 random.Reset(); 111 111 random.IntNumbers = new int[] { 3, 6 }; 112 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });112 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }); 113 113 Assert.IsTrue(parent1.Validate()); 114 parent2 = new Permutation( new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 });114 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 }); 115 115 Assert.IsTrue(parent2.Validate()); 116 expected = new Permutation( new int[] { 2, 7, 1, 3, 4, 5, 6, 0, 8 });116 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 7, 1, 3, 4, 5, 6, 0, 8 }); 117 117 Assert.IsTrue(expected.Validate()); 118 118 actual = OrderCrossover.Apply(random, parent1, parent2); … … 122 122 random.Reset(); 123 123 random.IntNumbers = new int[] { 2, 4 }; 124 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });124 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 125 125 Assert.IsTrue(parent1.Validate()); 126 parent2 = new Permutation( new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });126 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 5, 7, 6, 4, 2, 0 }); 127 127 Assert.IsTrue(parent2.Validate()); 128 expected = new Permutation( new int[] { 7, 6, 2, 3, 4, 0, 1, 5 });128 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 7, 6, 2, 3, 4, 0, 1, 5 }); 129 129 actual = OrderCrossover.Apply(random, parent1, parent2); 130 130 Assert.IsTrue(actual.Validate()); … … 133 133 random.Reset(); 134 134 random.IntNumbers = new int[] { 2, 5 }; 135 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });135 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }); 136 136 Assert.IsTrue(parent1.Validate()); 137 parent2 = new Permutation( new int[] { 7, 3, 0, 4, 8, 2, 5, 1, 6 });137 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 7, 3, 0, 4, 8, 2, 5, 1, 6 }); 138 138 Assert.IsTrue(parent2.Validate()); 139 expected = new Permutation( new int[] { 0, 8, 2, 3, 4, 5, 1, 6, 7 });139 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 8, 2, 3, 4, 5, 1, 6, 7 }); 140 140 Assert.IsTrue(expected.Validate()); 141 141 actual = OrderCrossover.Apply(random, parent1, parent2); … … 145 145 random.Reset(); 146 146 random.IntNumbers = new int[] { 0, 5 }; 147 parent1 = new Permutation( new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 });147 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 }); 148 148 Assert.IsTrue(parent1.Validate()); 149 parent2 = new Permutation( new int[] { 5, 3, 4, 0, 9, 8, 2, 7, 1, 6 });149 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 5, 3, 4, 0, 9, 8, 2, 7, 1, 6 }); 150 150 Assert.IsTrue(parent2.Validate()); 151 expected = new Permutation( new int[] { 2, 1, 4, 3, 7, 8, 6, 5, 0, 9 });151 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 1, 4, 3, 7, 8, 6, 5, 0, 9 }); 152 152 Assert.IsTrue(expected.Validate()); 153 153 actual = OrderCrossover.Apply(random, parent1, parent2); … … 157 157 random.Reset(); 158 158 random.IntNumbers = new int[] { 6, 9 }; 159 expected = new Permutation( new int[] { 3, 4, 8, 2, 7, 1, 6, 0, 5, 9 });159 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 3, 4, 8, 2, 7, 1, 6, 0, 5, 9 }); 160 160 Assert.IsTrue(expected.Validate()); 161 161 actual = OrderCrossover.Apply(random, parent1, parent2); … … 165 165 random.Reset(); 166 166 random.IntNumbers = new int[] { 0, 9 }; 167 expected = new Permutation( new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 });167 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 }); 168 168 Assert.IsTrue(expected.Validate()); 169 169 actual = OrderCrossover.Apply(random, parent1, parent2); … … 175 175 bool exceptionFired = false; 176 176 try { 177 OrderCrossover.Apply(random, new Permutation( 8), new Permutation(6));177 OrderCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6)); 178 178 } catch (System.ArgumentException) { 179 179 exceptionFired = true; -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/PartiallyMatchedCrossoverTest.cs
r3063 r3231 93 93 try { 94 94 target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 95 new Permutation( 4), new Permutation(4), new Permutation(4)}));95 new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)})); 96 96 } 97 97 catch (System.InvalidOperationException) { … … 111 111 random.Reset(); 112 112 random.IntNumbers = new int[] { 3, 5 }; 113 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });113 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 114 114 Assert.IsTrue(parent1.Validate()); 115 parent2 = new Permutation( new int[] { 2, 6, 4, 0, 5, 7, 1, 3 });115 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 6, 4, 0, 5, 7, 1, 3 }); 116 116 Assert.IsTrue(parent2.Validate()); 117 expected = new Permutation( new int[] { 2, 6, 7, 3, 4, 5, 1, 0 });117 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 6, 7, 3, 4, 5, 1, 0 }); 118 118 Assert.IsTrue(expected.Validate()); 119 119 actual = PartiallyMatchedCrossover.Apply(random, parent1, parent2); … … 123 123 random.Reset(); 124 124 random.IntNumbers = new int[] { 5, 7 }; 125 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });125 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); 126 126 Assert.IsTrue(parent1.Validate()); 127 parent2 = new Permutation( new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 });127 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 }); 128 128 Assert.IsTrue(parent2.Validate()); 129 expected = new Permutation( new int[] { 2, 1, 3, 0, 9, 5, 6, 7, 4, 8 });129 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 1, 3, 0, 9, 5, 6, 7, 4, 8 }); 130 130 Assert.IsTrue(expected.Validate()); 131 131 actual = PartiallyMatchedCrossover.Apply(random, parent1, parent2); … … 137 137 bool exceptionFired = false; 138 138 try { 139 PartiallyMatchedCrossover.Apply(random, new Permutation( 8), new Permutation(6));139 PartiallyMatchedCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6)); 140 140 } 141 141 catch (System.ArgumentException) { -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/PositionBasedCrossoverTest.cs
r3063 r3231 94 94 try { 95 95 target.Cross(random, new ItemArray<Permutation>(new Permutation[] { 96 new Permutation( 4), new Permutation(4), new Permutation(4) }));96 new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4) })); 97 97 } 98 98 catch (System.InvalidOperationException) { … … 114 114 random.Reset(); 115 115 random.IntNumbers = new int[] { 3, 1, 2, 5 }; 116 parent1 = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });116 parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 117 117 Assert.IsTrue(parent1.Validate()); 118 parent2 = new Permutation( new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });118 parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 5, 7, 6, 4, 2, 0 }); 119 119 Assert.IsTrue(parent2.Validate()); 120 120 121 expected = new Permutation( new int[] { 0, 3, 5, 1, 2, 4, 6, 7 });121 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 3, 5, 1, 2, 4, 6, 7 }); 122 122 Assert.IsTrue(expected.Validate()); 123 123 actual = PositionBasedCrossover.Apply(random, parent1, parent2); … … 129 129 bool exceptionFired = false; 130 130 try { 131 PositionBasedCrossover.Apply(random, new Permutation( 8), new Permutation(6));131 PositionBasedCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6)); 132 132 } catch (System.ArgumentException) { 133 133 exceptionFired = true; -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/ScrambleManipulatorTest.cs
r3053 r3231 88 88 random.Reset(); 89 89 random.IntNumbers = new int[] { 3, 6, 1, 1, 1, 0 }; 90 parent = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });90 parent = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 91 91 Assert.IsTrue(parent.Validate()); 92 92 93 expected = new Permutation( new int[] { 0, 1, 2, 4, 5, 6, 3, 7 });93 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 4, 5, 6, 3, 7 }); 94 94 Assert.IsTrue(expected.Validate()); 95 95 ScrambleManipulator.Apply(random, parent); -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/Swap2ManipulatorTest.cs
r3053 r3231 88 88 random.Reset(); 89 89 random.IntNumbers = new int[] { 1, 4 }; 90 parent = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });90 parent = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }); 91 91 Assert.IsTrue(parent.Validate()); 92 92 93 expected = new Permutation( new int[] { 0, 4, 2, 3, 1, 5, 6, 7, 8 });93 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 4, 2, 3, 1, 5, 6, 7, 8 }); 94 94 Assert.IsTrue(expected.Validate()); 95 95 Swap2Manipulator.Apply(random, parent); -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/Swap3ManipulatorTest.cs
r3053 r3231 89 89 random.IntNumbers = new int[] { 1, 3, 6 }; 90 90 random.DoubleNumbers = new double[] { 0 }; 91 parent = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });91 parent = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }); 92 92 Assert.IsTrue(parent.Validate()); 93 93 94 expected = new Permutation( new int[] { 0, 3, 2, 6, 4, 5, 1, 7, 8 });94 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 3, 2, 6, 4, 5, 1, 7, 8 }); 95 95 Assert.IsTrue(expected.Validate()); 96 96 Swap3Manipulator.Apply(random, parent); -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/TranslocationInversionManipulatorTest.cs
r3053 r3231 88 88 random.Reset(); 89 89 random.IntNumbers = new int[] { 2, 4, 4 }; 90 parent = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });90 parent = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 91 91 Assert.IsTrue(parent.Validate()); 92 92 93 expected = new Permutation( new int[] { 0, 1, 5, 6, 4, 3, 2, 7 });93 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 5, 6, 4, 3, 2, 7 }); 94 94 Assert.IsTrue(expected.Validate()); 95 95 TranslocationInversionManipulator.Apply(random, parent); -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/TranslocationManipulatorTest.cs
r3053 r3231 88 88 random.Reset(); 89 89 random.IntNumbers = new int[] { 2, 4, 4 }; 90 parent = new Permutation( new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });90 parent = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); 91 91 Assert.IsTrue(parent.Validate()); 92 92 93 expected = new Permutation( new int[] { 0, 1, 5, 6, 2, 3, 4, 7 });93 expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 5, 6, 2, 3, 4, 7 }); 94 94 Assert.IsTrue(expected.Validate()); 95 95 TranslocationManipulator.Apply(random, parent);
Note: See TracChangeset
for help on using the changeset viewer.