1
/* PeTe - Petri Engine exTremE
2
* Copyright (C) 2011 Jonas Finnemann Jensen <jopsen@gmail.com>,
3
* Thomas Søndersø Nielsen <primogens@gmail.com>,
4
* Lars Kærlund Østergaard <larsko@gmail.com>,
5
* Peter Gjøl Jensen <root@petergjoel.dk>
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
29
namespace PetriEngine {
35
namespace Structures {
39
class PetriNetBuilder;
40
class SuccessorGenerator;
52
// we can pack things here, but might give slowdown
53
} /*__attribute__((packed))*/;
55
/** Type used for holding markings values */
56
typedef uint32_t MarkVal;
58
/** Efficient representation of PetriNet */
60
PetriNet(uint32_t transitions, uint32_t invariants, uint32_t places);
64
uint32_t initial(size_t id) const;
65
MarkVal* makeInitialMarking() const;
66
/** Fire transition if possible and store result in result */
67
bool deadlocked(const MarkVal* marking) const;
68
bool fireable(const MarkVal* marking, int transitionIndex);
69
std::pair<const Invariant*, const Invariant*> preset(uint32_t id) const;
70
std::pair<const Invariant*, const Invariant*> postset(uint32_t id) const;
71
uint32_t numberOfTransitions() const {
75
uint32_t numberOfPlaces() const {
78
int inArc(uint32_t place, uint32_t transition) const;
79
int outArc(uint32_t transition, uint32_t place) const;
82
const std::vector<std::string>& transitionNames() const
84
return _transitionnames;
87
const std::vector<std::string>& placeNames() const
92
void print(MarkVal const * const val) const
94
for(size_t i = 0; i < _nplaces; ++i)
98
std::cout << _placenames[i] << "(" << i << ")" << " -> " << val[i] << std::endl;
105
void toXML(std::ostream& out);
107
const MarkVal* initial() const {
108
return _initialMarking;
113
/** Number of x variables
114
* @remarks We could also get this from the _places vector, but I don't see any
115
* any complexity garentees for this type.
117
uint32_t _ninvariants, _ntransitions, _nplaces;
119
std::vector<TransPtr> _transitions;
120
std::vector<Invariant> _invariants;
121
std::vector<uint32_t> _placeToPtrs;
122
MarkVal* _initialMarking;
124
std::vector<std::string> _transitionnames;
125
std::vector<std::string> _placenames;
127
friend class PetriNetBuilder;
128
friend class Reducer;
129
friend class SuccessorGenerator;
130
friend class ReducingSuccessorGenerator;
131
friend class STSolver;