Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/16/10 10:46:59 (15 years ago)
Author:
svonolfe
Message:

Updated the RealVector project to use the new solution encodings (#909)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Tests/DiscreteCrossoverTest.cs

    r3053 r3060  
    6868    public void DiscreteCrossoverCrossTest() {
    6969      DiscreteCrossover_Accessor target = new DiscreteCrossover_Accessor(new PrivateObject(typeof(DiscreteCrossover)));
    70       ItemArray<DoubleArray> parents;
     70      ItemArray<RealVector> parents;
    7171      TestRandom random = new TestRandom();
    7272      bool exceptionFired;
    7373      // The following test checks if there is an exception when there are less than 2 parents
    7474      random.Reset();
    75       parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) });
     75      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
    7676      exceptionFired = false;
    7777      try {
    78         DoubleArray actual;
     78        RealVector actual;
    7979        actual = target.Cross(random, parents);
    8080      } catch (System.ArgumentException) {
     
    9090    public void DiscreteCrossoverApplyTest() {
    9191      TestRandom random = new TestRandom();
    92       DoubleArray parent1, parent2, expected, actual;
    93       ItemArray<DoubleArray> parents;
     92      RealVector parent1, parent2, expected, actual;
     93      ItemArray<RealVector> parents;
    9494      bool exceptionFired;
    9595      // The following test is not based on published examples
    9696      random.Reset();
    9797      random.IntNumbers = new int[] { 0, 0, 1, 0, 1 };
    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 });
     98      parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
     99      parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
     100      parents = new ItemArray<RealVector>( new RealVector[] { parent1, parent2 } );
     101      expected = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.8 });
    102102      actual = DiscreteCrossover.Apply(random, parents);
    103       Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected));
     103      Assert.IsTrue(Auxiliary.DoubleArrayIsAlmostEqualByPosition(actual, expected));
    104104      // The following test is not based on published examples
    105105      random.Reset();
    106106      random.IntNumbers = new int[] { 0, 0, 1, 0, 1, 0 };
    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 });
     107      parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer
     108      parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
     109      parents = new ItemArray<RealVector>(new RealVector[] { parent1, parent2 });
    110110      exceptionFired = false;
    111111      try {
Note: See TracChangeset for help on using the changeset viewer.