Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.RealVector/CompleteAverageCrossover.cs @ 73

Last change on this file since 73 was 73, checked in by swagner, 17 years ago

Worked on ticket #15

  • adapted interfaces of static Apply methods
  • added missing variable info Maximization in HeuristicCrossover
  • simplified code
File size: 832 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using HeuristicLab.Core;
5using HeuristicLab.Data;
6
7namespace HeuristicLab.RealVector {
8  class CompleteAverageCrossover : RealVectorCrossoverBase {
9    public override string Description {
10      get { return "Complete average (complete continuous) crossover for real vectors."; }
11    }
12
13    public static double[] Apply(IRandom random, double[] parent1, double[] parent2) {
14      int length = parent1.Length;
15      double[] result = new double[length];
16
17      for (int i = 0; i < length; i++)
18        result[i] = (parent1[i] + parent2[i]) / 2;
19      return result;
20    }
21
22    protected override double[] Cross(IScope scope, IRandom random, double[] parent1, double[] parent2) {
23      return Apply(random, parent1, parent2);
24    }
25  }
26}
Note: See TracBrowser for help on using the repository browser.