-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
83 lines (64 loc) · 2.4 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <cstdlib>
#include "file_functions.h"
#include "help_functions.h"
#include "cluster.h"
#include "distances.h"
#include "hashtable.h"
#include "hash_functions.h"
#include "help_functions.h"
using namespace std;
int method_init;
int method_assign;
int method_update;
int main(int argc, const char *argv[]) {
ios::sync_with_stdio(false);
srand(time(NULL));
char *input_file = get_arguments(argv, argc, "-i");
char *conf_file = get_arguments(argv, argc, "-c");
char *output_file = get_arguments(argv, argc, "-o");
char *metric = get_arguments(argv, argc, "-d");
char *complete = get_arguments(argv, argc, "-complete", true);
method_init = atoi(get_arguments(argv, argc, "-init"));
method_assign = atoi(get_arguments(argv, argc, "-assign"));
method_update = atoi(get_arguments(argv, argc, "-update"));
num_of_clusters = 2;
global_k = 2;
global_L = 3;
int dim = 2;
double delta = 0.2;
read_file(input_file, dim);
read_configuration_file(conf_file);
mem_distance = new double*[(int)input_curves.size()];
for (int i = 0; i < (int)input_curves.size(); ++i) {
mem_distance[i] = new double[(int)input_curves.size()];
for (int j = 0; j < (int)input_curves.size(); ++j) {
mem_distance[i][j] = -1;
}
}
int max_points = 0;
for (int i = 0; i < (int)input_curves.size(); ++i) {
int value = input_curves[i].get_length();
max_points = max(max_points, value);
}
for (int i = 0; i < max_points * global_k * dim; ++i) {
vec_r.push_back(rand() % MAX_R);
}
int table_size = (int)input_curves.size() / 4 + 1;
vector<HashTable> hashtables(global_L + 1, HashTable(table_size));
for (int i = 0; i < global_L ; ++i) {
hashtables[i].set_id(i);
}
vector<const Curve*> centroids;
vector<vector<int> > clusters(num_of_clusters);
vector<double> silhouette_cluster(num_of_clusters);
if (method_assign == 2) {
insert_curves_into_hashtables(hashtables, delta, "classic");
}
clock_t begin = clock();
clustering(hashtables, delta, silhouette_cluster, centroids, clusters, metric);
clock_t end = clock();
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
print_file(output_file, metric, silhouette_cluster, elapsed_secs, centroids, clusters, dim, complete);
return 0;
}