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>,
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26
namespace PetriEngine{
30
class AssignmentExpression;
37
class PetriNetBuilder;
39
/** Type used for holding markings values */
41
/** Type used for holding variable values */
44
#define MARK_INF INT_MAX
46
/** Efficient representation of PetriNet */
49
PetriNet(int places, int transitions, int variables);
52
/** Fire transition if possible and store result in result */
53
bool fire(unsigned int transition,
54
const MarkVal* marking,
55
const VarVal* assignment,
56
MarkVal* resultMarking,
57
VarVal* resultAssignment) const;
58
bool fire(unsigned int transition, const Structures::State* s, Structures::State* ns, int multiplicity = 1, int kbound = 0) const;
59
/** Fire without checkings conditions */
60
void fireWithoutCheck(unsigned int transition,
61
const MarkVal* marking,
62
const VarVal* assignment,
63
MarkVal* resultMarking,
64
VarVal* resultAssignment,
65
int multiplicity = 1) const;
66
/** Fire transition if possible and store result in result (Respect MARK_INF */
67
bool fireWithMarkInf(unsigned int transition,
68
const MarkVal* marking,
69
const VarVal* assignment,
70
MarkVal* resultMarking,
71
VarVal* resultAssignment) const;
72
unsigned int numberOfTransitions() const {return _nTransitions;}
73
unsigned int numberOfVariables() const {return _nVariables;}
74
unsigned int numberOfPlaces() const {return _nPlaces;}
75
int inArc(unsigned int place, unsigned int transition) const;
76
int outArc(unsigned int transition, unsigned int place) const;
77
/** Get vector place names, don't use this to get the number of places */
78
const std::vector<std::string>& placeNames() const {return _places;}
79
/** Get vector variable names, don't use this to get the number of variable */
80
const std::vector<std::string>& variableNames() const {return _variables;}
81
/** Get vector transition names, don't use this to get the number of variable */
82
const std::vector<std::string>& transitionNames() const {return _transitions;}
84
std::vector<std::string> _places;
85
std::vector<std::string> _transitions;
86
std::vector<std::string> _variables;
87
/** Number of x variables
88
* @remarks We could also get this from the _places vector, but I don't see any
89
* any complexity garentees for this type.
91
size_t _nPlaces, _nTransitions, _nVariables;
92
/** Transition matrix, see transition vector */
94
/** Get a transition vector
95
* @remarks On form [p1-][p2-]...[p1+][p2+]...
96
* where p1- is number of tokens to be taken from p1.
97
* and p1+ is the number of tokens to given to p1.
99
const MarkVal* _tv(unsigned int t) const {return _tm + t * _nPlaces * 2;}
100
MarkVal* _tv(unsigned int t) {return _tm + t * _nPlaces * 2;}
103
PQL::Condition** _conditions;
104
PQL::AssignmentExpression** _assignments;
105
friend class PetriNetBuilder;