#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.Diagnostics; using System.Linq; using System.Windows.Forms; using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers; using MIConvexHull; namespace Visualization { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); int nrOfSamples = 100; int sampleSize = 100; double[][] inputs = CreateRandomData(nrOfSamples, sampleSize); Stopwatch watch = new Stopwatch(); watch.Start(); var result2 = HyperHull.Calculate(inputs); watch.Stop(); Console.WriteLine("HyperHull: " + watch.ElapsedMilliseconds); watch.Restart(); var result1 = ConvexHull.Create(inputs).Points.Select(x => x.Position).ToList(); watch.Stop(); Console.WriteLine("MIConvexHull: " + watch.ElapsedMilliseconds); int k = 0; foreach (var d in result1) { bool found = false; foreach (var e in result2) { int i = 0; for (i = 0; i < e.Count(); i++) { if (d[i] != e[i]) { break; } } if (i == e.Count()) { found = true; k++; break; } } } VisualizationForm vis = new VisualizationForm(); vis.Text = "Ratio: " + k + "/" + result1.Count; vis.Inputs = inputs; vis.ConvexHull1 = result1; vis.ConvexHull2 = result2; Application.Run(vis); } private 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, 240); } } return result; } } }