def loop_requirement(t1, t2): if t1 == t2: return False for p in pn_util.pre_set(t2): if len(pn_util.pre_set(p)) != 1: # check that the preset of the t2 preset has one entry return False if t1 not in pn_util.pre_set(p): # check that t1 is the unique way to mark the preset of t2 return False for p in pn_util.post_set(t2): if len(pn_util.post_set(p)) != 1: return False if t1 not in pn_util.post_set(p): return False for p in pn_util.pre_set(t1): if len(pn_util.post_set(p)) != 1: return False if t1 not in pn_util.post_set(p): return False if t2 not in pn_util.pre_set(p): # t2 has to enable t1! return False for p in pn_util.post_set(t1): if len(pn_util.pre_set(p)) != 1: # check that the preset of the t2 preset has one entry return False if t1 not in pn_util.pre_set(p): # check that t1 is the unique way to mark the preset of t2 return False if t2 not in pn_util.post_set(p): return False return True
def sequence_requirement(t1, t2): if t1 == t2: return False if len(pn_util.pre_set(t2)) == 0: return False for p in pn_util.post_set(t1): if len(pn_util.pre_set(p)) != 1 or len(pn_util.post_set(p)) != 1: return False if t1 not in pn_util.pre_set(p): return False if t2 not in pn_util.post_set(p): return False for p in pn_util.pre_set(t2): if len(pn_util.pre_set(p)) != 1 or len(pn_util.post_set(p)) != 1: return False if t1 not in pn_util.pre_set(p): return False if t2 not in pn_util.post_set(p): # redundant check, just to be sure... return False return True
def _get_src_transition(sub_net): for t in sub_net.transitions: if len(pn_util.pre_set(t)) == 0: return t return None
def concurrent_requirement(t1, t2): if t1 == t2: # check if transitions different return False if len(pn_util.pre_set(t1)) == 0 or len(pn_util.post_set(t1)) == 0 or len(pn_util.pre_set(t2)) == 0 or len( pn_util.post_set(t2)) == 0: # not possible in WF-net, just checking... return False pre_pre = set() post_post = set() for p in pn_util.pre_set(t1): # check if t1 is unique post of its preset pre_pre = set.union(pre_pre, pn_util.pre_set(p)) if len(pn_util.post_set(p)) > 1 or t1 not in pn_util.post_set(p): return False for p in pn_util.post_set(t1): # check if t1 is unique pre of its postset post_post = set.union(post_post, pn_util.post_set(p)) if len(pn_util.pre_set(p)) > 1 or t1 not in pn_util.pre_set(p): return False for p in pn_util.pre_set(t2): # check if t2 is unique post of its preset pre_pre = set.union(pre_pre, pn_util.pre_set(p)) if len(pn_util.post_set(p)) > 1 or t2 not in pn_util.post_set(p): return False for p in pn_util.post_set(t2): # check if t2 is unique pre of its postset post_post = set.union(post_post, pn_util.post_set(p)) if len(pn_util.pre_set(p)) > 1 or t2 not in pn_util.pre_set(p): return False for p in set.union(pn_util.pre_set(t1), pn_util.pre_set(t2)): # check if presets synchronize for t in pre_pre: if t not in pn_util.pre_set(p): return False for p in set.union(pn_util.post_set(t1), pn_util.post_set(t2)): # check if postsets synchronize for t in post_post: if t not in pn_util.post_set(p): return False return True
def choice_requirement(t1, t2): return t1 != t2 and pn_util.pre_set(t1) == pn_util.pre_set(t2) and pn_util.post_set(t1) == pn_util.post_set( t2) and len(pn_util.pre_set(t1)) > 0 and len( pn_util.post_set(t1)) > 0