#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.Linq; using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers; using HeuristicLab.Common; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace AlgorithmBehaviorUnitTests { [TestClass] public class ConvexHullTest { [TestMethod] public void TestConvexHullAlgorithms() { int nrOfSamples = 50; int dimension = 4; double[][] inputs = CreateRandomData(nrOfSamples, dimension); var lpResult = LPHull.Calculate(inputs); var qhResult = QhullWrapper.Calculate(inputs.ToList()); foreach (var qhr in qhResult) { bool found = false; foreach (var lpr in lpResult) { int i = 0; for (i = 0; i < lpr.Count(); i++) { if (!qhr[i].IsAlmost(lpr[i])) { break; } } if (i == lpr.Count()) { found = true; break; } } Assert.IsTrue(found); } } public static double[][] CreateRandomData(int n, int m) { double[][] result = new double[n][]; Random rand = new Random(); for (int i = 0; i < n; i++) { result[i] = new double[m]; for (int j = 0; j < m; j++) { result[i][j] = (double)rand.Next(1, 60); } } return result; } } }