#region License Information
/* HeuristicLab
* Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers;
using HeuristicLab.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace AlgorithmBehaviorUnitTests {
[TestClass]
public class VolumeCalculationTest {
[TestMethod]
public void TestVolumeCalculation() {
var points = new List();
points.Add(new double[] { -0.72045174, 1.44667601, -1.75159125 });
points.Add(new double[] { -0.67521503, 0.61127293, -0.33962646 });
points.Add(new double[] { 2.02392510, -0.41962562, -1.12211942 });
points.Add(new double[] { 0.02647963, -0.24983950, -0.47038916 });
points.Add(new double[] { 0.61548803, -0.25039511, 0.97745744 });
points.Add(new double[] { -1.65142294, -0.09537136, 1.93154268 });
points.Add(new double[] { 1.12618422, 0.49384888, 0.05286691 });
points.Add(new double[] { -0.12506782, -2.29161965, -0.09710301 });
var convexHull = LPHull.Calculate(points.ToArray());
double volume = ConvexHullMeasures.CalculateVolume(convexHull);
volume = Math.Round(volume, 6);
//volume computed with R and the geometry package which uses qhull
Assert.IsTrue(volume.IsAlmost(7.960698));
volume = ConvexHullMeasures.CalculateVolume(points);
volume = Math.Round(volume, 6);
Assert.IsTrue(volume.IsAlmost(7.960698));
}
[TestMethod]
public void TestVolumeCalculationQhull() {
var points = new List();
points.Add(new double[] { -0.72045174, 1.44667601, -1.75159125 });
points.Add(new double[] { -0.67521503, 0.61127293, -0.33962646 });
points.Add(new double[] { 2.02392510, -0.41962562, -1.12211942 });
points.Add(new double[] { 0.02647963, -0.24983950, -0.47038916 });
points.Add(new double[] { 0.61548803, -0.25039511, 0.97745744 });
points.Add(new double[] { -1.65142294, -0.09537136, 1.93154268 });
points.Add(new double[] { 1.12618422, 0.49384888, 0.05286691 });
points.Add(new double[] { -0.12506782, -2.29161965, -0.09710301 });
double volume = QhullWrapper.CalculateVolume(points);
volume = Math.Round(volume, 6);
//volume computed with R and the geometry package which uses qhull
Assert.IsTrue(volume.IsAlmost(7.960698));
}
}
}