1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers;
|
---|
4 | using HeuristicLab.Common;
|
---|
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
6 |
|
---|
7 | namespace AlgorithmBehaviorUnitTests {
|
---|
8 | [TestClass]
|
---|
9 | public class VolumeCalculationTest {
|
---|
10 | [TestMethod]
|
---|
11 | public void TestVolumeCalculation() {
|
---|
12 | const int numPoints = 8;
|
---|
13 | const int dimension = 3;
|
---|
14 |
|
---|
15 | var points = new List<double[]>();
|
---|
16 | points.Add(new double[] { -0.72045174, 1.44667601, -1.75159125 });
|
---|
17 | points.Add(new double[] { -0.67521503, 0.61127293, -0.33962646 });
|
---|
18 | points.Add(new double[] { 2.02392510, -0.41962562, -1.12211942 });
|
---|
19 | points.Add(new double[] { 0.02647963, -0.24983950, -0.47038916 });
|
---|
20 | points.Add(new double[] { 0.61548803, -0.25039511, 0.97745744 });
|
---|
21 | points.Add(new double[] { -1.65142294, -0.09537136, 1.93154268 });
|
---|
22 | points.Add(new double[] { 1.12618422, 0.49384888, 0.05286691 });
|
---|
23 | points.Add(new double[] { -0.12506782, -2.29161965, -0.09710301 });
|
---|
24 |
|
---|
25 | var convexHull = LPHull.Calculate(points.ToArray());
|
---|
26 | double volume = ConvexHullMeasures.CalculateVolumeNew(convexHull);
|
---|
27 | volume = Math.Round(volume, 6);
|
---|
28 | //volume computed with R and the geometry package which uses qhull
|
---|
29 | Assert.IsTrue(volume.IsAlmost(7.960698));
|
---|
30 | volume = ConvexHullMeasures.CalculateVolumeNew(points);
|
---|
31 | volume = Math.Round(volume, 6);
|
---|
32 | Assert.IsTrue(volume.IsAlmost(7.960698));
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|