Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/18/19 16:27:56 (5 years ago)
Author:
bwerth
Message:

#2521 fixed crowding unit tests, moved CrowdingTest, HyperVolumeTests and FastHyperVolumeTests to their own subfolder

Location:
branches/2521_ProblemRefactoring
Files:
1 added
6 deleted
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r17225 r17338  
    160160    <Compile Include="MultiObjective\CrowdingCalculator.cs" />
    161161    <Compile Include="MultiObjective\DominationCalculator.cs" />
     162    <Compile Include="MultiObjective\GenerationalDistanceCalculator.cs" />
    162163    <Compile Include="MultiObjective\HypervolumeCalculator.cs" />
    163164    <Compile Include="Results\IResultParameter.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Optimization-3.3/Multi-objective/CrowdingTest.cs

    r17262 r17338  
    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;
     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
     21using System;
     22using Microsoft.VisualStudio.TestTools.UnitTesting;
     23using HeuristicLab.Optimization;
    2424
    25 //namespace HeuristicLab.Analysis.Tests {
    26 //  [TestClass]
    27 //  public class CrowdingTest {
     25namespace HeuristicLab.Optimization.Tests {
     26  [TestClass]
     27  public class CrowdingTest {
    2828
    29 //    [TestMethod]
    30 //    [ExpectedException(typeof(ArgumentException))]
    31 //    [TestCategory("Analysis.MultiObjective")]
    32 //    [TestProperty("Time", "short")]
    33 //    public void CrowdingTestEmptyFront() {
    34 //      double[][] front = { };
     29    [TestMethod]
     30    [ExpectedException(typeof(ArgumentException))]
     31    [TestCategory("Optimization.MultiObjective")]
     32    [TestProperty("Time", "short")]
     33    public void CrowdingTestEmptyFront() {
     34      double[][] front = { };
    3535
    36 //      CrowdingCalculator.CalculateCrowding(front);
    37 //    }
     36      CrowdingCalculator.CalculateCrowding(front);
     37    }
    3838
    39 //    [TestMethod]
    40 //    [TestCategory("Analysis.MultiObjective")]
    41 //    [TestProperty("Time", "short")]
    42 //    public void CrowdingTestSamePoint() {
     39    [TestMethod]
     40    [TestCategory("Optimization.MultiObjective")]
     41    [TestProperty("Time", "short")]
     42    public void CrowdingTestSamePoint() {
    4343
    44 //      double[] point = new double[2];
    45 //      point[0] = 0.5;
    46 //      point[1] = 0.5;
     44      double[] point = new double[2];
     45      point[0] = 0.5;
     46      point[1] = 0.5;
    4747
    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 //    }
     48      double[] point1 = new double[2];
     49      point1[0] = 0.5;
     50      point1[1] = 0.5;
     51      double[][] front = { point, point1 };
     52      double dist = CrowdingCalculator.CalculateCrowding(front);
     53      Assert.AreEqual(double.PositiveInfinity, dist);
     54    }
    5555
    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 //    }
     56    [TestMethod]
     57    [TestCategory("Optimization.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 = CrowdingCalculator.CalculateCrowding(front);
     65      Assert.AreEqual(double.PositiveInfinity, dist);
     66    }
    6767
    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;
     68    [TestMethod]
     69    [TestCategory("Optimization.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;
    7878
    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 //    }
     79      double[] point2 = new double[2];
     80      point2[0] = 1;
     81      point2[1] = 1;
     82      double[][] front = { point, point1, point2 };
     83      double dist = CrowdingCalculator.CalculateCrowding(front);
     84      Assert.AreEqual(2, dist);
     85    }
    8686
    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;
     87    [TestMethod]
     88    [TestCategory("Optimization.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;
    9797
    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 //    }
     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 = CrowdingCalculator.CalculateCrowding(front);
     106      Assert.AreEqual(1.5, dist);
     107    }
    108108
    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;
     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("Optimization.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;
    123123
    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;
     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;
    130130
    131131
    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 //    }
     132      double[][] front = { point, point1, point2, point3, };
     133      double dist = CrowdingCalculator.CalculateCrowding(front);
     134      Assert.AreEqual(1.25, dist);
     135    }
    136136
    137137
    138 //  }
     138  }
    139139
    140140
    141 //}
     141}
  • branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Optimization-3.3/Multi-objective/FastHyperVolumeTests.cs

    r17262 r17338  
    2323using Microsoft.VisualStudio.TestTools.UnitTesting;
    2424
    25 namespace HeuristicLab.Analysis.MultiObjective.Tests {
     25namespace HeuristicLab.Optimization.Tests {
    2626  [TestClass]
    2727  public class FastHypervolumeTest {
     
    3939    /// </summary>
    4040    [TestMethod]
    41     [TestCategory("Analysis.MultiObjective")]
     41    [TestCategory("Optimization.MultiObjective")]
    4242    [TestProperty("Time", "short")]
    4343    public void FastHypervolumeTestSinglePoint() {
     
    6262    /// </summary>
    6363    [TestMethod]
    64     [TestCategory("Analysis.MultiObjective")]
     64    [TestCategory("Optimization.MultiObjective")]
    6565    [TestProperty("Time", "short")]
    6666    public void FastHypervolumeTestRandomSinglePoint() {
     
    100100    /// </summary>
    101101    [TestMethod]
    102     [TestCategory("Analysis.MultiObjective")]
     102    [TestCategory("Optimization.MultiObjective")]
    103103    [TestProperty("Time", "short")]
    104104    public void FastHypervolumeTestDiagonalPoint() {
  • branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Optimization-3.3/Multi-objective/HyperVolumeTests.cs

    r17262 r17338  
    2424using Microsoft.VisualStudio.TestTools.UnitTesting;
    2525
    26 namespace HeuristicLab.Analysis.MultiObjective.Tests {
     26namespace HeuristicLab.Optimization.Tests {
    2727  [TestClass]
    2828  public class HypervolumeTest {
     
    4141    /// </summary>
    4242    [TestMethod]
    43     [TestCategory("Analysis.MultiObjective")]
     43    [TestCategory("Optimization.MultiObjective")]
    4444    [TestProperty("Time", "short")]
    4545    public void HypervolumeTestSinglePoint() {
     
    9898    /// </summary>
    9999    [TestMethod]
    100     [TestCategory("Analysis.MultiObjective")]
     100    [TestCategory("Optimization.MultiObjective")]
    101101    [TestProperty("Time", "short")]
    102102    public void HypervolumeTestRandomSinglePoint() {
     
    151151    /// </summary>
    152152    [TestMethod]
    153     [TestCategory("Analysis.MultiObjective")]
     153    [TestCategory("Optimization.MultiObjective")]
    154154    [TestProperty("Time", "short")]
    155155    public void HypervolumeTestDiagonalPoint() {
     
    202202
    203203    [TestMethod()]
    204     [ExpectedException(typeof(ArgumentException))]
    205     [TestCategory("Analysis.MultiObjective")]
     204    [TestCategory("Optimization.MultiObjective")]
    206205    [TestProperty("Time", "short")]
    207206    public void HypervolumeTestReferencePointViolationNE() {
     
    220219      referencePoint[1] = 1;
    221220      double ne = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization);
    222     }
    223 
    224     [TestMethod()]
    225     [ExpectedException(typeof(ArgumentException))]
    226     [TestCategory("Analysis.MultiObjective")]
     221      Assert.AreEqual(0, ne);
     222    }
     223
     224    [TestMethod()]
     225    [TestCategory("Optimization.MultiObjective")]
    227226    [TestProperty("Time", "short")]
    228227    public void HypervolumeTestReferencePointViolationNW() {
     
    241240      referencePoint[1] = 1;
    242241      double nw = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization);
    243       Assert.AreEqual(0.25, nw);
    244     }
    245 
    246     [TestMethod()]
    247     [ExpectedException(typeof(ArgumentException))]
    248     [TestCategory("Analysis.MultiObjective")]
     242      Assert.AreEqual(0, nw);
     243    }
     244
     245    [TestMethod()]
     246    [TestCategory("Optimization.MultiObjective")]
    249247    [TestProperty("Time", "short")]
    250248    public void HypervolumeTestReferencePointViolationSW() {
     
    263261      referencePoint[1] = 0;
    264262      double sw = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization);
    265       Assert.AreEqual(0.25, sw);
    266     }
    267 
    268     [TestMethod()]
    269     [ExpectedException(typeof(ArgumentException))]
    270     [TestCategory("Analysis.MultiObjective")]
     263      Assert.AreEqual(0, sw);
     264    }
     265
     266    [TestMethod()]
     267    [TestCategory("Optimization.MultiObjective")]
    271268    [TestProperty("Time", "short")]
    272269    public void HypervolumeTestReferencePointViolationSE() {
     
    285282      referencePoint[1] = 0;
    286283      double se = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization);
    287       Assert.AreEqual(0.25, se);
     284      Assert.AreEqual(0, se);
    288285    }
    289286  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r17262 r17338  
    510510    <Compile Include="HeuristicLab.Analysis-3.3\EffectSizeUnitTests.cs" />
    511511    <Compile Include="HeuristicLab.Analysis-3.3\KruskalWallisUnitTests.cs" />
     512    <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\SpacingTest.cs" />
    512513    <Compile Include="HeuristicLab.Analysis-3.3\MultidimensionalScalingTest.cs" />
    513514    <Compile Include="HeuristicLab.Collections-3.3\BidirectionalDictionaryTest.cs" />
     
    590591    <Compile Include="HeuristicLab.IGraph\IGraphWrappersMatrixTest.cs" />
    591592    <Compile Include="HeuristicLab.IGraph\IGraphWrappersVectorTest.cs" />
     593    <Compile Include="HeuristicLab.Optimization-3.3\Multi-objective\CrowdingTest.cs" />
     594    <Compile Include="HeuristicLab.Optimization-3.3\Multi-objective\FastHyperVolumeTests.cs" />
     595    <Compile Include="HeuristicLab.Optimization-3.3\Multi-objective\HyperVolumeTests.cs" />
    592596    <Compile Include="HeuristicLab.Persistence-3.3\StorableAttributeTests.cs" />
    593597    <Compile Include="HeuristicLab.Persistence-3.3\UseCases.cs" />
     
    636640    <Compile Include="HeuristicLab.Problems.TestFunctions-3.3\SumSquaresEvaluatorTest.cs" />
    637641    <Compile Include="HeuristicLab.Problems.TestFunctions-3.3\ZakharovEvaluatorTest.cs" />
    638     <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\CrowdingTest.cs" />
    639     <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\FastHyperVolumeTests.cs" />
    640642    <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\GenerationalDistanceTest.cs" />
    641     <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\HyperVolumeTests.cs" />
    642643    <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\InvertedGenerationalDistanceTest.cs" />
    643     <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\SpacingTest.cs" />
    644644    <Compile Include="HeuristicLab.Problems.TravelingSalesman-3.3\TSPMoveEvaluatorTest.cs" />
    645645    <Compile Include="HeuristicLab.Problems.LinearAssignment-3.3\LinearAssignmentProblemSolverTest.cs" />
     
    716716    </EmbeddedResource>
    717717  </ItemGroup>
     718  <ItemGroup />
    718719  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    719720  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset for help on using the changeset viewer.