Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/17/19 17:28:33 (5 years ago)
Author:
mkommend
Message:

#2521: Adapted unit tests for multi-objective analysis.

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/Multi-objective
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/Multi-objective/CrowdingTest.cs

    r17261 r17262  
    1 #region License Information
    2 /* HeuristicLab
    3  * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    4  *
    5  * This file is part of HeuristicLab.
    6  *
    7  * HeuristicLab is free software: you can redistribute it and/or modify
    8  * it under the terms of the GNU General Public License as published by
    9  * the Free Software Foundation, either version 3 of the License, or
    10  * (at your option) any later version.
    11  *
    12  * HeuristicLab is distributed in the hope that it will be useful,
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  * GNU General Public License for more details.
    16  *
    17  * You should have received a copy of the GNU General Public License
    18  * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
    19  */
    20 #endregion
    21 using System;
    22 using Microsoft.VisualStudio.TestTools.UnitTesting;
     1//#region License Information
     2///* HeuristicLab
     3// * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4// *
     5// * This file is part of HeuristicLab.
     6// *
     7// * HeuristicLab is free software: you can redistribute it and/or modify
     8// * it under the terms of the GNU General Public License as published by
     9// * the Free Software Foundation, either version 3 of the License, or
     10// * (at your option) any later version.
     11// *
     12// * HeuristicLab is distributed in the hope that it will be useful,
     13// * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15// * GNU General Public License for more details.
     16// *
     17// * You should have received a copy of the GNU General Public License
     18// * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19// */
     20//#endregion
     21//using System;
     22//using Microsoft.VisualStudio.TestTools.UnitTesting;
     23//using HeuristicLab.Optimization;
    2324
    24 namespace HeuristicLab.Problems.TestFunctions.MultiObjective.Tests {
    25   [TestClass]
    26   public class CrowdingTest {
     25//namespace HeuristicLab.Analysis.Tests {
     26//  [TestClass]
     27//  public class CrowdingTest {
    2728
    28     [TestMethod]
    29     [ExpectedException(typeof(ArgumentException))]
    30     [TestCategory("Problems.TestFunctions.MultiObjective")]
    31     [TestProperty("Time", "short")]
    32     public void CrowdingTestEmptyFront() {
    33       double[][] front = { };
     29//    [TestMethod]
     30//    [ExpectedException(typeof(ArgumentException))]
     31//    [TestCategory("Analysis.MultiObjective")]
     32//    [TestProperty("Time", "short")]
     33//    public void CrowdingTestEmptyFront() {
     34//      double[][] front = { };
    3435
    35       Crowding.Calculate(front, null);
    36     }
     36//      CrowdingCalculator.CalculateCrowding(front);
     37//    }
    3738
    38     [TestMethod]
    39     [TestCategory("Problems.TestFunctions.MultiObjective")]
    40     [TestProperty("Time", "short")]
    41     public void CrowdingTestSamePoint() {
     39//    [TestMethod]
     40//    [TestCategory("Analysis.MultiObjective")]
     41//    [TestProperty("Time", "short")]
     42//    public void CrowdingTestSamePoint() {
    4243
    43       double[] point = new double[2];
    44       point[0] = 0.5;
    45       point[1] = 0.5;
     44//      double[] point = new double[2];
     45//      point[0] = 0.5;
     46//      point[1] = 0.5;
    4647
    47       double[] point1 = new double[2];
    48       point1[0] = 0.5;
    49       point1[1] = 0.5;
    50       double[][] front = { point, point1 };
    51       double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } });
    52       Assert.AreEqual(double.PositiveInfinity, dist);
    53     }
     48//      double[] point1 = new double[2];
     49//      point1[0] = 0.5;
     50//      point1[1] = 0.5;
     51//      double[][] front = { point, point1 };
     52//      double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } });
     53//      Assert.AreEqual(double.PositiveInfinity, dist);
     54//    }
    5455
    55     [TestMethod]
    56     [TestCategory("Problems.TestFunctions.MultiObjective")]
    57     [TestProperty("Time", "short")]
    58     public void CrowdingTestSinglePoint() {
    59       double[] point = new double[2];
    60       point[0] = 0;
    61       point[1] = 0;
    62       double[][] front = { point };
    63       double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } });
    64       Assert.AreEqual(double.PositiveInfinity, dist);
    65     }
     56//    [TestMethod]
     57//    [TestCategory("Analysis.MultiObjective")]
     58//    [TestProperty("Time", "short")]
     59//    public void CrowdingTestSinglePoint() {
     60//      double[] point = new double[2];
     61//      point[0] = 0;
     62//      point[1] = 0;
     63//      double[][] front = { point };
     64//      double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } });
     65//      Assert.AreEqual(double.PositiveInfinity, dist);
     66//    }
    6667
    67     [TestMethod]
    68     [TestCategory("Problems.TestFunctions.MultiObjective")]
    69     [TestProperty("Time", "short")]
    70     public void CrowdingTestDiagonal() {
    71       double[] point = new double[2];
    72       point[0] = 0;
    73       point[1] = 0;
    74       double[] point1 = new double[2];
    75       point1[0] = 0.5;
    76       point1[1] = 0.5;
     68//    [TestMethod]
     69//    [TestCategory("Analysis.MultiObjective")]
     70//    [TestProperty("Time", "short")]
     71//    public void CrowdingTestDiagonal() {
     72//      double[] point = new double[2];
     73//      point[0] = 0;
     74//      point[1] = 0;
     75//      double[] point1 = new double[2];
     76//      point1[0] = 0.5;
     77//      point1[1] = 0.5;
    7778
    78       double[] point2 = new double[2];
    79       point2[0] = 1;
    80       point2[1] = 1;
    81       double[][] front = { point, point1, point2 };
    82       double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } });
    83       Assert.AreEqual(2, dist);
    84     }
     79//      double[] point2 = new double[2];
     80//      point2[0] = 1;
     81//      point2[1] = 1;
     82//      double[][] front = { point, point1, point2 };
     83//      double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } });
     84//      Assert.AreEqual(2, dist);
     85//    }
    8586
    86     [TestMethod]
    87     [TestCategory("Problems.TestFunctions.MultiObjective")]
    88     [TestProperty("Time", "short")]
    89     public void CrowdingTestDiamond() {
    90       double[] point = new double[2];
    91       point[0] = 0;
    92       point[1] = 0;
    93       double[] point1 = new double[2];
    94       point1[0] = 1;
    95       point1[1] = 1.5;
     87//    [TestMethod]
     88//    [TestCategory("Analysis.MultiObjective")]
     89//    [TestProperty("Time", "short")]
     90//    public void CrowdingTestDiamond() {
     91//      double[] point = new double[2];
     92//      point[0] = 0;
     93//      point[1] = 0;
     94//      double[] point1 = new double[2];
     95//      point1[0] = 1;
     96//      point1[1] = 1.5;
    9697
    97       double[] point2 = new double[2];
    98       point2[0] = 3;
    99       point2[1] = 0.5;
    100       double[] point3 = new double[2];
    101       point3[0] = 4;
    102       point3[1] = 2;
    103       double[][] front = { point, point1, point2, point3 };
    104       double dist = Crowding.Calculate(front, new double[,] { { 0, 4 }, { 0, 2 } });
    105       Assert.AreEqual(1.5, dist);
    106     }
     98//      double[] point2 = new double[2];
     99//      point2[0] = 3;
     100//      point2[1] = 0.5;
     101//      double[] point3 = new double[2];
     102//      point3[0] = 4;
     103//      point3[1] = 2;
     104//      double[][] front = { point, point1, point2, point3 };
     105//      double dist = Crowding.Calculate(front, new double[,] { { 0, 4 }, { 0, 2 } });
     106//      Assert.AreEqual(1.5, dist);
     107//    }
    107108
    108     /// <summary>
    109     /// deltoid with 4 points of the 1-unit-square and the northeastern point at 4,4
    110     ///
    111     /// </summary>
    112     [TestMethod]
    113     [TestCategory("Problems.TestFunctions.MultiObjective")]
    114     [TestProperty("Time", "short")]
    115     public void CrowdingTestDeltoid() {
    116       double[] point = new double[2];
    117       point[0] = 0;
    118       point[1] = 0;
    119       double[] point1 = new double[2];
    120       point1[0] = 0.00000001;         //points should not be exactly equal because sorting behaviour could change result
    121       point1[1] = 1.00000001;
     109//    /// <summary>
     110//    /// deltoid with 4 points of the 1-unit-square and the northeastern point at 4,4
     111//    ///
     112//    /// </summary>
     113//    [TestMethod]
     114//    [TestCategory("Analysis.MultiObjective")]
     115//    [TestProperty("Time", "short")]
     116//    public void CrowdingTestDeltoid() {
     117//      double[] point = new double[2];
     118//      point[0] = 0;
     119//      point[1] = 0;
     120//      double[] point1 = new double[2];
     121//      point1[0] = 0.00000001;         //points should not be exactly equal because sorting behavior could change result
     122//      point1[1] = 1.00000001;
    122123
    123       double[] point2 = new double[2];
    124       point2[0] = 1;
    125       point2[1] = 0;
    126       double[] point3 = new double[2];
    127       point3[0] = 4;
    128       point3[1] = 4;
     124//      double[] point2 = new double[2];
     125//      point2[0] = 1;
     126//      point2[1] = 0;
     127//      double[] point3 = new double[2];
     128//      point3[0] = 4;
     129//      point3[1] = 4;
    129130
    130131
    131       double[][] front = { point, point1, point2, point3, };
    132       double dist = Crowding.Calculate(front, new double[,] { { 0, 4 }, { 0, 4 } });
    133       Assert.AreEqual(1.25, dist);
    134     }
     132//      double[][] front = { point, point1, point2, point3, };
     133//      double dist = Crowding.Calculate(front, new double[,] { { 0, 4 }, { 0, 4 } });
     134//      Assert.AreEqual(1.25, dist);
     135//    }
    135136
    136137
    137   }
     138//  }
    138139
    139140
    140 }
     141//}
Note: See TracChangeset for help on using the changeset viewer.