Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/16/10 10:46:59 (14 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/BlendAlphaBetaCrossoverTest.cs

    r3053 r3060  
    6868    public void BlendAlphaBetaCrossoverCrossTest() {
    6969      BlendAlphaBetaCrossover_Accessor target = new BlendAlphaBetaCrossover_Accessor(new PrivateObject(typeof(BlendAlphaBetaCrossover)));
    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 more than 2 parents
    7474      random.Reset();
    75       parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(5), new DoubleArray(6), new DoubleArray(4) });
     75      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(5), new RealVector(6), new RealVector(4) });
    7676      exceptionFired = false;
    7777      try {
    78         DoubleArray actual;
     78        RealVector actual;
    7979        actual = target.Cross(random, parents);
    8080      } catch (System.ArgumentException) {
     
    8484      // The following test checks if there is an exception when there are less than 2 parents
    8585      random.Reset();
    86       parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) });
     86      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
    8787      exceptionFired = false;
    8888      try {
    89         DoubleArray actual;
     89        RealVector actual;
    9090        actual = target.Cross(random, parents);
    9191      } catch (System.ArgumentException) {
     
    101101    public void BlendAlphaBetaCrossoverApplyTest() {
    102102      TestRandom random = new TestRandom();
    103       DoubleArray parent1, parent2, expected, actual;
     103      RealVector parent1, parent2, expected, actual;
    104104      DoubleValue alpha;
    105105      DoubleValue beta;
     
    110110      alpha = new DoubleValue(0.5);
    111111      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 });
     112      parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
     113      parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
     114      expected = new RealVector(new double[] { 0.3, 0.15, 0.3, 0.35, 0.45 });
    115115      actual = BlendAlphaBetaCrossover.Apply(random, parent1, parent2, alpha, beta);
    116       Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected));
     116      Assert.IsTrue(Auxiliary.DoubleArrayIsAlmostEqualByPosition(actual, expected));
    117117      // The following test is not based on published examples
    118118      random.Reset();
    119119      random.DoubleNumbers = new double[] { 0.25, 0.75, 0.25, 0.75, 0.25 };
    120120      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 });
     121      parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
     122      parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
    123123      exceptionFired = false;
    124124      try {
     
    132132      random.DoubleNumbers = new double[] { 0.25, 0.75, 0.25, 0.75, 0.25, .75 };
    133133      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 });
     134      parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer
     135      parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
    136136      exceptionFired = false;
    137137      try {
Note: See TracChangeset for help on using the changeset viewer.