Changeset 3048 for trunk/sources/HeuristicLab.Encodings.RealVector
- Timestamp:
- 03/15/10 23:49:54 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.RealVector/3.3
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/BoundsChecker.cs
r3017 r3048 35 35 [StorableClass] 36 36 public class BoundsChecker : SingleSuccessorOperator { 37 public LookupParameter<DoubleArray Data> RealVectorParameter {38 get { return (LookupParameter<DoubleArray Data>)Parameters["RealVector"]; }37 public LookupParameter<DoubleArray> RealVectorParameter { 38 get { return (LookupParameter<DoubleArray>)Parameters["RealVector"]; } 39 39 } 40 public ValueLookupParameter<Double Data> MinimumParameter {41 get { return (ValueLookupParameter<Double Data>)Parameters["Minimum"]; }40 public ValueLookupParameter<DoubleValue> MinimumParameter { 41 get { return (ValueLookupParameter<DoubleValue>)Parameters["Minimum"]; } 42 42 } 43 public ValueLookupParameter<Double Data> MaximumParameter {44 get { return (ValueLookupParameter<Double Data>)Parameters["Maximum"]; }43 public ValueLookupParameter<DoubleValue> MaximumParameter { 44 get { return (ValueLookupParameter<DoubleValue>)Parameters["Maximum"]; } 45 45 } 46 46 … … 51 51 public BoundsChecker() 52 52 : base() { 53 Parameters.Add(new LookupParameter<DoubleArray Data>("RealVector", "The real-valued vector for which the bounds should be checked."));54 Parameters.Add(new ValueLookupParameter<Double Data>("Minimum", "The lower bound for each element in the vector."));55 Parameters.Add(new ValueLookupParameter<Double Data>("Maximum", "The upper bound for each element in the vector."));53 Parameters.Add(new LookupParameter<DoubleArray>("RealVector", "The real-valued vector for which the bounds should be checked.")); 54 Parameters.Add(new ValueLookupParameter<DoubleValue>("Minimum", "The lower bound for each element in the vector.")); 55 Parameters.Add(new ValueLookupParameter<DoubleValue>("Maximum", "The upper bound for each element in the vector.")); 56 56 } 57 57 … … 64 64 /// <param name="vector">The vector to check.</param> 65 65 /// <returns>The corrected real vector.</returns> 66 public static void Apply(DoubleArray Data vector, DoubleData min, DoubleDatamax) {66 public static void Apply(DoubleArray vector, DoubleValue min, DoubleValue max) { 67 67 for (int i = 0; i < vector.Length; i++) { 68 68 if (vector[i] < min.Value) vector[i] = min.Value; -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Creators/UniformRandomRealVectorCreator.cs
r3017 r3048 51 51 /// <param name="max">The maximum value of the sampling range for each vector element (exclusive).</param> 52 52 /// <returns>The newly created real vector.</returns> 53 public static DoubleArray DataApply(IRandom random, int length, double min, double max) {53 public static DoubleArray Apply(IRandom random, int length, double min, double max) { 54 54 if (length <= 0) throw new ArgumentException("UniformRandomRealVectorCreator: Length is smaller or equal to 0.", "length"); 55 55 if (min > max) throw new ArgumentException("UniformRandomRealVectorCreator: Minimum is greater than Maximum.", "min"); 56 DoubleArray Data result = new DoubleArrayData(length);56 DoubleArray result = new DoubleArray(length); 57 57 for (int i = 0; i < length; i++) 58 58 result[i] = min + random.NextDouble() * (max - min); … … 68 68 /// <param name="maximum">The maximum value of the sampling range for each vector element (exclusive).</param> 69 69 /// <returns>The newly created real vector.</returns> 70 protected override DoubleArray Data Create(IRandom random, IntData length, DoubleData minimum, DoubleDatamaximum) {70 protected override DoubleArray Create(IRandom random, IntValue length, DoubleValue minimum, DoubleValue maximum) { 71 71 return Apply(random, length.Value, minimum.Value, maximum.Value); 72 72 } -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/AverageCrossover.cs
r3017 r3048 45 45 /// <param name="parents">The list of parents.</param> 46 46 /// <returns>The child vector (average) of the parents.</returns> 47 public static DoubleArray Data Apply(IRandom random, ItemArray<DoubleArrayData> parents) {47 public static DoubleArray Apply(IRandom random, ItemArray<DoubleArray> parents) { 48 48 int length = parents[0].Length, parentsCount = parents.Length; 49 49 if (parents.Length < 2) throw new ArgumentException("AverageCrossover: The number of parents is less than 2.", "parents"); 50 DoubleArray Data result = new DoubleArrayData(length);50 DoubleArray result = new DoubleArray(length); 51 51 try { 52 52 double avg; … … 65 65 66 66 /// <summary> 67 /// Forwards the call to <see cref="Apply(IRandom, ItemArray<DoubleArray Data>)"/>.67 /// Forwards the call to <see cref="Apply(IRandom, ItemArray<DoubleArray>)"/>. 68 68 /// </summary> 69 69 /// <param name="random">The random number generator.</param> 70 70 /// <param name="parents">The list of parents.</param> 71 71 /// <returns>The child vector (average) of the parents.</returns> 72 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {72 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 73 73 return Apply(random, parents); 74 74 } -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/BlendAlphaBetaCrossover.cs
r3017 r3048 43 43 /// Whether the problem is a maximization or minimization problem. 44 44 /// </summary> 45 public ValueLookupParameter<Bool Data> MaximizationParameter {46 get { return (ValueLookupParameter<Bool Data>)Parameters["Maximization"]; }45 public ValueLookupParameter<BoolValue> MaximizationParameter { 46 get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 47 47 } 48 48 /// <summary> 49 49 /// The quality of the parents. 50 50 /// </summary> 51 public SubScopesLookupParameter<Double Data> QualityParameter {52 get { return (SubScopesLookupParameter<Double Data>)Parameters["Quality"]; }51 public SubScopesLookupParameter<DoubleValue> QualityParameter { 52 get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; } 53 53 } 54 54 /// <summary> 55 55 /// The alpha parameter specifies how much the interval between the parents should be extended in direction of the better parent. 56 56 /// </summary> 57 public ValueLookupParameter<Double Data> AlphaParameter {58 get { return (ValueLookupParameter<Double Data>)Parameters["Alpha"]; }57 public ValueLookupParameter<DoubleValue> AlphaParameter { 58 get { return (ValueLookupParameter<DoubleValue>)Parameters["Alpha"]; } 59 59 } 60 60 /// <summary> 61 61 /// The beta parameter specifies how much the interval between the parents should be extended in direction of the worse parent. 62 62 /// </summary> 63 public ValueLookupParameter<Double Data> BetaParameter {64 get { return (ValueLookupParameter<Double Data>)Parameters["Beta"]; }63 public ValueLookupParameter<DoubleValue> BetaParameter { 64 get { return (ValueLookupParameter<DoubleValue>)Parameters["Beta"]; } 65 65 } 66 66 … … 71 71 public BlendAlphaBetaCrossover() 72 72 : base() { 73 Parameters.Add(new ValueLookupParameter<Bool Data>("Maximization", "Whether the problem is a maximization problem or not."));74 Parameters.Add(new SubScopesLookupParameter<Double Data>("Quality", "The quality values of the parents."));75 Parameters.Add(new ValueLookupParameter<Double Data>("Alpha", "The value for alpha.", new DoubleData(0.75)));76 Parameters.Add(new ValueLookupParameter<Double Data>("Beta", "The value for beta.", new DoubleData(0.25)));73 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "Whether the problem is a maximization problem or not.")); 74 Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The quality values of the parents.")); 75 Parameters.Add(new ValueLookupParameter<DoubleValue>("Alpha", "The value for alpha.", new DoubleValue(0.75))); 76 Parameters.Add(new ValueLookupParameter<DoubleValue>("Beta", "The value for beta.", new DoubleValue(0.25))); 77 77 } 78 78 … … 94 94 /// <param name="beta">The parameter beta.</param> 95 95 /// <returns>The real vector that results from the crossover.</returns> 96 public static DoubleArray Data Apply(IRandom random, DoubleArrayData betterParent, DoubleArrayData worseParent, DoubleData alpha, DoubleDatabeta) {96 public static DoubleArray Apply(IRandom random, DoubleArray betterParent, DoubleArray worseParent, DoubleValue alpha, DoubleValue beta) { 97 97 if (betterParent.Length != worseParent.Length) throw new ArgumentException("BlendAlphaBetaCrossover: The parents' vectors are of different length.", "betterParent"); 98 98 if (alpha.Value < 0) throw new ArgumentException("BlendAlphaBetaCrossover: Parameter alpha must be greater or equal to 0.", "alpha"); … … 100 100 int length = betterParent.Length; 101 101 double min, max, d; 102 DoubleArray Data result = new DoubleArrayData(length);102 DoubleArray result = new DoubleArray(length); 103 103 104 104 for (int i = 0; i < length; i++) { … … 117 117 118 118 /// <summary> 119 /// Checks if the number of parents is equal to 2, if all parameters are available and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleArrayData, DoubleData, DoubleData)"/>.119 /// Checks if the number of parents is equal to 2, if all parameters are available and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleArray, DoubleValue, DoubleValue)"/>. 120 120 /// </summary> 121 121 /// <exception cref="ArgumentException">Thrown when the number of parents is not equal to 2.</exception> … … 132 132 /// <param name="parents">The collection of parents (must be of size 2).</param> 133 133 /// <returns>The real vector that results from the crossover.</returns> 134 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {134 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 135 135 if (parents.Length != 2) throw new ArgumentException("BlendAlphaBetaCrossover: Number of parents is not equal to 2.", "parents"); 136 136 if (MaximizationParameter.ActualValue == null) throw new InvalidOperationException("BlendAlphaBetaCrossover: Parameter " + MaximizationParameter.ActualName + " could not be found."); … … 138 138 if (AlphaParameter.ActualValue == null || BetaParameter.ActualValue == null) throw new InvalidOperationException("BlendAlphaBetaCrossover: Parameter " + AlphaParameter.ActualName + " or paramter " + BetaParameter.ActualName + " could not be found."); 139 139 140 ItemArray<Double Data> qualities = QualityParameter.ActualValue;140 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 141 141 bool maximization = MaximizationParameter.ActualValue.Value; 142 142 // the better parent -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/BlendAlphaCrossover.cs
r3017 r3048 45 45 /// values left and right of the min and max value for each gene. 46 46 /// </summary> 47 public ValueLookupParameter<Double Data> AlphaParameter {48 get { return (ValueLookupParameter<Double Data>)Parameters["Alpha"]; }47 public ValueLookupParameter<DoubleValue> AlphaParameter { 48 get { return (ValueLookupParameter<DoubleValue>)Parameters["Alpha"]; } 49 49 } 50 50 /// <summary> … … 53 53 public BlendAlphaCrossover() 54 54 : base() { 55 Parameters.Add(new ValueLookupParameter<Double Data>("Alpha", "Value for alpha", new DoubleData(0.5)));55 Parameters.Add(new ValueLookupParameter<DoubleValue>("Alpha", "Value for alpha", new DoubleValue(0.5))); 56 56 } 57 57 … … 70 70 /// <param name="alpha">The alpha value for the crossover.</param> 71 71 /// <returns>The newly created real vector resulting from the crossover operation.</returns> 72 public static DoubleArray Data Apply(IRandom random, DoubleArrayData parent1, DoubleArrayData parent2, DoubleDataalpha) {72 public static DoubleArray Apply(IRandom random, DoubleArray parent1, DoubleArray parent2, DoubleValue alpha) { 73 73 if (parent1.Length != parent2.Length) throw new ArgumentException("BlendAlphaCrossover: The parents' vectors are of different length.", "parent1"); 74 74 if (alpha.Value < 0) throw new ArgumentException("BlendAlphaCrossover: Paramter alpha must be greater or equal than 0.", "alpha"); 75 75 int length = parent1.Length; 76 DoubleArray Data result = new DoubleArrayData(length);76 DoubleArray result = new DoubleArray(length); 77 77 double max = 0, min = 0, d = 0, resMin = 0, resMax = 0; 78 78 … … 90 90 91 91 /// <summary> 92 /// Checks that the number of parents is equal to 2 and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleArrayData, DoubleData)"/>.92 /// Checks that the number of parents is equal to 2 and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleArray, DoubleValue)"/>. 93 93 /// </summary> 94 94 /// <exception cref="ArgumentException">Thrown when the number of parents is not equal to 2.</exception> … … 97 97 /// <param name="parents">The collection of parents (must be of size 2).</param> 98 98 /// <returns>The real vector resulting from the crossover operation.</returns> 99 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {99 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 100 100 if (parents.Length != 2) throw new ArgumentException("BlendAlphaCrossover: The number of parents is not equal to 2", "parents"); 101 101 if (AlphaParameter.ActualValue == null) throw new InvalidOperationException("BlendAlphaCrossover: Parameter " + AlphaParameter.ActualName + " could not be found."); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/DiscreteCrossover.cs
r3017 r3048 45 45 /// <param name="parents">An array containing the parents that should be crossed.</param> 46 46 /// <returns>The newly created real vector, resulting from the crossover operation.</returns> 47 public static DoubleArray Data Apply(IRandom random, ItemArray<DoubleArrayData> parents) {47 public static DoubleArray Apply(IRandom random, ItemArray<DoubleArray> parents) { 48 48 int length = parents[0].Length; 49 49 … … 53 53 } 54 54 55 DoubleArray Data result = new DoubleArrayData(length);55 DoubleArray result = new DoubleArray(length); 56 56 for (int i = 0; i < length; i++) { 57 57 result[i] = parents[random.Next(parents.Length)][i]; … … 62 62 63 63 /// <summary> 64 /// Checks number of parents and forwards the call to <see cref="Apply(IRandom, ItemArray<DoubleArray Data>)"/>.64 /// Checks number of parents and forwards the call to <see cref="Apply(IRandom, ItemArray<DoubleArray>)"/>. 65 65 /// </summary> 66 66 /// <exception cref="ArgumentException">Thrown when <paramref name="parents"/> contains less than 2 elements.</exception> … … 68 68 /// <param name="parents">The collection of parents (must be of size 2 or greater).</param> 69 69 /// <returns>The real vector resulting from the crossover.</returns> 70 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {70 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 71 71 if (parents.Length < 2) throw new ArgumentException("DiscreteCrossover: The number of parents is less than 2.", "parents"); 72 72 return Apply(random, parents); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/HeuristicCrossover.cs
r3017 r3048 40 40 /// Whether the problem is a maximization or minimization problem. 41 41 /// </summary> 42 public ValueLookupParameter<Bool Data> MaximizationParameter {43 get { return (ValueLookupParameter<Bool Data>)Parameters["Maximization"]; }42 public ValueLookupParameter<BoolValue> MaximizationParameter { 43 get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 44 44 } 45 45 /// <summary> 46 46 /// The quality of the parents. 47 47 /// </summary> 48 public SubScopesLookupParameter<Double Data> QualityParameter {49 get { return (SubScopesLookupParameter<Double Data>)Parameters["Quality"]; }48 public SubScopesLookupParameter<DoubleValue> QualityParameter { 49 get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; } 50 50 } 51 51 … … 56 56 public HeuristicCrossover() 57 57 : base() { 58 Parameters.Add(new ValueLookupParameter<Bool Data>("Maximization", "Whether the problem is a maximization problem or not."));59 Parameters.Add(new SubScopesLookupParameter<Double Data>("Quality", "The quality values of the parents."));58 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "Whether the problem is a maximization problem or not.")); 59 Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The quality values of the parents.")); 60 60 } 61 61 … … 68 68 /// <param name="worseParent">The second parent for the crossover operation.</param> 69 69 /// <returns>The newly created real vector, resulting from the heuristic crossover.</returns> 70 public static DoubleArray Data Apply(IRandom random, DoubleArrayData betterParent, DoubleArrayDataworseParent) {70 public static DoubleArray Apply(IRandom random, DoubleArray betterParent, DoubleArray worseParent) { 71 71 if (betterParent.Length != worseParent.Length) 72 72 throw new ArgumentException("HeuristicCrossover: the two parents are not of the same length"); … … 79 79 result[i] = betterParent[i] + factor * (betterParent[i] - worseParent[i]); 80 80 } 81 return new DoubleArray Data(result);81 return new DoubleArray(result); 82 82 } 83 83 … … 96 96 /// <param name="parents">An array containing the two real vectors that should be crossed.</param> 97 97 /// <returns>The newly created real vector, resulting from the crossover operation.</returns> 98 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {98 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 99 99 if (parents.Length != 2) throw new ArgumentException("HeuristicCrossover: The number of parents is not equal to 2"); 100 100 … … 102 102 if (QualityParameter.ActualValue == null || QualityParameter.ActualValue.Length != parents.Length) throw new InvalidOperationException("HeuristicCrossover: Parameter " + QualityParameter.ActualName + " could not be found, or not in the same quantity as there are parents."); 103 103 104 ItemArray<Double Data> qualities = QualityParameter.ActualValue;104 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 105 105 bool maximization = MaximizationParameter.ActualValue.Value; 106 106 -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/LocalCrossover.cs
r3017 r3048 43 43 /// <param name="parent2">The second parent for the crossover operation.</param> 44 44 /// <returns>The newly created real vector, resulting from the local crossover.</returns> 45 public static DoubleArray Data Apply(IRandom random, DoubleArrayData parent1, DoubleArrayDataparent2) {45 public static DoubleArray Apply(IRandom random, DoubleArray parent1, DoubleArray parent2) { 46 46 if (parent1.Length != parent2.Length) 47 47 throw new ArgumentException("LocalCrossover: the two parents are not of the same length"); … … 55 55 result[i] = (factor * parent1[i]) + ((1 - factor) * parent2[i]); 56 56 } 57 return new DoubleArray Data(result);57 return new DoubleArray(result); 58 58 } 59 59 … … 65 65 /// <param name="parents">An array containing the two real vectors that should be crossed.</param> 66 66 /// <returns>The newly created real vector, resulting from the crossover operation.</returns> 67 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {67 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 68 68 if (parents.Length != 2) throw new ArgumentException("LocalCrossover: The number of parents is not equal to 2"); 69 69 return Apply(random, parents[0], parents[1]); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/RandomConvexCrossover.cs
r3017 r3048 43 43 /// <param name="parent2">The second parent vector for the crossover.</param> 44 44 /// <returns>The newly created real vector, resulting from the random convex crossover.</returns> 45 public static DoubleArray Data Apply(IRandom random, DoubleArrayData parent1, DoubleArrayDataparent2) {45 public static DoubleArray Apply(IRandom random, DoubleArray parent1, DoubleArray parent2) { 46 46 if (parent1.Length != parent2.Length) 47 47 throw new ArgumentException("ERROR in RandomConvexCrossover: the two parents are not of the same length"); … … 53 53 for (int i = 0; i < length; i++) 54 54 result[i] = (factor * parent1[i]) + ((1 - factor) * parent2[i]); 55 return new DoubleArray Data(result);55 return new DoubleArray(result); 56 56 } 57 57 … … 63 63 /// <param name="parents">An array containing the two real vectors that should be crossed.</param> 64 64 /// <returns>The newly created real vector, resulting from the crossover operation.</returns> 65 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {65 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 66 66 if (parents.Length != 2) throw new ArgumentException("ERROR in RandomConvexCrossover: The number of parents is not equal to 2"); 67 67 return Apply(random, parents[0], parents[1]); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/SimulatedBinaryCrossover.cs
r3017 r3048 40 40 /// The parameter must be greater or equal than 0. Common values are in the range [0;5] and more often just [2;5]. 41 41 /// </summary> 42 public ValueLookupParameter<Double Data> ContiguityParameter {43 get { return (ValueLookupParameter<Double Data>)Parameters["Contiguity"]; }42 public ValueLookupParameter<DoubleValue> ContiguityParameter { 43 get { return (ValueLookupParameter<DoubleValue>)Parameters["Contiguity"]; } 44 44 } 45 45 … … 50 50 public SimulatedBinaryCrossover() 51 51 : base() { 52 Parameters.Add(new ValueLookupParameter<Double Data>("Contiguity", "Specifies whether the crossover should produce very different (small value) or very similar (large value) children. Valid values must be greater or equal to 0.", new DoubleData(2)));52 Parameters.Add(new ValueLookupParameter<DoubleValue>("Contiguity", "Specifies whether the crossover should produce very different (small value) or very similar (large value) children. Valid values must be greater or equal to 0.", new DoubleValue(2))); 53 53 } 54 54 … … 66 66 /// <param name="contiguity">The contiguity value that specifies how close a child should be to its parents (larger value means closer). The value must be greater or equal than 0. Typical values are in the range [2;5].</param> 67 67 /// <returns>The vector resulting from the crossover.</returns> 68 public static DoubleArray Data Apply(IRandom random, DoubleArrayData parent1, DoubleArrayData parent2, DoubleDatacontiguity) {68 public static DoubleArray Apply(IRandom random, DoubleArray parent1, DoubleArray parent2, DoubleValue contiguity) { 69 69 if (parent1.Length != parent2.Length) throw new ArgumentException("SimulatedBinaryCrossover: Parents are of unequal length"); 70 70 if (contiguity.Value < 0) throw new ArgumentException("SimulatedBinaryCrossover: Contiguity value is smaller than 0", "contiguity"); 71 71 int length = parent1.Length; 72 DoubleArray Data result = new DoubleArrayData(length);72 DoubleArray result = new DoubleArray(length); 73 73 for (int i = 0; i < length; i++) { 74 74 if (length == 1 || random.NextDouble() < 0.5) { // cross this variable … … 92 92 93 93 /// <summary> 94 /// Checks number of parents, availability of the parameters and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleArrayData, DoubleData)"/>.94 /// Checks number of parents, availability of the parameters and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleArray, DoubleValue)"/>. 95 95 /// </summary> 96 96 /// <exception cref="ArgumentException">Thrown when there are not exactly 2 parents or when the contiguity parameter could not be found.</exception> … … 98 98 /// <param name="parents">The collection of parents (must be of size 2).</param> 99 99 /// <returns>The real vector resulting from the crossover.</returns> 100 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {100 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 101 101 if (parents.Length != 2) throw new ArgumentException("SimulatedBinaryCrossover: The number of parents is not equal to 2"); 102 102 if (ContiguityParameter.ActualValue == null) throw new InvalidOperationException("SimulatedBinaryCrossover: Parameter " + ContiguityParameter.ActualName + " could not be found."); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/SinglePointCrossover.cs
r3017 r3048 46 46 /// <param name="parent2">The second parent for crossover.</param> 47 47 /// <returns>The newly created real vector, resulting from the single point crossover.</returns> 48 public static DoubleArray Data Apply(IRandom random, DoubleArrayData parent1, DoubleArrayDataparent2) {48 public static DoubleArray Apply(IRandom random, DoubleArray parent1, DoubleArray parent2) { 49 49 if (parent1.Length != parent2.Length) throw new ArgumentException("SinglePointCrossover: Parents are of unequal length"); 50 50 int length = parent1.Length; 51 DoubleArray Data result = new DoubleArrayData(length);51 DoubleArray result = new DoubleArray(length); 52 52 int breakPoint = random.Next(1, length - 1); 53 53 … … 61 61 62 62 /// <summary> 63 /// Checks number of parents and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleArrayData)"/>.63 /// Checks number of parents and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleArray)"/>. 64 64 /// </summary> 65 65 /// <exception cref="ArgumentException">Thrown when the parents' vectors are of unequal length or when <paramref name="contiguity"/> is smaller than 0.</exception> … … 67 67 /// <param name="parents">The list of parents.</param> 68 68 /// <returns>A new real vector.</returns> 69 protected override HeuristicLab.Data.DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {69 protected override HeuristicLab.Data.DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 70 70 if (parents.Length != 2) throw new ArgumentException("SinglePointCrossover: The number of parents is not equal to 2"); 71 71 return Apply(random, parents[0], parents[1]); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/UniformAllPositionsArithmeticCrossover.cs
r3017 r3048 40 40 /// The alpha parameter needs to be in the interval [0;1] and specifies how close the resulting offspring should be either to parent1 (alpha -> 0) or parent2 (alpha -> 1). 41 41 /// </summary> 42 public ValueLookupParameter<Double Data> AlphaParameter {43 get { return (ValueLookupParameter<Double Data>)Parameters["Alpha"]; }42 public ValueLookupParameter<DoubleValue> AlphaParameter { 43 get { return (ValueLookupParameter<DoubleValue>)Parameters["Alpha"]; } 44 44 } 45 45 … … 49 49 public UniformAllPositionsArithmeticCrossover() 50 50 : base() { 51 Parameters.Add(new ValueLookupParameter<Double Data>("Alpha", "The alpha value in the range [0;1]", new DoubleData(0.33)));51 Parameters.Add(new ValueLookupParameter<DoubleValue>("Alpha", "The alpha value in the range [0;1]", new DoubleValue(0.33))); 52 52 } 53 53 … … 61 61 /// <param name="alpha">The alpha parameter (<see cref="AlphaParameter"/>).</param> 62 62 /// <returns>The vector resulting from the crossover.</returns> 63 public static DoubleArray Data Apply(IRandom random, DoubleArrayData parent1, DoubleArrayData parent2, DoubleDataalpha) {63 public static DoubleArray Apply(IRandom random, DoubleArray parent1, DoubleArray parent2, DoubleValue alpha) { 64 64 int length = parent1.Length; 65 65 if (length != parent2.Length) throw new ArgumentException("UniformAllPositionsArithmeticCrossover: The parent vectors are of different length.", "parent1"); 66 66 if (alpha.Value < 0 || alpha.Value > 1) throw new ArgumentException("UniformAllPositionsArithmeticCrossover: Parameter alpha must be in the range [0;1]", "alpha"); 67 DoubleArray Data result = new DoubleArrayData(length);67 DoubleArray result = new DoubleArray(length); 68 68 for (int i = 0; i < length; i++) { 69 69 result[i] = alpha.Value * parent1[i] + (1 - alpha.Value) * parent2[i]; … … 73 73 74 74 /// <summary> 75 /// Checks that there are exactly 2 parents, that the alpha parameter is not null and fowards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleArrrayData, DoubleData)"/>.75 /// Checks that there are exactly 2 parents, that the alpha parameter is not null and fowards the call to <see cref="Apply(IRandom, DoubleArray, DoubleArrrayData, DoubleValue)"/>. 76 76 /// </summary> 77 77 /// <exception cref="ArgumentException">Thrown when there are not exactly two parents.</exception> … … 80 80 /// <param name="parents">The collection of parents (must be of size 2).</param> 81 81 /// <returns>The vector resulting from the crossover.</returns> 82 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {82 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 83 83 if (parents.Length != 2) throw new ArgumentException("UniformAllPositionsArithmeticCrossover: There must be exactly two parents.", "parents"); 84 84 if (AlphaParameter.ActualValue == null) throw new InvalidOperationException("UniformAllPositionsArithmeticCrossover: Parameter " + AlphaParameter.ActualName + " could not be found."); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/UniformSomePositionsArithmeticCrossover.cs
r3017 r3048 40 40 /// The alpha parameter needs to be in the interval [0;1] and specifies how close the resulting offspring should be either to parent1 (alpha -> 0) or parent2 (alpha -> 1). 41 41 /// </summary> 42 public ValueLookupParameter<Double Data> AlphaParameter {43 get { return (ValueLookupParameter<Double Data>)Parameters["Alpha"]; }42 public ValueLookupParameter<DoubleValue> AlphaParameter { 43 get { return (ValueLookupParameter<DoubleValue>)Parameters["Alpha"]; } 44 44 } 45 45 /// <summary> 46 46 /// The probability in the range [0;1] for each position in the vector to be crossed. 47 47 /// </summary> 48 public ValueLookupParameter<Double Data> ProbabilityParameter {49 get { return (ValueLookupParameter<Double Data>)Parameters["Probability"]; }48 public ValueLookupParameter<DoubleValue> ProbabilityParameter { 49 get { return (ValueLookupParameter<DoubleValue>)Parameters["Probability"]; } 50 50 } 51 51 … … 55 55 public UniformSomePositionsArithmeticCrossover() 56 56 : base() { 57 Parameters.Add(new ValueLookupParameter<Double Data>("Alpha", "The alpha value in the range [0;1]", new DoubleData(0.5)));58 Parameters.Add(new ValueLookupParameter<Double Data>("Probability", "The probability for crossing a position in the range [0;1]", new DoubleData(0.5)));57 Parameters.Add(new ValueLookupParameter<DoubleValue>("Alpha", "The alpha value in the range [0;1]", new DoubleValue(0.5))); 58 Parameters.Add(new ValueLookupParameter<DoubleValue>("Probability", "The probability for crossing a position in the range [0;1]", new DoubleValue(0.5))); 59 59 } 60 60 … … 68 68 /// <param name="probability">The probability parameter (<see cref="ProbabilityParameter"/>).</param> 69 69 /// <returns>The vector resulting from the crossover.</returns> 70 public static DoubleArray Data Apply(IRandom random, DoubleArrayData parent1, DoubleArrayData parent2, DoubleData alpha, DoubleDataprobability) {70 public static DoubleArray Apply(IRandom random, DoubleArray parent1, DoubleArray parent2, DoubleValue alpha, DoubleValue probability) { 71 71 int length = parent1.Length; 72 72 if (length != parent2.Length) throw new ArgumentException("UniformSomePositionsArithmeticCrossover: The parent vectors are of different length.", "parent1"); … … 74 74 if (probability.Value < 0 || probability.Value > 1) throw new ArgumentException("UniformSomePositionsArithmeticCrossover: Parameter probability must be in the range [0;1]", "probability"); 75 75 76 DoubleArray Data result = new DoubleArrayData(length);76 DoubleArray result = new DoubleArray(length); 77 77 for (int i = 0; i < length; i++) { 78 78 if (random.NextDouble() < probability.Value) … … 84 84 85 85 /// <summary> 86 /// Checks that there are exactly 2 parents, that the alpha and the probability parameter are not null and fowards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleArrrayData, DoubleData)"/>.86 /// Checks that there are exactly 2 parents, that the alpha and the probability parameter are not null and fowards the call to <see cref="Apply(IRandom, DoubleArray, DoubleArrrayData, DoubleValue)"/>. 87 87 /// </summary> 88 88 /// <exception cref="ArgumentException">Thrown when there are not exactly two parents.</exception> … … 91 91 /// <param name="parents">The collection of parents (must be of size 2).</param> 92 92 /// <returns>The vector resulting from the crossover.</returns> 93 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {93 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 94 94 if (parents.Length != 2) throw new ArgumentException("UniformSomePositionsArithmeticCrossover: There must be exactly two parents.", "parents"); 95 95 if (AlphaParameter.ActualValue == null) throw new InvalidOperationException("UniformSomePositionsArithmeticCrossover: Parameter " + AlphaParameter.ActualName + " could not be found."); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Interfaces/IRealVectorCreator.cs
r2900 r3048 29 29 /// </summary> 30 30 public interface IRealVectorCreator : IRealVectorOperator, ISolutionCreator { 31 IValueLookupParameter<Int Data> LengthParameter { get; }32 IValueLookupParameter<Double Data> MinimumParameter { get; }33 IValueLookupParameter<Double Data> MaximumParameter { get; }34 ILookupParameter<DoubleArray Data> RealVectorParameter { get; }31 IValueLookupParameter<IntValue> LengthParameter { get; } 32 IValueLookupParameter<DoubleValue> MinimumParameter { get; } 33 IValueLookupParameter<DoubleValue> MaximumParameter { get; } 34 ILookupParameter<DoubleArray> RealVectorParameter { get; } 35 35 } 36 36 } -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Interfaces/IRealVectorCrossover.cs
r2900 r3048 29 29 /// </summary> 30 30 public interface IRealVectorCrossover : IRealVectorOperator, ICrossover { 31 ILookupParameter<ItemArray<DoubleArray Data>> ParentsParameter { get; }32 ILookupParameter<DoubleArray Data> ChildParameter { get; }31 ILookupParameter<ItemArray<DoubleArray>> ParentsParameter { get; } 32 ILookupParameter<DoubleArray> ChildParameter { get; } 33 33 } 34 34 } -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Interfaces/IRealVectorManipulator.cs
r2900 r3048 29 29 /// </summary> 30 30 public interface IRealVectorManipulator : IRealVectorOperator, IManipulator { 31 ILookupParameter<DoubleArray Data> RealVectorParameter { get; }31 ILookupParameter<DoubleArray> RealVectorParameter { get; } 32 32 } 33 33 } -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Manipulators/BreederGeneticAlgorithmManipulator.cs
r3026 r3048 38 38 public class BreederGeneticAlgorithmManipulator : RealVectorManipulator { 39 39 private static readonly double[] powerOfTwo = new double[] { 1, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625, 0.0078125, 0.00390625, 0.001953125, 0.0009765625, 0.00048828125, 0.000244140625, 0.0001220703125, 0.00006103515625, 0.000030517578125 }; 40 public ValueLookupParameter<Double Data> MinimumParameter {41 get { return (ValueLookupParameter<Double Data>)Parameters["Minimum"]; }40 public ValueLookupParameter<DoubleValue> MinimumParameter { 41 get { return (ValueLookupParameter<DoubleValue>)Parameters["Minimum"]; } 42 42 } 43 public ValueLookupParameter<Double Data> MaximumParameter {44 get { return (ValueLookupParameter<Double Data>)Parameters["Maximum"]; }43 public ValueLookupParameter<DoubleValue> MaximumParameter { 44 get { return (ValueLookupParameter<DoubleValue>)Parameters["Maximum"]; } 45 45 } 46 public ValueLookupParameter<Double Data> SearchIntervalFactorParameter {47 get { return (ValueLookupParameter<Double Data>)Parameters["SearchIntervalFactor"]; }46 public ValueLookupParameter<DoubleValue> SearchIntervalFactorParameter { 47 get { return (ValueLookupParameter<DoubleValue>)Parameters["SearchIntervalFactor"]; } 48 48 } 49 49 /// <summary> … … 53 53 public BreederGeneticAlgorithmManipulator() 54 54 : base() { 55 Parameters.Add(new ValueLookupParameter<Double Data>("Minimum", "The lower bound for each element in the vector."));56 Parameters.Add(new ValueLookupParameter<Double Data>("Maximum", "The upper bound for each element in the vector."));57 Parameters.Add(new ValueLookupParameter<Double Data>("SearchIntervalFactor", "The factor determining the size of the search interval, that will be added/removed to/from the allele selected for manipulation.", new DoubleData(0.1)));55 Parameters.Add(new ValueLookupParameter<DoubleValue>("Minimum", "The lower bound for each element in the vector.")); 56 Parameters.Add(new ValueLookupParameter<DoubleValue>("Maximum", "The upper bound for each element in the vector.")); 57 Parameters.Add(new ValueLookupParameter<DoubleValue>("SearchIntervalFactor", "The factor determining the size of the search interval, that will be added/removed to/from the allele selected for manipulation.", new DoubleValue(0.1))); 58 58 } 59 59 … … 66 66 /// <param name="max">The maximum number of the sampling range for the vector element (exclusive).</param> 67 67 /// <param name="searchIntervalFactor">The factor determining the size of the search interval.</param> 68 public static void Apply(IRandom random, DoubleArray Data vector, DoubleData min, DoubleData max, DoubleDatasearchIntervalFactor) {68 public static void Apply(IRandom random, DoubleArray vector, DoubleValue min, DoubleValue max, DoubleValue searchIntervalFactor) { 69 69 int length = vector.Length; 70 70 double prob, value; … … 114 114 115 115 /// <summary> 116 /// Checks the parameters Minimum, Maximum, and SearchIntervalFactor and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleData, DoubleData, DoubleData)"/>.116 /// Checks the parameters Minimum, Maximum, and SearchIntervalFactor and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleValue, DoubleValue, DoubleValue)"/>. 117 117 /// </summary> 118 118 /// <param name="random">A random number generator.</param> 119 119 /// <param name="realVector">The real vector to manipulate.</param> 120 protected override void Manipulate(IRandom random, DoubleArray DatarealVector) {120 protected override void Manipulate(IRandom random, DoubleArray realVector) { 121 121 if (MinimumParameter.ActualValue == null) throw new InvalidOperationException("BreederGeneticAlgorithmManipulator: Parameter " + MinimumParameter.ActualName + " could not be found."); 122 122 if (MaximumParameter.ActualValue == null) throw new InvalidOperationException("BreederGeneticAlgorithmManipulator: Paraemter " + MaximumParameter.ActualName + " could not be found."); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Manipulators/MichalewiczNonUniformAllPositionsManipulator.cs
r3017 r3048 40 40 /// The lower bound of the values in the real vector. 41 41 /// </summary> 42 public ValueLookupParameter<Double Data> MinimumParameter {43 get { return (ValueLookupParameter<Double Data>)Parameters["Minimum"]; }42 public ValueLookupParameter<DoubleValue> MinimumParameter { 43 get { return (ValueLookupParameter<DoubleValue>)Parameters["Minimum"]; } 44 44 } 45 45 /// <summary> 46 46 /// The upper bound of the values in the real vector. 47 47 /// </summary> 48 public ValueLookupParameter<Double Data> MaximumParameter {49 get { return (ValueLookupParameter<Double Data>)Parameters["Maximum"]; }48 public ValueLookupParameter<DoubleValue> MaximumParameter { 49 get { return (ValueLookupParameter<DoubleValue>)Parameters["Maximum"]; } 50 50 } 51 51 /// <summary> 52 52 /// The current generation. 53 53 /// </summary> 54 public LookupParameter<Int Data> GenerationParameter {55 get { return (LookupParameter<Int Data>)Parameters["Generation"]; }54 public LookupParameter<IntValue> GenerationParameter { 55 get { return (LookupParameter<IntValue>)Parameters["Generation"]; } 56 56 } 57 57 /// <summary> 58 58 /// The maximum generation. 59 59 /// </summary> 60 public LookupParameter<Int Data> MaximumGenerationsParameter {61 get { return (LookupParameter<Int Data>)Parameters["MaximumGenerations"]; }60 public LookupParameter<IntValue> MaximumGenerationsParameter { 61 get { return (LookupParameter<IntValue>)Parameters["MaximumGenerations"]; } 62 62 } 63 63 /// <summary> 64 64 /// The parameter describing how much the mutation should depend on the progress towards the maximum generation. 65 65 /// </summary> 66 public ValueLookupParameter<Double Data> GenerationDependencyParameter {67 get { return (ValueLookupParameter<Double Data>)Parameters["GenerationDependency"]; }66 public ValueLookupParameter<DoubleValue> GenerationDependencyParameter { 67 get { return (ValueLookupParameter<DoubleValue>)Parameters["GenerationDependency"]; } 68 68 } 69 69 … … 75 75 public MichalewiczNonUniformAllPositionsManipulator() 76 76 : base() { 77 Parameters.Add(new ValueLookupParameter<Double Data>("Minimum", "Minimum of the sampling range for the vector element (included)"));78 Parameters.Add(new ValueLookupParameter<Double Data>("Maximum", "Maximum of the sampling range for the vector element (excluded)"));79 Parameters.Add(new LookupParameter<Int Data>("Generation", "Current generation of the algorithm"));80 Parameters.Add(new LookupParameter<Int Data>("MaximumGenerations", "Maximum number of generations"));81 Parameters.Add(new ValueLookupParameter<Double Data>("GenerationDependency", "Specifies the degree of dependency on the number of generations", new DoubleData(5)));77 Parameters.Add(new ValueLookupParameter<DoubleValue>("Minimum", "Minimum of the sampling range for the vector element (included)")); 78 Parameters.Add(new ValueLookupParameter<DoubleValue>("Maximum", "Maximum of the sampling range for the vector element (excluded)")); 79 Parameters.Add(new LookupParameter<IntValue>("Generation", "Current generation of the algorithm")); 80 Parameters.Add(new LookupParameter<IntValue>("MaximumGenerations", "Maximum number of generations")); 81 Parameters.Add(new ValueLookupParameter<DoubleValue>("GenerationDependency", "Specifies the degree of dependency on the number of generations", new DoubleValue(5))); 82 82 } 83 83 … … 95 95 /// <param name="generationsDependency">Specifies the degree of dependency on the number of generations.</param> 96 96 /// <returns>The manipulated real vector.</returns> 97 public static void Apply(IRandom random, DoubleArray Data vector, DoubleData min, DoubleData max, IntData currentGeneration, IntData maximumGenerations, DoubleDatagenerationsDependency) {97 public static void Apply(IRandom random, DoubleArray vector, DoubleValue min, DoubleValue max, IntValue currentGeneration, IntValue maximumGenerations, DoubleValue generationsDependency) { 98 98 if (currentGeneration.Value > maximumGenerations.Value) throw new ArgumentException("MichalewiczNonUniformAllPositionManipulator: CurrentGeneration must be smaller or equal than MaximumGeneration", "currentGeneration"); 99 99 int length = vector.Length; … … 111 111 112 112 /// <summary> 113 /// Checks if all parameters are available and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleData, DoubleData, IntData, IntData, DoubleData)"/>.113 /// Checks if all parameters are available and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleValue, DoubleValue, IntValue, IntValue, DoubleValue)"/>. 114 114 /// </summary> 115 115 /// <param name="random">The random number generator.</param> 116 116 /// <param name="realVector">The real vector that should be manipulated.</param> 117 protected override void Manipulate(IRandom random, DoubleArray DatarealVector) {117 protected override void Manipulate(IRandom random, DoubleArray realVector) { 118 118 if (MinimumParameter.ActualValue == null) throw new InvalidOperationException("MichalewiczNonUniformAllPositionManipulator: Parameter " + MinimumParameter.ActualName + " could not be found."); 119 119 if (MaximumParameter.ActualValue == null) throw new InvalidOperationException("MichalewiczNonUniformAllPositionManipulator: Parameter " + MaximumParameter.ActualName + " could not be found."); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Manipulators/MichalewiczNonUniformOnePositionManipulator.cs
r3017 r3048 40 40 /// The lower bound of the values in the real vector. 41 41 /// </summary> 42 public ValueLookupParameter<Double Data> MinimumParameter {43 get { return (ValueLookupParameter<Double Data>)Parameters["Minimum"]; }42 public ValueLookupParameter<DoubleValue> MinimumParameter { 43 get { return (ValueLookupParameter<DoubleValue>)Parameters["Minimum"]; } 44 44 } 45 45 /// <summary> 46 46 /// The upper bound of the values in the real vector. 47 47 /// </summary> 48 public ValueLookupParameter<Double Data> MaximumParameter {49 get { return (ValueLookupParameter<Double Data>)Parameters["Maximum"]; }48 public ValueLookupParameter<DoubleValue> MaximumParameter { 49 get { return (ValueLookupParameter<DoubleValue>)Parameters["Maximum"]; } 50 50 } 51 51 /// <summary> 52 52 /// The current generation. 53 53 /// </summary> 54 public LookupParameter<Int Data> GenerationParameter {55 get { return (LookupParameter<Int Data>)Parameters["Generation"]; }54 public LookupParameter<IntValue> GenerationParameter { 55 get { return (LookupParameter<IntValue>)Parameters["Generation"]; } 56 56 } 57 57 /// <summary> 58 58 /// The maximum generation. 59 59 /// </summary> 60 public LookupParameter<Int Data> MaximumGenerationsParameter {61 get { return (LookupParameter<Int Data>)Parameters["MaximumGenerations"]; }60 public LookupParameter<IntValue> MaximumGenerationsParameter { 61 get { return (LookupParameter<IntValue>)Parameters["MaximumGenerations"]; } 62 62 } 63 63 /// <summary> 64 64 /// The parameter describing how much the mutation should depend on the progress towards the maximum generation. 65 65 /// </summary> 66 public ValueLookupParameter<Double Data> GenerationDependencyParameter {67 get { return (ValueLookupParameter<Double Data>)Parameters["GenerationDependency"]; }66 public ValueLookupParameter<DoubleValue> GenerationDependencyParameter { 67 get { return (ValueLookupParameter<DoubleValue>)Parameters["GenerationDependency"]; } 68 68 } 69 69 … … 75 75 public MichalewiczNonUniformOnePositionManipulator() 76 76 : base() { 77 Parameters.Add(new ValueLookupParameter<Double Data>("Minimum", "Minimum of the sampling range for the vector element (included)"));78 Parameters.Add(new ValueLookupParameter<Double Data>("Maximum", "Maximum of the sampling range for the vector element (excluded)"));79 Parameters.Add(new LookupParameter<Int Data>("Generation", "Current generation of the algorithm"));80 Parameters.Add(new LookupParameter<Int Data>("MaximumGenerations", "Maximum number of generations"));81 Parameters.Add(new ValueLookupParameter<Double Data>("GenerationDependency", "Specifies the degree of dependency on the number of generations", new DoubleData(5)));77 Parameters.Add(new ValueLookupParameter<DoubleValue>("Minimum", "Minimum of the sampling range for the vector element (included)")); 78 Parameters.Add(new ValueLookupParameter<DoubleValue>("Maximum", "Maximum of the sampling range for the vector element (excluded)")); 79 Parameters.Add(new LookupParameter<IntValue>("Generation", "Current generation of the algorithm")); 80 Parameters.Add(new LookupParameter<IntValue>("MaximumGenerations", "Maximum number of generations")); 81 Parameters.Add(new ValueLookupParameter<DoubleValue>("GenerationDependency", "Specifies the degree of dependency on the number of generations", new DoubleValue(5))); 82 82 } 83 83 … … 95 95 /// <param name="generationsDependency">Specifies the degree of dependency on the number of generations.</param> 96 96 /// <returns>The manipulated real vector.</returns> 97 public static void Apply(IRandom random, DoubleArray Data vector, DoubleData min, DoubleData max, IntData currentGeneration, IntData maximumGenerations, DoubleDatagenerationsDependency) {97 public static void Apply(IRandom random, DoubleArray vector, DoubleValue min, DoubleValue max, IntValue currentGeneration, IntValue maximumGenerations, DoubleValue generationsDependency) { 98 98 if (currentGeneration.Value > maximumGenerations.Value) throw new ArgumentException("MichalewiczNonUniformOnePositionManipulator: CurrentGeneration must be smaller or equal than MaximumGeneration", "currentGeneration"); 99 99 int length = vector.Length; … … 110 110 111 111 /// <summary> 112 /// Checks if all parameters are available and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleData, DoubleData, IntData, IntData, DoubleData)"/>.112 /// Checks if all parameters are available and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleValue, DoubleValue, IntValue, IntValue, DoubleValue)"/>. 113 113 /// </summary> 114 114 /// <param name="random">The random number generator.</param> 115 115 /// <param name="realVector">The real vector that should be manipulated.</param> 116 protected override void Manipulate(IRandom random, DoubleArray DatarealVector) {116 protected override void Manipulate(IRandom random, DoubleArray realVector) { 117 117 if (MinimumParameter.ActualValue == null) throw new InvalidOperationException("MichalewiczNonUniformOnePositionManipulator: Parameter " + MinimumParameter.ActualName + " could not be found."); 118 118 if (MaximumParameter.ActualValue == null) throw new InvalidOperationException("MichalewiczNonUniformOnePositionManipulator: Parameter " + MaximumParameter.ActualName + " could not be found."); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Manipulators/PolynomialAllPositionManipulator.cs
r3017 r3048 41 41 /// A higher value will shape the density function such that values closer to 0 (little manipulation) are more likely than values closer to 1 or -1 (maximum manipulation). 42 42 /// </summary> 43 public ValueLookupParameter<Double Data> ContiguityParameter {44 get { return (ValueLookupParameter<Double Data>)Parameters["Contiguity"]; }43 public ValueLookupParameter<DoubleValue> ContiguityParameter { 44 get { return (ValueLookupParameter<DoubleValue>)Parameters["Contiguity"]; } 45 45 } 46 46 /// <summary> … … 50 50 /// The manipulated value is not restricted by the (possibly) specified lower and upper bounds. Use the <see cref="BoundsChecker"/> to correct the values after performing the mutation. 51 51 /// </remarks> 52 public ValueLookupParameter<Double Data> MaximumManipulationParameter {53 get { return (ValueLookupParameter<Double Data>)Parameters["MaximumManipulation"]; }52 public ValueLookupParameter<DoubleValue> MaximumManipulationParameter { 53 get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumManipulation"]; } 54 54 } 55 55 … … 60 60 public PolynomialAllPositionManipulator() 61 61 : base() { 62 Parameters.Add(new ValueLookupParameter<Double Data>("Contiguity", "Specifies whether the manipulation should produce far stretching (small value) or close (large value) manipulations with higher probability. Valid values must be greater or equal to 0.", new DoubleData(2)));63 Parameters.Add(new ValueLookupParameter<Double Data>("MaximumManipulation", "Specifies the maximum value that should be added or subtracted by the manipulation. If this value is set to 0 no mutation will be performed.", new DoubleData(1)));62 Parameters.Add(new ValueLookupParameter<DoubleValue>("Contiguity", "Specifies whether the manipulation should produce far stretching (small value) or close (large value) manipulations with higher probability. Valid values must be greater or equal to 0.", new DoubleValue(2))); 63 Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumManipulation", "Specifies the maximum value that should be added or subtracted by the manipulation. If this value is set to 0 no mutation will be performed.", new DoubleValue(1))); 64 64 } 65 65 … … 71 71 /// <param name="contiguity">A parameter describing the shape of the probability density function which influences the strength of the manipulation.</param> 72 72 /// <param name="maxManipulation">The maximum strength of the manipulation.</param> 73 public static void Apply(IRandom random, DoubleArray Data vector, DoubleData contiguity, DoubleDatamaxManipulation) {73 public static void Apply(IRandom random, DoubleArray vector, DoubleValue contiguity, DoubleValue maxManipulation) { 74 74 if (contiguity.Value < 0) throw new ArgumentException("PolynomialAllPositionManipulator: Contiguity value is smaller than 0", "contiguity"); 75 75 double u, delta = 0; … … 88 88 89 89 /// <summary> 90 /// Checks the availability of the parameters and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleData, DoubleData)"/>.90 /// Checks the availability of the parameters and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleValue, DoubleValue)"/>. 91 91 /// </summary> 92 92 /// <param name="random">The random number generator to use.</param> 93 93 /// <param name="realVector">The vector of real values to manipulate.</param> 94 protected override void Manipulate(IRandom random, DoubleArray DatarealVector) {94 protected override void Manipulate(IRandom random, DoubleArray realVector) { 95 95 if (ContiguityParameter.ActualValue == null) throw new InvalidOperationException("PolynomialAllPositionManipulator: Parameter " + ContiguityParameter.ActualName + " could not be found."); 96 96 if (MaximumManipulationParameter.ActualValue == null) throw new InvalidOperationException("PolynomialAllPositionManipulator: Parameter " + MaximumManipulationParameter.ActualName + " could not be found."); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Manipulators/PolynomialOnePositionManipulator.cs
r3017 r3048 40 40 /// A higher value will shape the density function such that values closer to 0 (little manipulation) are more likely than values closer to 1 or -1 (maximum manipulation). 41 41 /// </summary> 42 public ValueLookupParameter<Double Data> ContiguityParameter {43 get { return (ValueLookupParameter<Double Data>)Parameters["Contiguity"]; }42 public ValueLookupParameter<DoubleValue> ContiguityParameter { 43 get { return (ValueLookupParameter<DoubleValue>)Parameters["Contiguity"]; } 44 44 } 45 45 /// <summary> … … 49 49 /// The manipulated value is not restricted by the (possibly) specified lower and upper bounds. Use the <see cref="BoundsChecker"/> to correct the values after performing the mutation. 50 50 /// </remarks> 51 public ValueLookupParameter<Double Data> MaximumManipulationParameter {52 get { return (ValueLookupParameter<Double Data>)Parameters["MaximumManipulation"]; }51 public ValueLookupParameter<DoubleValue> MaximumManipulationParameter { 52 get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumManipulation"]; } 53 53 } 54 54 … … 59 59 public PolynomialOnePositionManipulator() 60 60 : base() { 61 Parameters.Add(new ValueLookupParameter<Double Data>("Contiguity", "Specifies whether the manipulation should produce far stretching (small value) or close (large value) manipulations with higher probability. Valid values must be greater or equal to 0.", new DoubleData(2)));62 Parameters.Add(new ValueLookupParameter<Double Data>("MaximumManipulation", "Specifies the maximum value that should be added or subtracted by the manipulation. If this value is set to 0 no mutation will be performed.", new DoubleData(1)));61 Parameters.Add(new ValueLookupParameter<DoubleValue>("Contiguity", "Specifies whether the manipulation should produce far stretching (small value) or close (large value) manipulations with higher probability. Valid values must be greater or equal to 0.", new DoubleValue(2))); 62 Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumManipulation", "Specifies the maximum value that should be added or subtracted by the manipulation. If this value is set to 0 no mutation will be performed.", new DoubleValue(1))); 63 63 } 64 64 … … 70 70 /// <param name="contiguity">A parameter describing the shape of the probability density function which influences the strength of the manipulation.</param> 71 71 /// <param name="maxManipulation">The maximum strength of the manipulation.</param> 72 public static void Apply(IRandom random, DoubleArray Data vector, DoubleData contiguity, DoubleDatamaxManipulation) {72 public static void Apply(IRandom random, DoubleArray vector, DoubleValue contiguity, DoubleValue maxManipulation) { 73 73 if (contiguity.Value < 0) throw new ArgumentException("PolynomialOnePositionManipulator: Contiguity value is smaller than 0", "contiguity"); 74 74 int index = random.Next(vector.Length); … … 85 85 86 86 /// <summary> 87 /// Checks the availability of the parameters and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleData, DoubleData)"/>.87 /// Checks the availability of the parameters and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleValue, DoubleValue)"/>. 88 88 /// </summary> 89 89 /// <param name="random">The random number generator to use.</param> 90 90 /// <param name="realVector">The vector of real values to manipulate.</param> 91 protected override void Manipulate(IRandom random, DoubleArray DatarealVector) {91 protected override void Manipulate(IRandom random, DoubleArray realVector) { 92 92 if (ContiguityParameter.ActualValue == null) throw new InvalidOperationException("PolynomialOnePositionManipulator: Parameter " + ContiguityParameter.ActualName + " could not be found."); 93 93 if (MaximumManipulationParameter.ActualValue == null) throw new InvalidOperationException("PolynomialOnePositionManipulator: Parameter " + MaximumManipulationParameter.ActualName + " could not be found."); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Manipulators/SelfAdaptiveNormalAllPositionsManipulator.cs
r3017 r3048 42 42 /// Parameter for the strategy vector. 43 43 /// </summary> 44 public LookupParameter<DoubleArray Data> StrategyVectorParameter {45 get { return (LookupParameter<DoubleArray Data>)Parameters["StrategyVector"]; }44 public LookupParameter<DoubleArray> StrategyVectorParameter { 45 get { return (LookupParameter<DoubleArray>)Parameters["StrategyVector"]; } 46 46 } 47 47 /// <summary> … … 51 51 public SelfAdaptiveNormalAllPositionsManipulator() 52 52 : base() { 53 Parameters.Add(new LookupParameter<DoubleArray Data>("StrategyVector", "The vector containing the endogenous strategy parameters."));53 Parameters.Add(new LookupParameter<DoubleArray>("StrategyVector", "The vector containing the endogenous strategy parameters.")); 54 54 } 55 55 … … 64 64 /// <param name="vector">The real vector to manipulate.</param> 65 65 /// <returns>The manipulated real vector.</returns> 66 public static void Apply(IRandom random, DoubleArray Data vector, DoubleArrayDatastrategyParameters) {66 public static void Apply(IRandom random, DoubleArray vector, DoubleArray strategyParameters) { 67 67 NormalDistributedRandom N = new NormalDistributedRandom(random, 0.0, 1.0); 68 68 for (int i = 0; i < vector.Length; i++) { … … 72 72 73 73 /// <summary> 74 /// Checks that the strategy vector is not null and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleArrayData)"/>.74 /// Checks that the strategy vector is not null and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleArray)"/>. 75 75 /// </summary> 76 76 /// <param name="random">The random number generator.</param> 77 77 /// <param name="realVector">The vector of real values that is manipulated.</param> 78 protected override void Manipulate(IRandom random, DoubleArray DatarealVector) {78 protected override void Manipulate(IRandom random, DoubleArray realVector) { 79 79 if (StrategyVectorParameter.ActualValue == null) throw new InvalidOperationException("SelfAdaptiveNormalAllPositionsManipulator: Parameter " + StrategyVectorParameter.ActualName + " could not be found."); 80 80 Apply(random, realVector, StrategyVectorParameter.ActualValue); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Manipulators/UniformOnePositionManipulator.cs
r3017 r3048 39 39 /// The lower bound of the values in the real vector. 40 40 /// </summary> 41 public ValueLookupParameter<Double Data> MinimumParameter {42 get { return (ValueLookupParameter<Double Data>)Parameters["Minimum"]; }41 public ValueLookupParameter<DoubleValue> MinimumParameter { 42 get { return (ValueLookupParameter<DoubleValue>)Parameters["Minimum"]; } 43 43 } 44 44 /// <summary> 45 45 /// The upper bound of the values in the real vector. 46 46 /// </summary> 47 public ValueLookupParameter<Double Data> MaximumParameter {48 get { return (ValueLookupParameter<Double Data>)Parameters["Maximum"]; }47 public ValueLookupParameter<DoubleValue> MaximumParameter { 48 get { return (ValueLookupParameter<DoubleValue>)Parameters["Maximum"]; } 49 49 } 50 50 … … 54 54 /// </summary> 55 55 public UniformOnePositionManipulator() { 56 Parameters.Add(new ValueLookupParameter<Double Data>("Minimum", "Minimum of the sampling range for the vector element (included)"));57 Parameters.Add(new ValueLookupParameter<Double Data>("Maximum", "Maximum of the sampling range for the vector element (excluded)"));56 Parameters.Add(new ValueLookupParameter<DoubleValue>("Minimum", "Minimum of the sampling range for the vector element (included)")); 57 Parameters.Add(new ValueLookupParameter<DoubleValue>("Maximum", "Maximum of the sampling range for the vector element (excluded)")); 58 58 } 59 59 … … 67 67 /// <param name="max">The maximum value of the sampling range for 68 68 /// the vector element to change (exclusive).</param> 69 public static void Apply(IRandom random, DoubleArray Data vector, DoubleData min, DoubleDatamax) {69 public static void Apply(IRandom random, DoubleArray vector, DoubleValue min, DoubleValue max) { 70 70 int index = random.Next(vector.Length); 71 71 vector[index] = min.Value + random.NextDouble() * (max.Value - min.Value); … … 73 73 74 74 /// <summary> 75 /// Checks if the minimum and maximum parameters are available and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleData, DoubleData)"/>.75 /// Checks if the minimum and maximum parameters are available and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleValue, DoubleValue)"/>. 76 76 /// </summary> 77 77 /// <param name="random">The random number generator to use.</param> 78 78 /// <param name="realVector">The real vector to manipulate.</param> 79 protected override void Manipulate(IRandom random, DoubleArray DatarealVector) {79 protected override void Manipulate(IRandom random, DoubleArray realVector) { 80 80 if (MinimumParameter.ActualValue == null) throw new InvalidOperationException("UniformOnePositionManipulator: Parameter " + MinimumParameter.ActualName + " could not be found."); 81 81 if (MaximumParameter.ActualValue == null) throw new InvalidOperationException("UniformOnePositionManipulator: Parameter " + MaximumParameter.ActualName + " could not be found."); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/RealVectorCreator.cs
r3034 r3048 41 41 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 42 42 } 43 public ILookupParameter<DoubleArray Data> RealVectorParameter {44 get { return (ILookupParameter<DoubleArray Data>)Parameters["RealVector"]; }43 public ILookupParameter<DoubleArray> RealVectorParameter { 44 get { return (ILookupParameter<DoubleArray>)Parameters["RealVector"]; } 45 45 } 46 public IValueLookupParameter<Int Data> LengthParameter {47 get { return (IValueLookupParameter<Int Data>)Parameters["Length"]; }46 public IValueLookupParameter<IntValue> LengthParameter { 47 get { return (IValueLookupParameter<IntValue>)Parameters["Length"]; } 48 48 } 49 public IValueLookupParameter<Double Data> MinimumParameter {50 get { return (IValueLookupParameter<Double Data>)Parameters["Minimum"]; }49 public IValueLookupParameter<DoubleValue> MinimumParameter { 50 get { return (IValueLookupParameter<DoubleValue>)Parameters["Minimum"]; } 51 51 } 52 public IValueLookupParameter<Double Data> MaximumParameter {53 get { return (IValueLookupParameter<Double Data>)Parameters["Maximum"]; }52 public IValueLookupParameter<DoubleValue> MaximumParameter { 53 get { return (IValueLookupParameter<DoubleValue>)Parameters["Maximum"]; } 54 54 } 55 55 … … 57 57 : base() { 58 58 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 59 Parameters.Add(new LookupParameter<DoubleArray Data>("RealVector", "The vector which should be manipulated."));60 Parameters.Add(new ValueLookupParameter<Int Data>("Length", "The length of the vector."));61 Parameters.Add(new ValueLookupParameter<Double Data>("Minimum", "The lower bound for each element in the vector."));62 Parameters.Add(new ValueLookupParameter<Double Data>("Maximum", "The upper bound for each element in the vector."));59 Parameters.Add(new LookupParameter<DoubleArray>("RealVector", "The vector which should be manipulated.")); 60 Parameters.Add(new ValueLookupParameter<IntValue>("Length", "The length of the vector.")); 61 Parameters.Add(new ValueLookupParameter<DoubleValue>("Minimum", "The lower bound for each element in the vector.")); 62 Parameters.Add(new ValueLookupParameter<DoubleValue>("Maximum", "The upper bound for each element in the vector.")); 63 63 } 64 64 … … 68 68 } 69 69 70 protected abstract DoubleArray Data Create(IRandom random, IntData length, DoubleData minimum, DoubleDatamaximum);70 protected abstract DoubleArray Create(IRandom random, IntValue length, DoubleValue minimum, DoubleValue maximum); 71 71 } 72 72 } -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/RealVectorCrossover.cs
r3034 r3048 41 41 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 42 42 } 43 public ILookupParameter<ItemArray<DoubleArray Data>> ParentsParameter {44 get { return (SubScopesLookupParameter<DoubleArray Data>)Parameters["Parents"]; }43 public ILookupParameter<ItemArray<DoubleArray>> ParentsParameter { 44 get { return (SubScopesLookupParameter<DoubleArray>)Parameters["Parents"]; } 45 45 } 46 public ILookupParameter<DoubleArray Data> ChildParameter {47 get { return (ILookupParameter<DoubleArray Data>)Parameters["Child"]; }46 public ILookupParameter<DoubleArray> ChildParameter { 47 get { return (ILookupParameter<DoubleArray>)Parameters["Child"]; } 48 48 } 49 49 … … 51 51 : base() { 52 52 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic crossover operators.")); 53 Parameters.Add(new SubScopesLookupParameter<DoubleArray Data>("Parents", "The parent vectors which should be crossed."));54 Parameters.Add(new LookupParameter<DoubleArray Data>("Child", "The child vector resulting from the crossover."));53 Parameters.Add(new SubScopesLookupParameter<DoubleArray>("Parents", "The parent vectors which should be crossed.")); 54 Parameters.Add(new LookupParameter<DoubleArray>("Child", "The child vector resulting from the crossover.")); 55 55 } 56 56 … … 60 60 } 61 61 62 protected abstract DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents);62 protected abstract DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents); 63 63 } 64 64 } -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/RealVectorManipulator.cs
r3034 r3048 41 41 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 42 42 } 43 public ILookupParameter<DoubleArray Data> RealVectorParameter {44 get { return (ILookupParameter<DoubleArray Data>)Parameters["RealVector"]; }43 public ILookupParameter<DoubleArray> RealVectorParameter { 44 get { return (ILookupParameter<DoubleArray>)Parameters["RealVector"]; } 45 45 } 46 46 … … 48 48 : base() { 49 49 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 50 Parameters.Add(new LookupParameter<DoubleArray Data>("RealVector", "The vector which should be manipulated."));50 Parameters.Add(new LookupParameter<DoubleArray>("RealVector", "The vector which should be manipulated.")); 51 51 } 52 52 … … 56 56 } 57 57 58 protected abstract void Manipulate(IRandom random, DoubleArray DatarealVector);58 protected abstract void Manipulate(IRandom random, DoubleArray realVector); 59 59 } 60 60 } -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/Auxiliary.cs
r2929 r3048 25 25 namespace HeuristicLab.Encodings.RealVector_33.Tests { 26 26 public static class Auxiliary { 27 public static bool RealVectorIsAlmostEqualByPosition(DoubleArray Data p1, DoubleArrayDatap2) {27 public static bool RealVectorIsAlmostEqualByPosition(DoubleArray p1, DoubleArray p2) { 28 28 bool equal = (p1.Length == p2.Length); 29 29 if (equal) { -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/BlendAlphaBetaCrossoverTest.cs
r2936 r3048 68 68 public void BlendAlphaBetaCrossoverCrossTest() { 69 69 BlendAlphaBetaCrossover_Accessor target = new BlendAlphaBetaCrossover_Accessor(new PrivateObject(typeof(BlendAlphaBetaCrossover))); 70 ItemArray<DoubleArray Data> parents;70 ItemArray<DoubleArray> parents; 71 71 TestRandom random = new TestRandom(); 72 72 bool exceptionFired; 73 73 // The following test checks if there is an exception when there are more than 2 parents 74 74 random.Reset(); 75 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(5), new DoubleArrayData(6), new DoubleArrayData(4) });75 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(5), new DoubleArray(6), new DoubleArray(4) }); 76 76 exceptionFired = false; 77 77 try { 78 DoubleArray Dataactual;78 DoubleArray actual; 79 79 actual = target.Cross(random, parents); 80 80 } catch (System.ArgumentException) { … … 84 84 // The following test checks if there is an exception when there are less than 2 parents 85 85 random.Reset(); 86 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(4) });86 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) }); 87 87 exceptionFired = false; 88 88 try { 89 DoubleArray Dataactual;89 DoubleArray actual; 90 90 actual = target.Cross(random, parents); 91 91 } catch (System.ArgumentException) { … … 101 101 public void BlendAlphaBetaCrossoverApplyTest() { 102 102 TestRandom random = new TestRandom(); 103 DoubleArray Dataparent1, parent2, expected, actual;104 Double Dataalpha;105 Double Databeta;103 DoubleArray parent1, parent2, expected, actual; 104 DoubleValue alpha; 105 DoubleValue beta; 106 106 bool exceptionFired; 107 107 // The following test is not based on published examples 108 108 random.Reset(); 109 109 random.DoubleNumbers = new double[] { 0.5, 0.5, 0.5, 0.5, 0.5 }; 110 alpha = new Double Data(0.5);111 beta = new Double Data(0.5);112 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });113 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });114 expected = new DoubleArray Data(new double[] { 0.3, 0.15, 0.3, 0.35, 0.45 });110 alpha = new DoubleValue(0.5); 111 beta = new DoubleValue(0.5); 112 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 113 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 114 expected = new DoubleArray(new double[] { 0.3, 0.15, 0.3, 0.35, 0.45 }); 115 115 actual = BlendAlphaBetaCrossover.Apply(random, parent1, parent2, alpha, beta); 116 116 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected)); … … 118 118 random.Reset(); 119 119 random.DoubleNumbers = new double[] { 0.25, 0.75, 0.25, 0.75, 0.25 }; 120 alpha = new Double Data(-0.25); // negative values for alpha are not allowed121 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });122 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });120 alpha = new DoubleValue(-0.25); // negative values for alpha are not allowed 121 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 122 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 123 123 exceptionFired = false; 124 124 try { … … 131 131 random.Reset(); 132 132 random.DoubleNumbers = new double[] { 0.25, 0.75, 0.25, 0.75, 0.25, .75 }; 133 alpha = new Double Data(0.25);134 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer135 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });133 alpha = new DoubleValue(0.25); 134 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 135 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 136 136 exceptionFired = false; 137 137 try { -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/BlendAlphaCrossoverTest.cs
r2929 r3048 68 68 public void BlendAlphaCrossoverCrossTest() { 69 69 BlendAlphaCrossover_Accessor target = new BlendAlphaCrossover_Accessor(new PrivateObject(typeof(BlendAlphaCrossover))); 70 ItemArray<DoubleArray Data> parents;70 ItemArray<DoubleArray> parents; 71 71 TestRandom random = new TestRandom(); 72 72 bool exceptionFired; 73 73 // The following test checks if there is an exception when there are more than 2 parents 74 74 random.Reset(); 75 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(5), new DoubleArrayData(6), new DoubleArrayData(4) });75 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(5), new DoubleArray(6), new DoubleArray(4) }); 76 76 exceptionFired = false; 77 77 try { 78 DoubleArray Dataactual;78 DoubleArray actual; 79 79 actual = target.Cross(random, parents); 80 80 } catch (System.ArgumentException) { … … 84 84 // The following test checks if there is an exception when there are less than 2 parents 85 85 random.Reset(); 86 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(4) });86 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) }); 87 87 exceptionFired = false; 88 88 try { 89 DoubleArray Dataactual;89 DoubleArray actual; 90 90 actual = target.Cross(random, parents); 91 91 } catch (System.ArgumentException) { … … 101 101 public void BlendAlphaCrossoverApplyTest() { 102 102 TestRandom random = new TestRandom(); 103 DoubleArray Dataparent1, parent2, expected, actual;104 Double Dataalpha;103 DoubleArray parent1, parent2, expected, actual; 104 DoubleValue alpha; 105 105 bool exceptionFired; 106 106 // The following test is not based on published examples 107 107 random.Reset(); 108 108 random.DoubleNumbers = new double[] { 0.5, 0.5, 0.5, 0.5, 0.5 }; 109 alpha = new Double Data(0.5);110 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });111 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });112 expected = new DoubleArray Data(new double[] { 0.3, 0.15, 0.3, 0.35, 0.45 });109 alpha = new DoubleValue(0.5); 110 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 111 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 112 expected = new DoubleArray(new double[] { 0.3, 0.15, 0.3, 0.35, 0.45 }); 113 113 actual = BlendAlphaCrossover.Apply(random, parent1, parent2, alpha); 114 114 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected)); … … 116 116 random.Reset(); 117 117 random.DoubleNumbers = new double[] { 0.25, 0.75, 0.25, 0.75, 0.25 }; 118 alpha = new Double Data(0.25);119 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });120 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });121 expected = new DoubleArray Data(new double[] { 0.225, 0.1875, 0.3, 0.4625, 0.1875 });118 alpha = new DoubleValue(0.25); 119 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 120 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 121 expected = new DoubleArray(new double[] { 0.225, 0.1875, 0.3, 0.4625, 0.1875 }); 122 122 actual = BlendAlphaCrossover.Apply(random, parent1, parent2, alpha); 123 123 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected)); … … 125 125 random.Reset(); 126 126 random.DoubleNumbers = new double[] { 0.25, 0.75, 0.25, 0.75, 0.25 }; 127 alpha = new Double Data(-0.25); // negative values for alpha are not allowed128 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });129 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });130 expected = new DoubleArray Data(new double[] { 0.225, 0.1875, 0.3, 0.4625, 0.1875 });127 alpha = new DoubleValue(-0.25); // negative values for alpha are not allowed 128 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 129 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 130 expected = new DoubleArray(new double[] { 0.225, 0.1875, 0.3, 0.4625, 0.1875 }); 131 131 exceptionFired = false; 132 132 try { … … 139 139 random.Reset(); 140 140 random.DoubleNumbers = new double[] { 0.25, 0.75, 0.25, 0.75, 0.25, .75 }; 141 alpha = new Double Data(0.25);142 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer143 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });144 expected = new DoubleArray Data(new double[] { 0.225, 0.1875, 0.3, 0.4625, 0.1875 });141 alpha = new DoubleValue(0.25); 142 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 143 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 144 expected = new DoubleArray(new double[] { 0.225, 0.1875, 0.3, 0.4625, 0.1875 }); 145 145 exceptionFired = false; 146 146 try { -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/DiscreteCrossoverTest.cs
r2936 r3048 68 68 public void DiscreteCrossoverCrossTest() { 69 69 DiscreteCrossover_Accessor target = new DiscreteCrossover_Accessor(new PrivateObject(typeof(DiscreteCrossover))); 70 ItemArray<DoubleArray Data> parents;70 ItemArray<DoubleArray> parents; 71 71 TestRandom random = new TestRandom(); 72 72 bool exceptionFired; 73 73 // The following test checks if there is an exception when there are less than 2 parents 74 74 random.Reset(); 75 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(4) });75 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) }); 76 76 exceptionFired = false; 77 77 try { 78 DoubleArray Dataactual;78 DoubleArray actual; 79 79 actual = target.Cross(random, parents); 80 80 } catch (System.ArgumentException) { … … 90 90 public void DiscreteCrossoverApplyTest() { 91 91 TestRandom random = new TestRandom(); 92 DoubleArray Dataparent1, parent2, expected, actual;93 ItemArray<DoubleArray Data> parents;92 DoubleArray parent1, parent2, expected, actual; 93 ItemArray<DoubleArray> parents; 94 94 bool exceptionFired; 95 95 // The following test is not based on published examples 96 96 random.Reset(); 97 97 random.IntNumbers = new int[] { 0, 0, 1, 0, 1 }; 98 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });99 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });100 parents = new ItemArray<DoubleArray Data>( new DoubleArrayData[] { parent1, parent2 } );101 expected = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.8 });98 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 99 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 100 parents = new ItemArray<DoubleArray>( new DoubleArray[] { parent1, parent2 } ); 101 expected = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.8 }); 102 102 actual = DiscreteCrossover.Apply(random, parents); 103 103 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected)); … … 105 105 random.Reset(); 106 106 random.IntNumbers = new int[] { 0, 0, 1, 0, 1, 0 }; 107 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer108 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });109 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { parent1, parent2 });107 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 108 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 109 parents = new ItemArray<DoubleArray>(new DoubleArray[] { parent1, parent2 }); 110 110 exceptionFired = false; 111 111 try { -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/HeuristicCrossoverTest.cs
r2936 r3048 68 68 public void HeuristicCrossoverCrossTest() { 69 69 HeuristicCrossover_Accessor target = new HeuristicCrossover_Accessor(new PrivateObject(typeof(HeuristicCrossover))); 70 ItemArray<DoubleArray Data> parents;70 ItemArray<DoubleArray> parents; 71 71 TestRandom random = new TestRandom(); 72 72 bool exceptionFired; 73 73 // The following test checks if there is an exception when there are more than 2 parents 74 74 random.Reset(); 75 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(5), new DoubleArrayData(6), new DoubleArrayData(4) });75 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(5), new DoubleArray(6), new DoubleArray(4) }); 76 76 exceptionFired = false; 77 77 try { 78 DoubleArray Dataactual;78 DoubleArray actual; 79 79 actual = target.Cross(random, parents); 80 80 } … … 85 85 // The following test checks if there is an exception when there are less than 2 parents 86 86 random.Reset(); 87 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(4) });87 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) }); 88 88 exceptionFired = false; 89 89 try { 90 DoubleArray Dataactual;90 DoubleArray actual; 91 91 actual = target.Cross(random, parents); 92 92 } catch (System.ArgumentException) { … … 102 102 public void HeuristicCrossoverApplyTest() { 103 103 TestRandom random = new TestRandom(); 104 DoubleArray Dataparent1, parent2, expected, actual;104 DoubleArray parent1, parent2, expected, actual; 105 105 bool exceptionFired; 106 106 // The following test is not based on published examples 107 107 random.Reset(); 108 108 random.DoubleNumbers = new double[] { 0.3 }; 109 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });110 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });111 expected = new DoubleArray Data(new double[] { 0.14, 0.23, 0.3, 0.59, -0.11 });109 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 110 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 111 expected = new DoubleArray(new double[] { 0.14, 0.23, 0.3, 0.59, -0.11 }); 112 112 actual = HeuristicCrossover.Apply(random, parent1, parent2); 113 113 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected)); … … 115 115 random.Reset(); 116 116 random.DoubleNumbers = new double[] { 0.3 }; 117 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer118 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });117 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 118 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 119 119 exceptionFired = false; 120 120 try { -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/LocalCrossoverTest.cs
r2936 r3048 68 68 public void LocalCrossoverCrossTest() { 69 69 LocalCrossover_Accessor target = new LocalCrossover_Accessor(new PrivateObject(typeof(LocalCrossover))); 70 ItemArray<DoubleArray Data> parents;70 ItemArray<DoubleArray> parents; 71 71 TestRandom random = new TestRandom(); 72 72 bool exceptionFired; 73 73 // The following test checks if there is an exception when there are more than 2 parents 74 74 random.Reset(); 75 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(5), new DoubleArrayData(6), new DoubleArrayData(4) });75 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(5), new DoubleArray(6), new DoubleArray(4) }); 76 76 exceptionFired = false; 77 77 try { 78 DoubleArray Dataactual;78 DoubleArray actual; 79 79 actual = target.Cross(random, parents); 80 80 } … … 85 85 // The following test checks if there is an exception when there are less than 2 parents 86 86 random.Reset(); 87 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(4) });87 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) }); 88 88 exceptionFired = false; 89 89 try { 90 DoubleArray Dataactual;90 DoubleArray actual; 91 91 actual = target.Cross(random, parents); 92 92 } catch (System.ArgumentException) { … … 102 102 public void LocalCrossoverApplyTest() { 103 103 TestRandom random = new TestRandom(); 104 DoubleArray Dataparent1, parent2, expected, actual;104 DoubleArray parent1, parent2, expected, actual; 105 105 bool exceptionFired; 106 106 // The following test is not based on published examples 107 107 random.Reset(); 108 108 random.DoubleNumbers = new double[] { 0.3, 0.1, 0.2, 0.4, 0.23 }; 109 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });110 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });111 expected = new DoubleArray Data(new double[] { 0.34, 0.11, 0.3, 0.32, 0.639 });109 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 110 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 111 expected = new DoubleArray(new double[] { 0.34, 0.11, 0.3, 0.32, 0.639 }); 112 112 actual = LocalCrossover.Apply(random, parent1, parent2); 113 113 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected)); … … 115 115 random.Reset(); 116 116 random.DoubleNumbers = new double[] { 0.3, 0.1, 0.2, 0.4, 0.23, 0.5}; 117 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer118 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });117 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 118 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 119 119 exceptionFired = false; 120 120 try { -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/MichalewiczNonUniformAllPositionsManipulatorTest.cs
r2936 r3048 85 85 public void MichalewiczNonUniformAllPositionsManipulatorApplyTest() { 86 86 TestRandom random = new TestRandom(); 87 DoubleArray Dataparent, expected;88 Double Datamin, max, generationsDependency;89 Int DatacurrentGeneration, maximumGenerations;87 DoubleArray parent, expected; 88 DoubleValue min, max, generationsDependency; 89 IntValue currentGeneration, maximumGenerations; 90 90 bool exceptionFired; 91 91 // The following test is not based on published examples 92 92 random.Reset(); 93 93 random.DoubleNumbers = new double[] { 0.2, 0.5, 0.7, 0.8, 0.9, 0.5, 0.2, 0.5, 0.7, 0.8 }; 94 parent = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });95 expected = new DoubleArray Data(new double[] { 0.45, 0.22, 0.3, 0.6, 0.14 });96 min = new Double Data(0.3);97 max = new Double Data(0.7);98 generationsDependency = new Double Data(0.1);99 currentGeneration = new Int Data(1);100 maximumGenerations = new Int Data(4);94 parent = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 95 expected = new DoubleArray(new double[] { 0.45, 0.22, 0.3, 0.6, 0.14 }); 96 min = new DoubleValue(0.3); 97 max = new DoubleValue(0.7); 98 generationsDependency = new DoubleValue(0.1); 99 currentGeneration = new IntValue(1); 100 maximumGenerations = new IntValue(4); 101 101 MichalewiczNonUniformAllPositionsManipulator.Apply(random, parent, min, max, currentGeneration, maximumGenerations, generationsDependency); 102 102 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(expected, parent)); … … 105 105 random.Reset(); 106 106 random.DoubleNumbers = new double[] { 0.2, 0.5, 0.7, 0.8, 0.9, 0.5, 0.2, 0.5, 0.7, 0.8 }; 107 parent = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });108 min = new Double Data(0.3);109 max = new Double Data(0.7);110 generationsDependency = new Double Data(0.1);111 currentGeneration = new Int Data(5); //current generation > max generation112 maximumGenerations = new Int Data(4);107 parent = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 108 min = new DoubleValue(0.3); 109 max = new DoubleValue(0.7); 110 generationsDependency = new DoubleValue(0.1); 111 currentGeneration = new IntValue(5); //current generation > max generation 112 maximumGenerations = new IntValue(4); 113 113 try { 114 114 MichalewiczNonUniformAllPositionsManipulator.Apply(random, parent, min, max, currentGeneration, maximumGenerations, generationsDependency); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/MichalewiczNonUniformOnePositionManipulatorTest.cs
r2936 r3048 85 85 public void MichalewiczNonUniformOnePositionManipulatorApplyTest() { 86 86 TestRandom random = new TestRandom(); 87 DoubleArray Dataparent, expected;88 Double Datamin, max, generationsDependency;89 Int DatacurrentGeneration, maximumGenerations;87 DoubleArray parent, expected; 88 DoubleValue min, max, generationsDependency; 89 IntValue currentGeneration, maximumGenerations; 90 90 bool exceptionFired; 91 91 // The following test is not based on published examples … … 93 93 random.IntNumbers = new int[] { 3 }; 94 94 random.DoubleNumbers = new double[] { 0.2, 0.7 }; 95 parent = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });96 expected = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.34, 0.1 });97 min = new Double Data(0.3);98 max = new Double Data(0.7);99 generationsDependency = new Double Data(0.1);100 currentGeneration = new Int Data(1);101 maximumGenerations = new Int Data(4);95 parent = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 96 expected = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.34, 0.1 }); 97 min = new DoubleValue(0.3); 98 max = new DoubleValue(0.7); 99 generationsDependency = new DoubleValue(0.1); 100 currentGeneration = new IntValue(1); 101 maximumGenerations = new IntValue(4); 102 102 MichalewiczNonUniformOnePositionManipulator.Apply(random, parent, min, max, currentGeneration, maximumGenerations, generationsDependency); 103 103 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(expected, parent)); … … 107 107 random.IntNumbers = new int[] { 3 }; 108 108 random.DoubleNumbers = new double[] { 0.2, 0.7 }; 109 parent = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });110 min = new Double Data(0.3);111 max = new Double Data(0.7);112 generationsDependency = new Double Data(0.1);113 currentGeneration = new Int Data(5); //current generation > max generation114 maximumGenerations = new Int Data(4);109 parent = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 110 min = new DoubleValue(0.3); 111 max = new DoubleValue(0.7); 112 generationsDependency = new DoubleValue(0.1); 113 currentGeneration = new IntValue(5); //current generation > max generation 114 maximumGenerations = new IntValue(4); 115 115 try { 116 116 MichalewiczNonUniformOnePositionManipulator.Apply(random, parent, min, max, currentGeneration, maximumGenerations, generationsDependency); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/PolynomialAllPositionManipulatorTest.cs
r2936 r3048 85 85 public void PolynomialAllPositionManipulatorApplyTest() { 86 86 TestRandom random = new TestRandom(); 87 DoubleArray Dataparent, expected;88 Double Datacontiguity, maxManipulation;87 DoubleArray parent, expected; 88 DoubleValue contiguity, maxManipulation; 89 89 bool exceptionFired; 90 90 // The following test is not based on published examples 91 91 random.Reset(); 92 92 random.DoubleNumbers = new double[] { 0.2, 0.7, 0.8, 0.01, 0.1 }; 93 parent = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });94 expected = new DoubleArray Data(new double[] { 0.120213215256006, 0.336631954950876, 0.474551336679454, 0.322759240811056, -0.0182075293954083 });95 contiguity = new Double Data(0.8);96 maxManipulation = new Double Data(0.2);93 parent = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 94 expected = new DoubleArray(new double[] { 0.120213215256006, 0.336631954950876, 0.474551336679454, 0.322759240811056, -0.0182075293954083 }); 95 contiguity = new DoubleValue(0.8); 96 maxManipulation = new DoubleValue(0.2); 97 97 PolynomialAllPositionManipulator.Apply(random, parent, contiguity, maxManipulation); 98 98 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(expected, parent)); … … 101 101 random.Reset(); 102 102 random.DoubleNumbers = new double[] { 0.2, 0.7, 0.8, 0.01, 0.1 }; 103 parent = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });104 contiguity = new Double Data(-1); //Contiguity value < 0105 maxManipulation = new Double Data(0.2);103 parent = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 104 contiguity = new DoubleValue(-1); //Contiguity value < 0 105 maxManipulation = new DoubleValue(0.2); 106 106 try { 107 107 PolynomialAllPositionManipulator.Apply(random, parent, contiguity, maxManipulation); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/PolynomialOnePositionManipulatorTest.cs
r2936 r3048 85 85 public void PolynomialOnePositionManipulatorApplyTest() { 86 86 TestRandom random = new TestRandom(); 87 DoubleArray Dataparent, expected;88 Double Datacontiguity, maxManipulation;87 DoubleArray parent, expected; 88 DoubleValue contiguity, maxManipulation; 89 89 bool exceptionFired; 90 90 // The following test is not based on published examples … … 92 92 random.IntNumbers = new int[] { 3 }; 93 93 random.DoubleNumbers = new double[] { 0.2 }; 94 parent = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });95 expected = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.1261980542102, 0.1 });96 contiguity = new Double Data(0.2);97 maxManipulation = new Double Data(0.7);94 parent = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 95 expected = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.1261980542102, 0.1 }); 96 contiguity = new DoubleValue(0.2); 97 maxManipulation = new DoubleValue(0.7); 98 98 PolynomialOnePositionManipulator.Apply(random, parent, contiguity, maxManipulation); 99 99 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(expected, parent)); … … 103 103 random.IntNumbers = new int[] { 3 }; 104 104 random.DoubleNumbers = new double[] { 0.2 }; 105 parent = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });106 contiguity = new Double Data(-1); //Contiguity value < 0107 maxManipulation = new Double Data(0.2);105 parent = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 106 contiguity = new DoubleValue(-1); //Contiguity value < 0 107 maxManipulation = new DoubleValue(0.2); 108 108 try { 109 109 PolynomialOnePositionManipulator.Apply(random, parent, contiguity, maxManipulation); -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/RandomConvexCrossoverTest.cs
r2936 r3048 68 68 public void RandomConvexCrossoverCrossTest() { 69 69 RandomConvexCrossover_Accessor target = new RandomConvexCrossover_Accessor(new PrivateObject(typeof(RandomConvexCrossover))); 70 ItemArray<DoubleArray Data> parents;70 ItemArray<DoubleArray> parents; 71 71 TestRandom random = new TestRandom(); 72 72 bool exceptionFired; 73 73 // The following test checks if there is an exception when there are more than 2 parents 74 74 random.Reset(); 75 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(5), new DoubleArrayData(6), new DoubleArrayData(4) });75 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(5), new DoubleArray(6), new DoubleArray(4) }); 76 76 exceptionFired = false; 77 77 try { 78 DoubleArray Dataactual;78 DoubleArray actual; 79 79 actual = target.Cross(random, parents); 80 80 } … … 85 85 // The following test checks if there is an exception when there are less than 2 parents 86 86 random.Reset(); 87 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(4) });87 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) }); 88 88 exceptionFired = false; 89 89 try { 90 DoubleArray Dataactual;90 DoubleArray actual; 91 91 actual = target.Cross(random, parents); 92 92 } catch (System.ArgumentException) { … … 102 102 public void RandomConvexCrossoverApplyTest() { 103 103 TestRandom random = new TestRandom(); 104 DoubleArray Dataparent1, parent2, expected, actual;104 DoubleArray parent1, parent2, expected, actual; 105 105 bool exceptionFired; 106 106 // The following test is not based on published examples 107 107 random.Reset(); 108 108 random.DoubleNumbers = new double[] { 0.3 }; 109 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });110 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });111 expected = new DoubleArray Data(new double[] { 0.34, 0.13, 0.3, 0.29, 0.59 });109 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 110 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 111 expected = new DoubleArray(new double[] { 0.34, 0.13, 0.3, 0.29, 0.59 }); 112 112 actual = RandomConvexCrossover.Apply(random, parent1, parent2); 113 113 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected)); … … 115 115 random.Reset(); 116 116 random.DoubleNumbers = new double[] { 0.3 }; 117 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer118 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });117 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 118 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 119 119 exceptionFired = false; 120 120 try { -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/SimulatedBinaryCrossoverTest.cs
r2936 r3048 68 68 public void SimulatedBinaryCrossoverCrossTest() { 69 69 SimulatedBinaryCrossover_Accessor target = new SimulatedBinaryCrossover_Accessor(new PrivateObject(typeof(SimulatedBinaryCrossover))); 70 ItemArray<DoubleArray Data> parents;70 ItemArray<DoubleArray> parents; 71 71 TestRandom random = new TestRandom(); 72 72 bool exceptionFired; 73 73 // The following test checks if there is an exception when there are more than 2 parents 74 74 random.Reset(); 75 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(5), new DoubleArrayData(6), new DoubleArrayData(4) });75 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(5), new DoubleArray(6), new DoubleArray(4) }); 76 76 exceptionFired = false; 77 77 try { 78 DoubleArray Dataactual;78 DoubleArray actual; 79 79 actual = target.Cross(random, parents); 80 80 } … … 85 85 // The following test checks if there is an exception when there are less than 2 parents 86 86 random.Reset(); 87 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(4) });87 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) }); 88 88 exceptionFired = false; 89 89 try { 90 DoubleArray Dataactual;90 DoubleArray actual; 91 91 actual = target.Cross(random, parents); 92 92 } catch (System.ArgumentException) { … … 102 102 public void SimulatedBinaryCrossoverApplyTest() { 103 103 TestRandom random = new TestRandom(); 104 DoubleArray Dataparent1, parent2, expected, actual;105 Double Datacontiguity;104 DoubleArray parent1, parent2, expected, actual; 105 DoubleValue contiguity; 106 106 bool exceptionFired; 107 107 // The following test is not based on published examples 108 108 random.Reset(); 109 109 random.DoubleNumbers = new double[] { 0.3, 0.9, 0.7, 0.2, 0.8, 0.1, 0.2, 0.3, 0.4, 0.8, 0.7 }; 110 contiguity = new Double Data(0.3);111 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });112 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });113 expected = new DoubleArray Data(new double[] { 1.11032829834638, -0.0145477755417797, 0.3, 0.5, 0.1 });110 contiguity = new DoubleValue(0.3); 111 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 112 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 113 expected = new DoubleArray(new double[] { 1.11032829834638, -0.0145477755417797, 0.3, 0.5, 0.1 }); 114 114 actual = SimulatedBinaryCrossover.Apply(random, parent1, parent2, contiguity); 115 115 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected)); … … 117 117 random.Reset(); 118 118 random.DoubleNumbers = new double[] { 0.3, 0.9, 0.7, 0.2, 0.8, 0.1, 0.2, 0.3, 0.4, 0.8, 0.7 }; 119 contiguity = new Double Data(0.3);120 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer121 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });119 contiguity = new DoubleValue(0.3); 120 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 121 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 122 122 exceptionFired = false; 123 123 try { … … 130 130 random.Reset(); 131 131 random.DoubleNumbers = new double[] { 0.3, 0.9, 0.7, 0.2, 0.8, 0.1, 0.2, 0.3, 0.4, 0.8, 0.7 }; 132 contiguity = new Double Data(-0.3); // contiguity < 0133 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1});134 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });132 contiguity = new DoubleValue(-0.3); // contiguity < 0 133 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1}); 134 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 135 135 exceptionFired = false; 136 136 try { -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/SinglePointCrossoverTest.cs
r2936 r3048 68 68 public void SinglePointCrossoverCrossTest() { 69 69 SinglePointCrossover_Accessor target = new SinglePointCrossover_Accessor(new PrivateObject(typeof(SinglePointCrossover))); 70 ItemArray<DoubleArray Data> parents;70 ItemArray<DoubleArray> parents; 71 71 TestRandom random = new TestRandom(); 72 72 bool exceptionFired; 73 73 // The following test checks if there is an exception when there are more than 2 parents 74 74 random.Reset(); 75 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(5), new DoubleArrayData(6), new DoubleArrayData(4) });75 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(5), new DoubleArray(6), new DoubleArray(4) }); 76 76 exceptionFired = false; 77 77 try { 78 DoubleArray Dataactual;78 DoubleArray actual; 79 79 actual = target.Cross(random, parents); 80 80 } … … 85 85 // The following test checks if there is an exception when there are less than 2 parents 86 86 random.Reset(); 87 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(4) });87 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) }); 88 88 exceptionFired = false; 89 89 try { 90 DoubleArray Dataactual;90 DoubleArray actual; 91 91 actual = target.Cross(random, parents); 92 92 } catch (System.ArgumentException) { … … 102 102 public void SinglePointCrossoverApplyTest() { 103 103 TestRandom random = new TestRandom(); 104 DoubleArray Dataparent1, parent2, expected, actual;104 DoubleArray parent1, parent2, expected, actual; 105 105 bool exceptionFired; 106 106 // The following test is not based on published examples 107 107 random.Reset(); 108 108 random.IntNumbers = new int[] { 3 }; 109 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });110 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });111 expected = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.2, 0.8 });109 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 110 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 111 expected = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.2, 0.8 }); 112 112 actual = SinglePointCrossover.Apply(random, parent1, parent2); 113 113 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected)); … … 115 115 random.Reset(); 116 116 random.IntNumbers = new int[] { 2 }; 117 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer118 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });117 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 118 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 119 119 exceptionFired = false; 120 120 try { -
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/UniformOnePositionManipulatorTest.cs
r2936 r3048 85 85 public void UniformOnePositionManipulatorApplyTest() { 86 86 TestRandom random = new TestRandom(); 87 DoubleArray Dataparent, expected;88 Double Datamin, max;87 DoubleArray parent, expected; 88 DoubleValue min, max; 89 89 // The following test is not based on published examples 90 90 random.Reset(); 91 91 random.IntNumbers = new int[] { 3 }; 92 92 random.DoubleNumbers = new double[] { 0.2 }; 93 parent = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });94 expected = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.3, 0.1 });95 min = new Double Data(0.2);96 max = new Double Data(0.7);93 parent = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 94 expected = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.3, 0.1 }); 95 min = new DoubleValue(0.2); 96 max = new DoubleValue(0.7); 97 97 UniformOnePositionManipulator.Apply(random, parent, min, max); 98 98 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(expected, parent));
Note: See TracChangeset
for help on using the changeset viewer.