Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/06/10 16:41:51 (14 years ago)
Author:
abeham
Message:

#890

  • changed SinglePointCrossover to work with vectors of length 2
  • updated unit tests
File:
1 edited

Legend:

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

    r3376 r3675  
    9595      }
    9696      Assert.IsTrue(exceptionFired);
     97      // The following test checks if there is an exception when the vector has just one dimension
     98      random.Reset();
     99      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(1) });
     100      exceptionFired = false;
     101      try {
     102        RealVector actual;
     103        actual = target.Cross(random, parents);
     104      } catch (System.ArgumentException) {
     105        exceptionFired = true;
     106      }
     107      Assert.IsTrue(exceptionFired);
    97108    }
    98109
     
    125136      }
    126137      Assert.IsTrue(exceptionFired);
     138      // The following test is not based on published examples
     139      random.Reset();
     140      random.IntNumbers = new int[] { 5 }; // should not have an effect
     141      parent1 = new RealVector(new double[] { 0.2, 0.4 });
     142      parent2 = new RealVector(new double[] { 0.6, 0.1 });
     143      expected = new RealVector(new double[] { 0.2, 0.1 });
     144      actual = SinglePointCrossover.Apply(random, parent1, parent2);
     145      Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected));
     146      // The following test is not based on published examples
    127147    }
    128148
Note: See TracChangeset for help on using the changeset viewer.