~verifypn-maintainers/verifypn/u4.2

« back to all changes in this revision

Viewing changes to include/PetriEngine/Colored/EquivalenceClass.h

  • Committer: srba.jiri at gmail
  • Date: 2021-07-07 12:02:50 UTC
  • mfrom: (233.1.63 update-parser)
  • Revision ID: srba.jiri@gmail.com-20210707120250-f86fv0m9ycbge3qs
merged in lp:~tapaal-contributor/verifypn/update-parser improving CPN unfodling and refactoring the code, fixing parser

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef PARTITION_H
2
 
#define PARTITION_H
 
1
#ifndef EQUIVALENCECLASS_H
 
2
#define EQUIVALENCECLASS_H
3
3
 
4
4
#include "Intervals.h"
5
5
#include "Colors.h"
9
9
    namespace Colored {
10
10
        class EquivalenceClass {
11
11
            public:
12
 
                EquivalenceClass();
13
 
                EquivalenceClass(ColorType *colorType);
14
 
                EquivalenceClass(ColorType *colorType, intervalTuple_t colorIntervals);
 
12
                EquivalenceClass(uint32_t id);
 
13
                EquivalenceClass(uint32_t id, const ColorType *colorType);
 
14
                EquivalenceClass(uint32_t id, const ColorType *colorType, interval_vector_t&& colorIntervals);
15
15
                ~EquivalenceClass() {}
16
 
                std::string toString(){
17
 
                    std::cout << "Id: " << _id << std::endl;
 
16
                std::string toString() const{
18
17
                    return _colorIntervals.toString();
19
18
                }
20
19
 
21
 
                bool isEmpty(){
22
 
                    if(_colorIntervals.size() < 1 || _colorIntervals.getFirst().size() < 1){
 
20
                bool isEmpty() const{
 
21
                    if(_colorIntervals.size() < 1 || _colorIntervals.front().size() < 1){
23
22
                        return true;
24
23
                    } 
25
24
                    return false;
26
25
                }
27
26
 
28
 
                bool containsColor(std::vector<uint32_t> ids);
29
 
 
30
 
                size_t size();
31
 
 
32
 
                EquivalenceClass intersect(EquivalenceClass other);
33
 
 
34
 
                EquivalenceClass subtract(EquivalenceClass other, bool print);
35
 
 
36
 
                static uint32_t idCounter;
 
27
                bool containsColor(const std::vector<uint32_t> &ids, const std::vector<bool> &diagonalPositions) const;
 
28
 
 
29
                size_t size() const;
 
30
 
 
31
                EquivalenceClass intersect(uint32_t id, const EquivalenceClass &other) const;
 
32
 
 
33
                EquivalenceClass subtract(uint32_t id, const EquivalenceClass &other, const std::vector<bool> &diagonalPositions) const;
 
34
                
 
35
                uint32_t id() const { return _id; }
 
36
                const ColorType* type() const { return _colorType; }
 
37
                const interval_vector_t& intervals() const { return _colorIntervals; }
 
38
                void clear() { _colorIntervals.clear(); }
 
39
                void setIntervalVector(const interval_vector_t& interval) { _colorIntervals = interval; }
 
40
                void addInterval(interval_t&& interval) { _colorIntervals.addInterval(interval); }
 
41
            private:
37
42
                uint32_t _id;
38
 
                ColorType *_colorType;
39
 
                intervalTuple_t _colorIntervals;
40
 
 
41
 
            private:
 
43
                const ColorType *_colorType;
 
44
                interval_vector_t _colorIntervals;
42
45
 
43
46
            
44
47
        };
45
 
 
46
 
        struct EquivalenceVec{
47
 
            std::vector<EquivalenceClass> _equivalenceClasses;
48
 
            std::unordered_map<const Colored::Color *, EquivalenceClass *> colorEQClassMap;
49
 
            bool diagonal = false;
50
 
 
51
 
            void applyPartition(Colored::ArcIntervals& arcInterval){
52
 
                if(diagonal){
53
 
                    return;
54
 
                }
55
 
                std::vector<Colored::intervalTuple_t> newTupleVec;
56
 
                for(auto intervalTuple : arcInterval._intervalTupleVec){
57
 
                    intervalTuple.combineNeighbours();
58
 
                    intervalTuple_t newIntervalTuple;
59
 
                    for(auto interval : intervalTuple._intervals){
60
 
                        for(auto EQClass : _equivalenceClasses){
61
 
                            for(auto EQinterval : EQClass._colorIntervals._intervals){
62
 
                                auto overlap = interval.getOverlap(EQinterval);
63
 
                                if(overlap.isSound()){
64
 
                                    newIntervalTuple.addInterval(EQinterval.getSingleColorInterval());
65
 
                                    continue;
66
 
                                }
67
 
                            }
68
 
                        }
69
 
                    }
70
 
                   newTupleVec.push_back(std::move(newIntervalTuple));
71
 
                }
72
 
                arcInterval._intervalTupleVec = std::move(newTupleVec);               
73
 
            }
74
 
        };
75
 
 
76
48
    }
77
49
}
78
50
 
79
 
#endif /* PARTITION_H */
 
 
b'\\ No newline at end of file'
 
51
#endif /* EQUIVALENCECLASS_H */
 
 
b'\\ No newline at end of file'