[10208] | 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 |
|
---|
| 22 | using System;
|
---|
[10207] | 23 | using System.Collections.Generic;
|
---|
| 24 | using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers;
|
---|
| 25 | using HeuristicLab.Common;
|
---|
| 26 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 27 |
|
---|
| 28 | namespace AlgorithmBehaviorUnitTests {
|
---|
| 29 | [TestClass]
|
---|
| 30 | public class VolumeCalculationTest {
|
---|
| 31 | [TestMethod]
|
---|
| 32 | public void TestVolumeCalculation() {
|
---|
| 33 | var points = new List<double[]>();
|
---|
| 34 | points.Add(new double[] { -0.72045174, 1.44667601, -1.75159125 });
|
---|
| 35 | points.Add(new double[] { -0.67521503, 0.61127293, -0.33962646 });
|
---|
| 36 | points.Add(new double[] { 2.02392510, -0.41962562, -1.12211942 });
|
---|
| 37 | points.Add(new double[] { 0.02647963, -0.24983950, -0.47038916 });
|
---|
| 38 | points.Add(new double[] { 0.61548803, -0.25039511, 0.97745744 });
|
---|
| 39 | points.Add(new double[] { -1.65142294, -0.09537136, 1.93154268 });
|
---|
| 40 | points.Add(new double[] { 1.12618422, 0.49384888, 0.05286691 });
|
---|
| 41 | points.Add(new double[] { -0.12506782, -2.29161965, -0.09710301 });
|
---|
| 42 |
|
---|
| 43 | var convexHull = LPHull.Calculate(points.ToArray());
|
---|
[10208] | 44 | double volume = ConvexHullMeasures.CalculateVolume(convexHull);
|
---|
[10207] | 45 | volume = Math.Round(volume, 6);
|
---|
| 46 | //volume computed with R and the geometry package which uses qhull
|
---|
| 47 | Assert.IsTrue(volume.IsAlmost(7.960698));
|
---|
[10208] | 48 | volume = ConvexHullMeasures.CalculateVolume(points);
|
---|
[10207] | 49 | volume = Math.Round(volume, 6);
|
---|
| 50 | Assert.IsTrue(volume.IsAlmost(7.960698));
|
---|
| 51 | }
|
---|
[10208] | 52 |
|
---|
| 53 | [TestMethod]
|
---|
| 54 | public void TestVolumeCalculationQhull() {
|
---|
| 55 | var points = new List<double[]>();
|
---|
| 56 | points.Add(new double[] { -0.72045174, 1.44667601, -1.75159125 });
|
---|
| 57 | points.Add(new double[] { -0.67521503, 0.61127293, -0.33962646 });
|
---|
| 58 | points.Add(new double[] { 2.02392510, -0.41962562, -1.12211942 });
|
---|
| 59 | points.Add(new double[] { 0.02647963, -0.24983950, -0.47038916 });
|
---|
| 60 | points.Add(new double[] { 0.61548803, -0.25039511, 0.97745744 });
|
---|
| 61 | points.Add(new double[] { -1.65142294, -0.09537136, 1.93154268 });
|
---|
| 62 | points.Add(new double[] { 1.12618422, 0.49384888, 0.05286691 });
|
---|
| 63 | points.Add(new double[] { -0.12506782, -2.29161965, -0.09710301 });
|
---|
| 64 |
|
---|
| 65 | double volume = QhullWrapper.CalculateVolume(points);
|
---|
| 66 | volume = Math.Round(volume, 6);
|
---|
| 67 | //volume computed with R and the geometry package which uses qhull
|
---|
| 68 | Assert.IsTrue(volume.IsAlmost(7.960698));
|
---|
| 69 | }
|
---|
[10207] | 70 | }
|
---|
| 71 | }
|
---|