-
Notifications
You must be signed in to change notification settings - Fork 0
/
policytree.cpp
58 lines (55 loc) · 1.97 KB
/
policytree.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
// C header files
#include <string>
#include <unordered_map>
// User-defined header files
#include "class_definitions.h"
#include "msp_functions.h"
// unordered_map<string,int> OpType = {
// {"OR",0},
// {"AND",1},
// {"ATTR",2},
// {"THRESHOLD",3},
// {"CONDITIONAL",4},
// {"NONE",5}
// };
int main(){
//string line= "((((ONE OR THREE) AND (FOUR AND FIVE)) OR ((TWO AND FOUR) AND (ONE OR TWO))) AND((ONE OR TWO) AND ((THREE OR FIVE) AND (TWO OR FOUR))))";
string line = "(((ONE and THREE) and (TWO OR FOUR)) or (THREE and FOUR))";
PolicyParser parser = PolicyParser();
BinNode *root = parser.parse(line);
// walkThrough(root, "", true);
MSP msp = MSP();
BinNode *policy = msp.createPolicy(line);
// walkThrough(policy, "", true);
unordered_map<string, vector<int>> mono_span_prog = msp.convertPolicyToMSP(policy);
int num_cols = msp.len_longest_row;
// for(auto i: mono_span_prog){
// cout<<i.first<<" ";
// for(auto j: i.second)
// cout<<j<<" ";
// cout<<endl;
// }
// cout<<endl<<endl;
vector<string> attrList = msp.getAttributeList(policy);
// for(auto i: attrList)
// cout<<i<<endl;
vector<string> attrList2{"ONE", "TWO", "THREE","FOUR"};
vector<BinNode*> prunedPolicy = msp.prune(policy, attrList2);
// for(auto i: prunedPolicy)
// cout<<i->getAttribute()<<endl;
// cout<<endl<<endl;
attrList2 = {"TWO", "THREE","FOUR"};
prunedPolicy = msp.prune(policy, attrList2);
for(auto i: prunedPolicy)
cout<<i->getAttribute()<<endl;
// attrList2 = {"ONE", "TWO", "THREE","FOUR", "FIVE"};
// prunedPolicy = msp.prune(policy, attrList2);
// for(auto i: prunedPolicy)
// cout<<i->getAttribute()<<endl;
// cout<<endl<<endl;
// attrList2 = {"TWO", "THREE","FOUR", "FIVE"};
// prunedPolicy = msp.prune(policy, attrList2);
// for(auto i: prunedPolicy)
// cout<<i->getAttribute()<<endl;
// cout<<endl<<endl;
}