Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/BigVolumeTest.cs @ 11336

Last change on this file since 11336 was 10286, checked in by ascheibe, 11 years ago

#1886 added support for calculating big volumes

File size: 2.1 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 System.Linq;
25using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers;
26using Mehroz;
27using Microsoft.VisualStudio.TestTools.UnitTesting;
28
29namespace AlgorithmBehaviorUnitTests {
30  [TestClass]
31  public class BigVolumeTest {
32    [TestMethod]
33    public void TestSimplexVolumeCalculation() {
34      List<double[]> simplex = new List<double[]>();
35      simplex.Add(new[] { 12.0, 4.5, 5.6 });
36      simplex.Add(new[] { 1.0, 10.5, 5.6 });
37      simplex.Add(new[] { 3.0, 1.5, 7.7 });
38      simplex.Add(new[] { 1.5, 6.5, 3.9 });
39
40      double volume = ConvexHullMeasures.CalculateSimplexVolume(simplex);
41      double volumeBig = ConvexHullMeasures.CalculateSimplexVolumeBig(simplex).ToDouble();
42      Assert.AreEqual(Math.Round(volume, 0), Math.Round(volumeBig, 0));
43    }
44
45    [TestMethod]
46    public void TestVolumeCalculation() {
47      int nrOfSamples = 51;
48      int dimension = 4;
49
50      var inputs = ConvexHullTest.CreateRandomData(nrOfSamples, dimension).ToList();
51
52      double volume = ConvexHullMeasures.CalculateVolume(inputs);
53      Fraction volumeBig = ConvexHullMeasures.CalculateVolumeBig(inputs);
54      double vb = volumeBig.ToDouble();
55      Assert.AreEqual(Math.Round(volume), Math.Round(vb, 0));
56    }
57  }
58}
Note: See TracBrowser for help on using the repository browser.