Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/19/16 18:24:53 (8 years ago)
Author:
mkommend
Message:

#1087: Copied unit tests from branch and adapted path of multi-objective test function project file.

Location:
trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions.MultiObjective-3.3
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions.MultiObjective-3.3/FastHyperVolumeTests.cs

    r14111 r14121  
    2020#endregion
    2121using System;
    22 using System.Collections.Generic;
    23 using HeuristicLab.Problems.TestFunctions.MultiObjective;
    2422using Microsoft.VisualStudio.TestTools.UnitTesting;
    2523
    26 namespace MultiObjectiveTestfunctionTests {
     24namespace HeuristicLab.Problems.TestFunctions.MultiObjective.Tests {
    2725  [TestClass]
    2826  public class FastHypervolumeTest {
     
    4038    /// </summary>
    4139    [TestMethod]
    42     [TestCategory("Problems.TestFunctions")]
     40    [TestCategory("Problems.TestFunctions.MultiObjective")]
    4341    [TestProperty("Time", "short")]
    44     public void SinglePointTest() {
     42    public void FastHypervolumeTestSinglePoint() {
    4543      double[] point = new double[] { 0.5, 0.5, 0.5 };
    4644      double[][] front = { point };
     
    6361    /// </summary>
    6462    [TestMethod]
    65     [TestCategory("Problems.TestFunctions")]
     63    [TestCategory("Problems.TestFunctions.MultiObjective")]
    6664    [TestProperty("Time", "short")]
    67     public void RandomSinglePointTest() {
     65    public void FastHypervolumeTestRandomSinglePoint() {
    6866      //Front with a single Point
    6967      double[] point = new double[3];
    70       Random r = new Random();
     68      var r = new System.Random();
    7169
    7270      point[0] = r.NextDouble();
     
    10098    /// Hypervolume should be 0.25
    10199    /// </summary>
    102     //[TestMethod]
    103     public void DiagonalPointTest() {
     100    [TestMethod]
     101    [TestCategory("Problems.TestFunctions.MultiObjective")]
     102    [TestProperty("Time", "short")]
     103    public void FastHypervolumeTestDiagonalPoint() {
    104104      //Front with three points
    105105      double[] point1 = new double[] { 1, 0, 0 };
     
    110110      double[] referencePoint = new double[] { 1, 1, 1 };
    111111      double hv = Hypervolume.Calculate(front, referencePoint, new bool[3]);
    112       Assert.AreEqual(0.25, hv);
     112      Assert.AreEqual(0.5, hv);
    113113    }
    114 
    115 
    116     public void HypervolumeConsistencyTest() {
    117       double[] referencePoint = new double[] { 1, 1, 1 };
    118       bool[] maximization = new bool[3];
    119       List<double[]> points = new List<double[]>();
    120       Random r = new Random();
    121       for (int i = 0; i < 100; i++) {
    122         double[] p = new double[3];
    123         p[0] = r.NextDouble();
    124         p[1] = r.NextDouble();
    125         points.Add(p);
    126       }
    127       var front = NonDominatedSelect.SelectNonDominatedVectors(points, maximization, true);
    128 
    129       double dim3hv = Hypervolume.Calculate(front, referencePoint, new bool[3]);
    130       double dim2hv = Hypervolume.Calculate(front, referencePoint, maximization);
    131 
    132 
    133 
    134 
    135     }
    136 
    137 
    138114  }
    139 
    140 
    141115}
Note: See TracChangeset for help on using the changeset viewer.