-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrule.hpp
72 lines (54 loc) · 2.16 KB
/
rule.hpp
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
// Author: Kristi Daigh
// Project: MLEM2 Rule Induction
// Date: 11/20/2019
/** Header file for the rule class.
@file rule.hpp */
#ifndef RULE_H
#define RULE_H
#include "av.hpp"
#include <set>
#include <string>
#include <vector>
#define DEBUG false
class Rule {
/* Global to track current ID. */
static int idCount;
public:
/* Constructs new rule with unique ID. */
Rule();
/* Adds (the index of) a single condition from the rule. */
void addCondition(int index);
/* Removes (the index of) a single condition from the rule. */
void removeCondition(int index);
/* Checks for the occurence of (the index of) a condition in the rule.
@returns True if the condition is found; False, otherwise. */
bool containsCondition(int index) const;
/* Updates (or sets) conditions. */
void setConditions(std::set<int> conditions);
/* Returns set of (indices of) selected conditions. */
std::set<int> getConditions() const;
/* Retrieves the intersection of all attribute-value pairs in the rule.
@param avBlocks, array of attribute-value blocks. */
std::set<int> getBlock(std::vector<AV *> avBlocks) const;
/* Retrieves the intersections of all conditions with the same attribute as given condition. */
std::set<int> getAttributeGroup(std::vector<AV *> avBlocks, int index) const;
/* Optimize rule by merging intervals.
@param avBlocks, array of attribute-value blocks.*/
void mergeIntervals(std::vector<AV *> avBlocks);
/* Optimizes rule by linearly dropping unnecessary conditions.
@param B, set for the concept. */
void dropConditions(std::vector<AV *> avBlocks, std::set<int> B);
/* Converts rule to string, with format (A1, V1) & ... & (AN, VN). */
std::string toString(std::vector<AV *> avBlocks) const;
/* Gets number of conditions. */
std::size_t size() const;
/* Checks if rule is empty (i.e. has no conditions). */
bool empty() const;
/* Unique identifier for the rule. */
const int id;
/* Set of indices of selected conditions for rule. */
std::set<int> m_conditions;
private:
// TODO: move m_conditions here
};
#endif