-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rule.h
50 lines (40 loc) · 1.53 KB
/
Rule.h
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
#ifndef RULE_H
#define RULE_H
#include <vector>
#include <unordered_map>
#include <string>
#include <memory>
/* Represents a Literal */
typedef int Literal;
struct Rule {
enum RuleType { BASIC, CHOICE, CONSTRAINT, WEIGHTCONSTRAINT };
virtual RuleType getType() const = 0;
};
struct BasicRule: public Rule {
BasicRule(const Literal h, const std::vector<Literal>& p, const std::vector<Literal>& n) : head(h), positiveBody(p), negativeBody(n) {};
RuleType getType() const {return BASIC;};
Literal head;
std::vector<Literal> positiveBody;
std::vector<Literal> negativeBody;
};
struct ChoiceRule: public Rule {
ChoiceRule(const std::vector<Literal>& h, const std::vector<Literal>& p, const std::vector<Literal>& n) : head(h), positiveBody(p), negativeBody(n) {};
RuleType getType() const {return CHOICE;};
std::vector<Literal> head;
std::vector<Literal> positiveBody;
std::vector<Literal> negativeBody;
};
struct ConstraintRule: public Rule {
ConstraintRule(const std::vector<Literal>& p, const std::vector<Literal>& n) : positiveBody(p), negativeBody(n) {};
RuleType getType() const {return CONSTRAINT;};
std::vector<Literal> positiveBody;
std::vector<Literal> negativeBody;
};
struct WeightRule: public Rule {
WeightRule(const std::unordered_map<Literal, long>& b, const long l) : positiveBody(b), upperLimit(l) {};
RuleType getType() const {return WEIGHTCONSTRAINT;};
std::unordered_map<Literal, long> positiveBody;
long upperLimit;
};
typedef std::shared_ptr<Rule> Rule_ptr;
#endif //RULE_H