-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
93 lines (84 loc) · 2.64 KB
/
main.cpp
File metadata and controls
93 lines (84 loc) · 2.64 KB
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
84
85
86
87
88
89
90
91
92
93
#include <iostream>
#include <vector>
#include <ctime>
#include <fstream>
#include <string>
#include "TransactionDB.hpp"
#include "Miner.hpp"
#include "MINIT.hpp"
#include "MIWI.hpp"
#include "MAFIA.hpp"
void test_MINIT()
{
TransactionDB D("/Users/jiyi/Documents/ut/lab/proj/data/mushroom.dat", DB_type::BITSET);
Miner* miner = new MINIT(&D, 100.0f/8124.0f, D.dim());
miner->mine();
if (miner->check())
{
printf("result is valid.\n");
miner->print_result();
}
delete miner;
}
void test_MIWI()
{
TransactionDB D("/Users/jiyi/Documents/ut/lab/proj/data/mushroom.dat", DB_type::VECTOR);
Miner* miner = new MIWI(&D, 100.0f/8124.0f);
miner->mine();
if (miner->check())
{
printf("result is valid.\n");
miner->print_result();
}
delete miner;
}
void test_MAFIA()
{
TransactionDB D("/Users/jiyi/Documents/ut/lab/proj/data/mushroom.dat", DB_type::VECTOR);
Miner* miner = new MAFIA(&D, 1000.0f/8124.0f);
miner->mine();
if (miner->check())
{
printf("result is valid.\n");
miner->print_result();
}
delete miner;
}
void gen_dataset(string input_file, int lower_bound, int upper_bound)
{
TransactionDB D(input_file, DB_type::VECTOR);
lower_bound = lower_bound == -1 ? 1 : lower_bound;
upper_bound = upper_bound == -1 ? D.size() : upper_bound;
string output_file = input_file.substr(0, input_file.length()-4) + "_" + to_string(lower_bound) + "_" + to_string(upper_bound) + ".its";
ofstream output;
output.open(output_file);
output << "item:" << D.dim() << "transaction:" << D.size() << endl;
for (int threshold = lower_bound; threshold <= upper_bound; threshold++)
{
Miner* miner = new MAFIA(&D, threshold);
miner->mine();
miner->write_result(output);
cout << "MFI: threshold=" << threshold << " result_num=" << miner->result_size() << " time=" << miner->elapsed_time() << "s" << endl;
if (miner->result_size() == 0)
{
delete miner;
break;
}
delete miner;
}
for (int threshold = lower_bound; threshold <= upper_bound; threshold++)
{
Miner* miner = new MIWI(&D, threshold);
miner->mine();
miner->write_result(output);
cout << "MII: threshold=" << threshold << " result_num=" << miner->result_size() << " time=" << miner->elapsed_time() << "s" << endl;
delete miner;
}
output.close();
}
int main(int argc, const char * argv[])
{
//gen_dataset("/Users/jiyi/Documents/ut/lab/proj/data/mushroom.dat", -1, -1);
gen_dataset(argv[1], atoi(argv[2]), atoi(argv[3]));
return 0;
}