Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/10 15:59:37 (15 years ago)
Author:
abeham
Message:

Updated RealVector encoding to use a double matrix as bounds #929

Location:
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Tests
Files:
3 edited

Legend:

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

    r3061 r3123  
    8686      TestRandom random = new TestRandom();
    8787      RealVector parent, expected;
    88       DoubleValue min, max, generationsDependency;
     88      DoubleValue generationsDependency;
     89      DoubleMatrix bounds;
    8990      IntValue currentGeneration, maximumGenerations;
    9091      bool exceptionFired;
     
    9495      parent = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
    9596      expected = new RealVector(new double[] { 0.45, 0.22, 0.3, 0.6, 0.14 });
    96       min = new DoubleValue(0.3);
    97       max = new DoubleValue(0.7);
     97      bounds = new DoubleMatrix(new double[,] { { 0.3, 0.7 } });
    9898      generationsDependency = new DoubleValue(0.1);
    9999      currentGeneration = new IntValue(1);
    100100      maximumGenerations = new IntValue(4);
    101       MichalewiczNonUniformAllPositionsManipulator.Apply(random, parent, min, max, currentGeneration, maximumGenerations, generationsDependency);
     101      MichalewiczNonUniformAllPositionsManipulator.Apply(random, parent, bounds, currentGeneration, maximumGenerations, generationsDependency);
    102102      Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(expected, parent));
    103103      // The following test is not based on published examples
     
    106106      random.DoubleNumbers = new double[] { 0.2, 0.5, 0.7, 0.8, 0.9, 0.5, 0.2, 0.5, 0.7, 0.8 };
    107107      parent = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
    108       min = new DoubleValue(0.3);
    109       max = new DoubleValue(0.7);
     108      bounds = new DoubleMatrix(new double[,] { { 0.3, 0.7 } });
    110109      generationsDependency = new DoubleValue(0.1);
    111110      currentGeneration = new IntValue(5); //current generation > max generation
    112111      maximumGenerations = new IntValue(4);
    113112      try {
    114         MichalewiczNonUniformAllPositionsManipulator.Apply(random, parent, min, max, currentGeneration, maximumGenerations, generationsDependency);
     113        MichalewiczNonUniformAllPositionsManipulator.Apply(random, parent, bounds, currentGeneration, maximumGenerations, generationsDependency);
    115114      }
    116115      catch (System.ArgumentException) {
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Tests/MichalewiczNonUniformOnePositionManipulatorTest.cs

    r3061 r3123  
    8686      TestRandom random = new TestRandom();
    8787      RealVector parent, expected;
    88       DoubleValue min, max, generationsDependency;
     88      DoubleValue generationsDependency;
     89      DoubleMatrix bounds;
    8990      IntValue currentGeneration, maximumGenerations;
    9091      bool exceptionFired;
     
    9596      parent = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
    9697      expected = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.34, 0.1 });
    97       min = new DoubleValue(0.3);
    98       max = new DoubleValue(0.7);
     98      bounds = new DoubleMatrix(new double[,] { { 0.3, 0.7 } });
    9999      generationsDependency = new DoubleValue(0.1);
    100100      currentGeneration = new IntValue(1);
    101101      maximumGenerations = new IntValue(4);
    102       MichalewiczNonUniformOnePositionManipulator.Apply(random, parent, min, max, currentGeneration, maximumGenerations, generationsDependency);
     102      MichalewiczNonUniformOnePositionManipulator.Apply(random, parent, bounds, currentGeneration, maximumGenerations, generationsDependency);
    103103      Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(expected, parent));
    104104      // The following test is not based on published examples
     
    108108      random.DoubleNumbers = new double[] { 0.2, 0.7 };
    109109      parent = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
    110       min = new DoubleValue(0.3);
    111       max = new DoubleValue(0.7);
     110      bounds = new DoubleMatrix(new double[,] { { 0.3, 0.7 } });
    112111      generationsDependency = new DoubleValue(0.1);
    113112      currentGeneration = new IntValue(5); //current generation > max generation
    114113      maximumGenerations = new IntValue(4);
    115114      try {
    116         MichalewiczNonUniformOnePositionManipulator.Apply(random, parent, min, max, currentGeneration, maximumGenerations, generationsDependency);
     115        MichalewiczNonUniformOnePositionManipulator.Apply(random, parent, bounds, currentGeneration, maximumGenerations, generationsDependency);
    117116      }
    118117      catch (System.ArgumentException) {
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Tests/UniformOnePositionManipulatorTest.cs

    r3061 r3123  
    8686      TestRandom random = new TestRandom();
    8787      RealVector parent, expected;
    88       DoubleValue min, max;
     88      DoubleMatrix bounds;
    8989      // The following test is not based on published examples
    9090      random.Reset();
     
    9393      parent = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
    9494      expected = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.3, 0.1 });
    95       min = new DoubleValue(0.2);
    96       max = new DoubleValue(0.7);
    97       UniformOnePositionManipulator.Apply(random, parent, min, max);
     95      bounds = new DoubleMatrix(new double[,] { { 0.2, 0.7 } });
     96      UniformOnePositionManipulator.Apply(random, parent, bounds);
    9897      Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(expected, parent));
    9998    }
Note: See TracChangeset for help on using the changeset viewer.