Changeset 3048 for trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/UniformSomePositionsArithmeticCrossover.cs
- Timestamp:
- 03/15/10 23:49:54 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.");
Note: See TracChangeset
for help on using the changeset viewer.