-
Notifications
You must be signed in to change notification settings - Fork 1
/
Model.cc
57 lines (43 loc) · 1.09 KB
/
Model.cc
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
#include <algorithm>
#include "Model.hpp"
using std::any_of;
using std::move;
size_t Model::addComponent(Set<BVar> component)
{
size_t id = _componentList.size();
_componentList.push_back(move(component));
_componentMSS.emplace_back(); /*< initialize empty vector of MSS */
return id;
}
void Model::addMSS(size_t componentId, Set<BVar> mss)
{
_componentMSS[componentId].push_back(move(mss));
}
const Vector<Set<BVar>>& Model::allComponents() const
{
return _componentList;
}
const Vector<Set<BVar>>& Model::mssForComponent(size_t componentId) const
{
return _componentMSS[componentId];
}
size_t Model::componentCount() const
{
return _componentList.size();
}
size_t Model::mssCount() const
{
size_t count = 0;
for (const Vector<Set<BVar>>& mssList : _componentMSS)
{
count += mssList.size();
}
return count;
}
bool Model::alreadyCovered(size_t componentId, const Set<BVar>& s)
{
auto isSuperset = [&s] (const Set<BVar>& mss) { return isSubset(s, mss); };
return any_of(_componentMSS[componentId].begin(),
_componentMSS[componentId].end(),
isSuperset);
}