3.2.11.2. causality/DGPetri.hpp¶
3.2.11.2.1. Class causality::DGPetriNet
¶
-
class causality::DGPetriNet¶
Adaptation of a derivation graph into a Petri net. Importantly, if the underlying derivation graph is enlarged then
syncSize()
must be called before calling certain other methods on the object.
3.2.11.2.1.1. Synopsis¶
-
std::shared_ptr<dg::DG> getDG() const
-
friend std::ostream &operator<<(std::ostream &s, const DGPetriNet &net)
-
void syncSize()
-
std::vector<dg::DG::Vertex> getPostPlaces(dg::DG::HyperEdge e) const
-
static std::shared_ptr<DGPetriNet> make(std::shared_ptr<dg::DG> dg_)
3.2.11.2.1.2. Details¶
-
friend std::ostream &operator<<(std::ostream &s, const DGPetriNet &net)¶
-
void syncSize()¶
Enlarges the internal data structures to the current size of the underlying derivation graph.
-
std::vector<dg::DG::Vertex> getPostPlaces(dg::DG::HyperEdge e) const¶
- Returns
a list of unique targets for the given hyperedge.
Requires
syncSize()
to have been called since the last time the underlying derivation graph has changed size.
Calls
syncSize()
.- Returns
a new Petri net, adapting the given derivation graph.
- Throws
LogicError
if dg_ is null.- Throws
LogicError
if neither dg_->hasActiveBuilder() nor dg_->isLocked().
3.2.11.2.2. Class causality::DGPetriNetMarking
¶
-
class causality::DGPetriNetMarking¶
Representation of a marking on a Petri net. Importantly, if the underlying derivation graph is enlarged then
syncSize()
must be called before calling certain other methods on the object.
3.2.11.2.2.1. Synopsis¶
-
explicit DGPetriNetMarking(std::shared_ptr<DGPetriNet> net)
-
std::shared_ptr<DGPetriNet> getNet() const
-
void syncSize() const
-
friend std::ostream &operator<<(std::ostream &s, const DGPetriNetMarking &m)
-
friend bool operator==(const DGPetriNetMarking &a, const DGPetriNetMarking &b)
-
friend bool operator!=(const DGPetriNetMarking &a, const DGPetriNetMarking &b)
-
int add(dg::DG::Vertex v, int c)
-
int remove(dg::DG::Vertex v, int c)
-
int operator[](dg::DG::Vertex v)
-
int getNumTokens() const
-
std::vector<dg::DG::HyperEdge> getAllEnabled() const
-
std::vector<dg::DG::Vertex> getNonZeroPlaces() const
-
std::vector<dg::DG::Vertex> getEmptyPostPlaces(dg::DG::HyperEdge e) const
-
bool isEnabled(dg::DG::HyperEdge e) const
-
void fire(dg::DG::HyperEdge e)
3.2.11.2.2.2. Details¶
- Throws
LogicError
if net is null.
-
std::shared_ptr<DGPetriNet> getNet() const¶
- Returns
the underlying Petri net.
-
void syncSize() const¶
Enlarges the internal data structures to the current size of the underlying derivation graph.
Calls getNet().syncSize().
-
friend std::ostream &operator<<(std::ostream &s, const DGPetriNetMarking &m)¶
Calls syncSize().
-
friend bool operator==(const DGPetriNetMarking &a, const DGPetriNetMarking &b)¶
-
friend bool operator!=(const DGPetriNetMarking &a, const DGPetriNetMarking &b)¶
-
int add(dg::DG::Vertex v, int c)¶
-
- Returns
the new total token count on v.
- Throws
LogicError
if !v.- Throws
LogicError
if v.getDG() != getNet()->getDG().- Throws
LogicError
if c < 0.
Requires
syncSize()
to have been called since the last time the underlying derivation graph has changed size.
-
int remove(dg::DG::Vertex v, int c)¶
Remove c tokens from the place v.
- Returns
the new total token count on v.
- Throws
LogicError
if !v.- Throws
LogicError
if v.getDG() != getNet()->getDG().- Throws
LogicError
if c < 0.- Throws
LogicError
if not enough tokens are left to remove all c.
Requires
syncSize()
to have been called since the last time the underlying derivation graph has changed size.
-
int operator[](dg::DG::Vertex v)¶
- Returns
the token count for v.
- Throws
LogicError
if !v.- Throws
LogicError
if v.getDG() != getNet()->getDG().
Requires
syncSize()
to have been called since the last time the underlying derivation graph has changed size.
-
int getNumTokens() const¶
- Returns
the total number of tokens in the marking.
-
std::vector<dg::DG::HyperEdge> getAllEnabled() const¶
- Returns
a list of all hyperedges currently enabled for firing.
-
std::vector<dg::DG::Vertex> getEmptyPostPlaces(dg::DG::HyperEdge e) const¶
- Returns
a list of all target vertices of the given hyperedge that do not have any tokens. The list represents a set, so if vertex is a target multiple times it will only be included once.
- Throws
LogicError
if !e.- Throws
LogicError
if e.getDG() != getNet()->getDG().
-
bool isEnabled(dg::DG::HyperEdge e) const¶
- Returns
whether the given hyperedge is enabled for firing.
- Throws
LogicError
if !e.- Throws
LogicError
if e.getDG() != getNet()->getDG().
-
void fire(dg::DG::HyperEdge e)¶
Fire the given edge.
- Throws
LogicError
if !e.- Throws
LogicError
if e.getDG() != getNet()->getDG().- Throws
LogicError
if !isEnabled(e).