Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
test-convexhull-time.C
Go to the documentation of this file.
1
2/* Aleph-w
3
4 / \ | | ___ _ __ | |__ __ __
5 / _ \ | |/ _ \ '_ \| '_ \ ____\ \ /\ / / Data structures & Algorithms
6 / ___ \| | __/ |_) | | | |_____\ V V / version 1.9c
7 /_/ \_\_|\___| .__/|_| |_| \_/\_/ https://github.com/lrleon/Aleph-w
8 |_|
9
10 This file is part of Aleph-w library
11
12 Copyright (c) 2002-2018 Leandro Rabindranath Leon
13
14 This program is free software: you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <https://www.gnu.org/licenses/>.
26*/
27# include <iostream>
28
29# include <gsl/gsl_rng.h>
30
31# include <geom_algorithms.H>
32# include <ahNow.H>
33
34using namespace std;
35
37
39{
40 Points ret;
41
42 for (size_t i = 0; i < n; ++i)
44
45 return ret;
46}
47
48int main()
49{
50 constexpr size_t num_exp = 6;
51 constexpr size_t num_test = 12;
52 size_t sample_size = 128;
53
55 gsl_rng_set(rng, time(nullptr));
56
57 double sz[num_exp];
58 double bf[num_exp];
59 double gw[num_exp];
60 double qh[num_exp];
61
62 for (size_t i = 0; i < num_exp; ++i)
63 {
64 cout << "Testing sample size: " << sample_size << endl;
65
66 sz[i] = sample_size;
67
68 bf[i] = gw[i] = qh[i] = 0.0;
69
70 for (size_t j = 0; j < num_test; ++j)
71 {
72 Points points = generate_points(sample_size, rng);
73
74 Now now;
75 now.start();
76 QuickHull()(points);
77 qh[i] += now.elapsed();
78
79 now.start();
80 GiftWrappingConvexHull()(points);
81 gw[i] += now.elapsed();
82
83 now.start();
84 BruteForceConvexHull()(points);
85 bf[i] += now.elapsed();
86 }
87
88 sample_size = sample_size << 1;
89 }
90
91 cout << "Sample size\tQuick hull\tGift wrapping\tBrute force\n"
92 << "===========\t===========\t=============\t==========\n";
93
94 for (size_t i = 0; i < num_exp; ++i)
95 cout << sz[i] << '\t' << qh[i]/num_test << '\t' << gw[i]/num_test
96 << '\t' << bf[i]/num_test << endl;
97
99
100 return 0;
101}
102
High-resolution timer and benchmarking utilities.
Brute force convex hull algorithm.
Dynamic singly linked list with functional programming support.
Definition htlist.H:1155
T & append(const T &item)
Definition htlist.H:1271
Gift wrapping (Jarvis march) convex hull algorithm.
Class Now is a practical class for timing based in a high resolution clock.
Definition ahNow.H:79
TimePointType start()
Sets internally the current time point.
Definition ahNow.H:195
Represents a point with rectangular coordinates in a 2D plane.
Definition point.H:229
QuickHull convex hull algorithm.
static mt19937 rng
Computational geometry algorithms.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
STL namespace.
Points generate_points(size_t n, gsl_rng *&rng)
int main()