Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/18/08 00:40:57 (16 years ago)
Author:
swagner
Message:

Worked on ticket #15

  • adapted interfaces of static Apply methods
  • added missing variable info Maximization in HeuristicCrossover
  • simplified code
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.RealVector/RandomConvexCrossover.cs

    r70 r73  
    1111    }
    1212
    13     public static double[] Apply(IScope scope, IRandom random, double[] parent1, double[] parent2) {
    14       double factor;
     13    public static double[] Apply(IRandom random, double[] parent1, double[] parent2) {
    1514      int length = parent1.Length;
    1615      double[] result = new double[length];
    17       double min = scope.GetVariableValue<DoubleData>("Minimum", true).Data;
    18       double max = scope.GetVariableValue<DoubleData>("Maximum", true).Data;
     16      double factor = random.NextDouble();
    1917
    20       factor = random.NextDouble();
    21 
    22       for (int i = 0; i < length; i++) {
     18      for (int i = 0; i < length; i++)
    2319        result[i] = (factor * parent1[i]) + ((1 - factor) * parent2[i]);
    24 
    25         // check borders
    26         if (result[i] < min) { result[i] = min; }
    27         if (result[i] > max) { result[i] = max; }
    28       }
    29 
    3020      return result;
    3121    }
    3222
    3323    protected override double[] Cross(IScope scope, IRandom random, double[] parent1, double[] parent2) {
    34       return Apply(scope, random, parent1, parent2);
     24      return Apply(random, parent1, parent2);
    3525    }
    3626  }
Note: See TracChangeset for help on using the changeset viewer.