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/SimulatedBinaryCrossoverTest.cs

    r3053 r3060  
    6868    public void SimulatedBinaryCrossoverCrossTest() {
    6969      SimulatedBinaryCrossover_Accessor target = new SimulatedBinaryCrossover_Accessor(new PrivateObject(typeof(SimulatedBinaryCrossover)));
    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      }
     
    8585      // The following test checks if there is an exception when there are less than 2 parents
    8686      random.Reset();
    87       parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) });
     87      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
    8888      exceptionFired = false;
    8989      try {
    90         DoubleArray actual;
     90        RealVector actual;
    9191        actual = target.Cross(random, parents);
    9292      } catch (System.ArgumentException) {
     
    102102    public void SimulatedBinaryCrossoverApplyTest() {
    103103      TestRandom random = new TestRandom();
    104       DoubleArray parent1, parent2, expected, actual;
     104      RealVector parent1, parent2, expected, actual;
    105105      DoubleValue contiguity;
    106106      bool exceptionFired;
     
    109109      random.DoubleNumbers = new double[] { 0.3, 0.9, 0.7, 0.2, 0.8, 0.1, 0.2, 0.3, 0.4, 0.8, 0.7 };
    110110      contiguity = new DoubleValue(0.3);
    111       parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
    112       parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
    113       expected = new DoubleArray(new double[] { 1.11032829834638, -0.0145477755417797, 0.3, 0.5, 0.1 });
     111      parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
     112      parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
     113      expected = new RealVector(new double[] { 1.11032829834638, -0.0145477755417797, 0.3, 0.5, 0.1 });
    114114      actual = SimulatedBinaryCrossover.Apply(random, parent1, parent2, contiguity);
    115       Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected));
     115      Assert.IsTrue(Auxiliary.DoubleArrayIsAlmostEqualByPosition(actual, expected));
    116116      // The following test is not based on published examples
    117117      random.Reset();
    118118      random.DoubleNumbers = new double[] { 0.3, 0.9, 0.7, 0.2, 0.8, 0.1, 0.2, 0.3, 0.4, 0.8, 0.7 };
    119119      contiguity = new DoubleValue(0.3);
    120       parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer
    121       parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
     120      parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer
     121      parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
    122122      exceptionFired = false;
    123123      try {
     
    131131      random.DoubleNumbers = new double[] { 0.3, 0.9, 0.7, 0.2, 0.8, 0.1, 0.2, 0.3, 0.4, 0.8, 0.7 };
    132132      contiguity = new DoubleValue(-0.3);  //  contiguity < 0
    133       parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1});
    134       parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
     133      parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1});
     134      parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });
    135135      exceptionFired = false;
    136136      try {
Note: See TracChangeset for help on using the changeset viewer.