7
7
namespace Simplification {
9
9
class LinearPrograms {
11
std::vector<LinearProgram> lps;
12
bool hasEmpty = false;
13
LinearPrograms(const LinearProgram& lp){
17
LinearPrograms(LinearPrograms&& other)
18
: lps(std::move(other.lps)), hasEmpty(other.hasEmpty)
23
LinearPrograms& operator = (LinearPrograms&& other)
25
lps = std::move(other.lps);
26
hasEmpty = other.hasEmpty;
16
30
virtual ~LinearPrograms(){
18
std::vector<LinearProgram> lps;
20
size_t sizeInBytes() {
22
for (auto &lp : lps) {
23
content += lp.sizeInBytes();
25
return sizeof(std::vector<LinearProgram>) + content;
28
33
bool satisfiable(const PetriEngine::PetriNet* net, const PetriEngine::MarkVal* m0, uint32_t timeout) {
34
if(hasEmpty) return true;
29
35
for(uint32_t i = 0; i < lps.size(); i++){
30
36
if(!lps[i].isImpossible(net, m0, timeout)){
37
void add(const LinearProgram& lp){
41
static LinearPrograms lpsMerge(LinearPrograms& lps1, LinearPrograms& lps2){
42
if (lps1.lps.size() == 0) {
47
void add(const LinearProgram&& lp){
54
lps.push_back(std::move(lp));
58
void add(Equation&& eq){
59
lps.emplace_back(std::move(eq));
63
* Merges two linear programs, this invalidates lps2 to restrict
64
* temporary memory-overhead.
67
void merge(LinearPrograms& lps2){
68
if (lps.size() == 0) {
45
72
else if (lps2.lps.size() == 0) {
50
for(LinearProgram& lp1 : lps1.lps){
76
std::vector<LinearProgram> merged;
77
merged.reserve(lps.size() * lps2.lps.size());
78
for(LinearProgram& lp1 : lps){
51
79
for(LinearProgram& lp2 : lps2.lps){
52
res.add(LinearProgram::lpUnion(lp1, lp2));
80
merged.push_back(LinearProgram::lpUnion(lp1, lp2));
85
size_t osize = merged.size();
86
merged.resize(merged.size() + lps.size());
87
for(size_t i = 0; i < lps.size(); ++i)
88
merged[osize + i].swap(lps[i]);
92
size_t osize = merged.size();
93
merged.resize(merged.size() + lps2.size());
94
for(size_t i = 0; i < lps2.size(); ++i)
95
merged[osize + i].swap(lps2.lps[i]);
99
hasEmpty = hasEmpty && lps2.hasEmpty;
58
static LinearPrograms lpsUnion(LinearPrograms& lps1, LinearPrograms& lps2){
60
for(LinearProgram& lp : lps1.lps){
63
for(LinearProgram& lp : lps2.lps){
104
* Unions two linear programs, this invalidates lps2 to restrict
105
* temporary memory-overhead.
108
void makeUnion(LinearPrograms& lps2)
110
// move data, dont copy!
111
size_t osize = lps.size();
112
lps.resize(lps.size() + lps2.lps.size());
113
for(size_t i = 0; i < lps2.size(); ++i)
115
lps[osize + i].swap(lps2.lps[i]);
118
hasEmpty = hasEmpty || lps2.hasEmpty;
72
#endif /* LINEARPROGRAMS_H */
b'\\ No newline at end of file'
129
#endif /* LINEARPROGRAMS_H */