-
Notifications
You must be signed in to change notification settings - Fork 0
/
constraint.h
73 lines (59 loc) · 1.75 KB
/
constraint.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef CALCUDOKUSOLVER_CONSTRAINT_H
#define CALCUDOKUSOLVER_CONSTRAINT_H
#include <vector>
#include <memory>
#include "variable.h"
using std::vector;
using std::shared_ptr;
class CspSolver;
class Constraint {
public:
explicit Constraint(CspSolver & csp) : csp(csp) {}
virtual ~Constraint() = default;
virtual bool isSatisfied() = 0;
virtual void addVariable(int v);
vector<int> vars = vector<int>();
protected:
CspSolver & csp;
};
class AlldiffConstraint : public Constraint {
public:
explicit AlldiffConstraint(CspSolver & csp) : Constraint(csp) {}
bool isSatisfied() override;
};
class PlusConstraint : public Constraint {
public:
explicit PlusConstraint(CspSolver & csp, int target) : Constraint(csp), target(target) {}
bool isSatisfied() override;
private:
int target;
};
class MinusConstraint : public Constraint {
public:
explicit MinusConstraint(CspSolver & csp, int target) : Constraint(csp), target(target) {}
bool isSatisfied() override;
private:
int target;
};
class MultiplyConstraint : public Constraint {
public:
explicit MultiplyConstraint(CspSolver & csp, int target) : Constraint(csp), target(target) {}
bool isSatisfied() override;
private:
int target;
};
class DivideConstraint : public Constraint {
public:
explicit DivideConstraint(CspSolver & csp, int target) : Constraint(csp), target(target) {}
bool isSatisfied() override;
private:
int target;
};
class ModuloConstraint : public Constraint {
public:
explicit ModuloConstraint(CspSolver & csp, int target) : Constraint(csp), target(target) {}
bool isSatisfied() override;
private:
int target;
};
#endif //CALCUDOKUSOLVER_CONSTRAINT_H