Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/VolumeCalculationTest.cs @ 10208

Last change on this file since 10208 was 10208, checked in by ascheibe, 10 years ago

#1886

  • added x64 configurations for qhull
  • added a wrapper for qhull volume calculation
  • removed old volume calculation code
File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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
22using System;
23using System.Collections.Generic;
24using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers;
25using HeuristicLab.Common;
26using Microsoft.VisualStudio.TestTools.UnitTesting;
27
28namespace AlgorithmBehaviorUnitTests {
29  [TestClass]
30  public class VolumeCalculationTest {
31    [TestMethod]
32    public void TestVolumeCalculation() {
33      const int numPoints = 8;
34      const int dimension = 3;
35
36      var points = new List<double[]>();
37      points.Add(new double[] { -0.72045174, 1.44667601, -1.75159125 });
38      points.Add(new double[] { -0.67521503, 0.61127293, -0.33962646 });
39      points.Add(new double[] { 2.02392510, -0.41962562, -1.12211942 });
40      points.Add(new double[] { 0.02647963, -0.24983950, -0.47038916 });
41      points.Add(new double[] { 0.61548803, -0.25039511, 0.97745744 });
42      points.Add(new double[] { -1.65142294, -0.09537136, 1.93154268 });
43      points.Add(new double[] { 1.12618422, 0.49384888, 0.05286691 });
44      points.Add(new double[] { -0.12506782, -2.29161965, -0.09710301 });
45
46      var convexHull = LPHull.Calculate(points.ToArray());
47      double volume = ConvexHullMeasures.CalculateVolume(convexHull);
48      volume = Math.Round(volume, 6);
49      //volume computed with R and the geometry package which uses qhull
50      Assert.IsTrue(volume.IsAlmost(7.960698));
51      volume = ConvexHullMeasures.CalculateVolume(points);
52      volume = Math.Round(volume, 6);
53      Assert.IsTrue(volume.IsAlmost(7.960698));
54    }
55
56
57    [TestMethod]
58    public void TestVolumeCalculationQhull() {
59      const int numPoints = 8;
60      const int dimension = 3;
61
62      var points = new List<double[]>();
63      points.Add(new double[] { -0.72045174, 1.44667601, -1.75159125 });
64      points.Add(new double[] { -0.67521503, 0.61127293, -0.33962646 });
65      points.Add(new double[] { 2.02392510, -0.41962562, -1.12211942 });
66      points.Add(new double[] { 0.02647963, -0.24983950, -0.47038916 });
67      points.Add(new double[] { 0.61548803, -0.25039511, 0.97745744 });
68      points.Add(new double[] { -1.65142294, -0.09537136, 1.93154268 });
69      points.Add(new double[] { 1.12618422, 0.49384888, 0.05286691 });
70      points.Add(new double[] { -0.12506782, -2.29161965, -0.09710301 });
71
72      double volume = QhullWrapper.CalculateVolume(points);
73      volume = Math.Round(volume, 6);
74      //volume computed with R and the geometry package which uses qhull
75      Assert.IsTrue(volume.IsAlmost(7.960698));
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.