Removed sequential net; adjusted naming from conformative to normative

This commit is contained in:
Nora Wickelmaier 2024-03-22 11:12:41 +01:00
parent c0b24a03aa
commit b762968774

View File

@ -1,18 +1,14 @@
# 03_create-petrinet.py # 03_create-petrinet.py
# #
# content: (1) Create places and transitions # content: (1) Create places and transitions
# (2) Sequential net # (2) Normative net
# (3) Concurrent net
# #
# input: -- # input: --
# output: results/haum/conformative_petrinet_con.pnml # output: results/normative_petrinet.pnml
# results/processmaps/conformative_petrinet_con.png # results/processmaps/normative_petrinet.png
# results/processmaps/conformative_bpmn_con.png # results/processmaps/normative_bpmn.png
# results/haum/conformative_petrinet_seq.pnml
# results/processmaps/conformative_petrinet_seq.png
# results/processmaps/conformative_bpmn_seq.png
# #
# last mod: 2024-03-06 # last mod: 2024-03-22
import pm4py import pm4py
from pm4py.objects.petri_net.obj import PetriNet, Marking from pm4py.objects.petri_net.obj import PetriNet, Marking
@ -62,93 +58,90 @@ t_16 = PetriNet.Transition("t_16")
t_17 = PetriNet.Transition("t_17") t_17 = PetriNet.Transition("t_17")
t_18 = PetriNet.Transition("t_18") t_18 = PetriNet.Transition("t_18")
#--------------- (2) Sequential net --------------- #--------------- (2) Normative net ---------------
net_seq = PetriNet("new_petri_net") net = PetriNet("new_petri_net")
# Add places # Add places
net_seq.places.add(source) net.places.add(source)
net_seq.places.add(sink) net.places.add(sink)
net_seq.places.add(p_1) net.places.add(p_1)
net_seq.places.add(p_2) net.places.add(p_2)
net_seq.places.add(p_3) net.places.add(p_3)
net_seq.places.add(p_4) net.places.add(p_4)
net_seq.places.add(p_5) net.places.add(p_5)
net_seq.places.add(p_6) net.places.add(p_6)
net_seq.places.add(p_7) net.places.add(p_7)
net_seq.places.add(p_8) net.places.add(p_8)
net.places.add(p_9)
net.places.add(p_10)
net.places.add(p_11)
net.places.add(p_12)
# Add transitions # Add transitions
net_seq.transitions.add(mv) net.transitions.add(mv)
net_seq.transitions.add(fc) net.transitions.add(fc)
net_seq.transitions.add(ot) net.transitions.add(ot)
net_seq.transitions.add(op) net.transitions.add(op)
# Add hidden transitions # Add hidden transitions
net_seq.transitions.add(t_1) net.transitions.add(t_1)
net_seq.transitions.add(t_2) net.transitions.add(t_2)
net_seq.transitions.add(t_3) net.transitions.add(t_3)
net_seq.transitions.add(t_4) net.transitions.add(t_4)
net_seq.transitions.add(t_5) net.transitions.add(t_5)
net_seq.transitions.add(t_6) net.transitions.add(t_6)
net_seq.transitions.add(t_7) net.transitions.add(t_7)
net_seq.transitions.add(t_8) net.transitions.add(t_8)
net_seq.transitions.add(t_9) net.transitions.add(t_9)
net_seq.transitions.add(t_10) net.transitions.add(t_10)
net_seq.transitions.add(t_11) net.transitions.add(t_11)
net_seq.transitions.add(t_12) net.transitions.add(t_12)
net_seq.transitions.add(t_13) net.transitions.add(t_13)
net_seq.transitions.add(t_14) net.transitions.add(t_14)
net_seq.transitions.add(t_15) net.transitions.add(t_15)
net_seq.transitions.add(t_16)
net_seq.transitions.add(t_17)
net_seq.transitions.add(t_18)
# Add arcs # Add arcs
petri_utils.add_arc_from_to(source, t_1, net_seq) petri_utils.add_arc_from_to(source, t_1, net)
petri_utils.add_arc_from_to(source, t_2, net_seq) petri_utils.add_arc_from_to(t_1, p_1, net)
petri_utils.add_arc_from_to(t_1, p_1, net_seq) petri_utils.add_arc_from_to(t_1, p_2, net)
petri_utils.add_arc_from_to(t_2, p_2, net_seq) petri_utils.add_arc_from_to(p_1, t_2, net)
petri_utils.add_arc_from_to(p_1, mv, net_seq) petri_utils.add_arc_from_to(p_1, t_3, net)
petri_utils.add_arc_from_to(p_2, fc, net_seq) petri_utils.add_arc_from_to(t_3, p_5, net)
petri_utils.add_arc_from_to(mv, p_3, net_seq) petri_utils.add_arc_from_to(t_2, p_3, net)
petri_utils.add_arc_from_to(p_3, t_3, net_seq) petri_utils.add_arc_from_to(p_3, mv, net)
petri_utils.add_arc_from_to(p_3, t_4, net_seq) petri_utils.add_arc_from_to(mv, p_4, net)
petri_utils.add_arc_from_to(p_3, t_5, net_seq) petri_utils.add_arc_from_to(p_4, t_5, net)
petri_utils.add_arc_from_to(p_3, t_6, net_seq) petri_utils.add_arc_from_to(p_4, t_6, net)
petri_utils.add_arc_from_to(p_3, t_7, net_seq) petri_utils.add_arc_from_to(t_6, p_3, net)
petri_utils.add_arc_from_to(t_7, p_1, net_seq) petri_utils.add_arc_from_to(t_5, p_5, net)
petri_utils.add_arc_from_to(fc, p_4, net_seq) petri_utils.add_arc_from_to(p_5, t_15, net)
petri_utils.add_arc_from_to(p_4, t_8, net_seq) petri_utils.add_arc_from_to(t_15, sink, net)
petri_utils.add_arc_from_to(p_4, t_9, net_seq) petri_utils.add_arc_from_to(p_2, fc, net)
petri_utils.add_arc_from_to(p_4, t_10, net_seq) petri_utils.add_arc_from_to(p_2, t_8, net)
petri_utils.add_arc_from_to(t_9, p_1, net_seq) petri_utils.add_arc_from_to(t_8, p_12, net)
petri_utils.add_arc_from_to(t_16, p_5, net_seq) petri_utils.add_arc_from_to(p_12, t_15, net)
petri_utils.add_arc_from_to(t_3, p_2, net_seq) petri_utils.add_arc_from_to(fc, p_6, net)
petri_utils.add_arc_from_to(t_5, p_6, net_seq) petri_utils.add_arc_from_to(p_6, t_9, net)
petri_utils.add_arc_from_to(t_6, p_5, net_seq) petri_utils.add_arc_from_to(t_9, p_12, net)
petri_utils.add_arc_from_to(p_6, ot, net_seq) petri_utils.add_arc_from_to(p_6, t_4, net)
petri_utils.add_arc_from_to(p_5, op, net_seq) petri_utils.add_arc_from_to(t_4, p_7, net)
petri_utils.add_arc_from_to(ot, p_8, net_seq) petri_utils.add_arc_from_to(p_7, ot, net)
petri_utils.add_arc_from_to(op, p_7, net_seq) petri_utils.add_arc_from_to(ot, p_8, net)
petri_utils.add_arc_from_to(p_8, t_11, net_seq) petri_utils.add_arc_from_to(p_8, t_10, net)
petri_utils.add_arc_from_to(p_8, t_12, net_seq) petri_utils.add_arc_from_to(t_10, p_11, net)
petri_utils.add_arc_from_to(p_8, t_13, net_seq) petri_utils.add_arc_from_to(p_11, t_13, net)
petri_utils.add_arc_from_to(p_8, t_17, net_seq) petri_utils.add_arc_from_to(t_13, p_12, net)
petri_utils.add_arc_from_to(t_10, p_6, net_seq) petri_utils.add_arc_from_to(p_8, t_7, net)
petri_utils.add_arc_from_to(t_17, p_6, net_seq) petri_utils.add_arc_from_to(t_7, p_9, net)
petri_utils.add_arc_from_to(p_7, t_14, net_seq) petri_utils.add_arc_from_to(p_9, op, net)
petri_utils.add_arc_from_to(p_7, t_15, net_seq) petri_utils.add_arc_from_to(op, p_10, net)
petri_utils.add_arc_from_to(p_7, t_16, net_seq) petri_utils.add_arc_from_to(p_10, t_11, net)
petri_utils.add_arc_from_to(p_7, t_18, net_seq) petri_utils.add_arc_from_to(p_10, t_12, net)
petri_utils.add_arc_from_to(t_18, p_6, net_seq) petri_utils.add_arc_from_to(t_12, p_9, net)
petri_utils.add_arc_from_to(t_13, p_5, net_seq) petri_utils.add_arc_from_to(t_11, p_11, net)
petri_utils.add_arc_from_to(t_15, p_1, net_seq) petri_utils.add_arc_from_to(p_11, t_14, net)
petri_utils.add_arc_from_to(t_11, p_1, net_seq) petri_utils.add_arc_from_to(t_14, p_7, net)
petri_utils.add_arc_from_to(t_4, sink, net_seq)
petri_utils.add_arc_from_to(t_8, sink, net_seq)
petri_utils.add_arc_from_to(t_12, sink, net_seq)
petri_utils.add_arc_from_to(t_14, sink, net_seq)
# Add tokens # Add tokens
initial_marking = Marking() initial_marking = Marking()
@ -156,116 +149,14 @@ initial_marking[source] = 1
final_marking = Marking() final_marking = Marking()
final_marking[sink] = 1 final_marking[sink] = 1
pm4py.view_petri_net(net_seq, initial_marking, final_marking) pm4py.view_petri_net(net, initial_marking, final_marking)
pm4py.write_pnml(net_seq, initial_marking, final_marking, "results/haum/conformative_petrinet_seq.pnml") pm4py.write_pnml(net, initial_marking, final_marking,
"results/normative_petrinet.pnml")
pm4py.vis.save_vis_petri_net(net_seq, initial_marking, final_marking, pm4py.vis.save_vis_petri_net(net, initial_marking, final_marking,
"results/processmaps/conformative_petrinet_seq.png") "results/processmaps/normative_petrinet.png")
bpmn = pm4py.convert.convert_to_bpmn(net_seq, initial_marking, final_marking) bpmn = pm4py.convert.convert_to_bpmn(net, initial_marking, final_marking)
pm4py.view_bpmn(bpmn) pm4py.view_bpmn(bpmn)
pm4py.vis.save_vis_bpmn(bpmn, "results/processmaps/conformative_bpmn_seq.png") pm4py.vis.save_vis_bpmn(bpmn, "results/processmaps/normative_bpmn.png")
#--------------- (3) Concurrent net ---------------
net_con = PetriNet("new_petri_net")
# Add places
net_con.places.add(source)
net_con.places.add(sink)
net_con.places.add(p_1)
net_con.places.add(p_2)
net_con.places.add(p_3)
net_con.places.add(p_4)
net_con.places.add(p_5)
net_con.places.add(p_6)
net_con.places.add(p_7)
net_con.places.add(p_8)
net_con.places.add(p_9)
net_con.places.add(p_10)
net_con.places.add(p_11)
net_con.places.add(p_12)
# Add transitions
net_con.transitions.add(mv)
net_con.transitions.add(fc)
net_con.transitions.add(ot)
net_con.transitions.add(op)
# Add hidden transitions
net_con.transitions.add(t_1)
net_con.transitions.add(t_2)
net_con.transitions.add(t_3)
net_con.transitions.add(t_4)
net_con.transitions.add(t_5)
net_con.transitions.add(t_6)
net_con.transitions.add(t_7)
net_con.transitions.add(t_8)
net_con.transitions.add(t_9)
net_con.transitions.add(t_10)
net_con.transitions.add(t_11)
net_con.transitions.add(t_12)
net_con.transitions.add(t_13)
net_con.transitions.add(t_14)
net_con.transitions.add(t_15)
# Add arcs
petri_utils.add_arc_from_to(source, t_1, net_con)
petri_utils.add_arc_from_to(t_1, p_1, net_con)
petri_utils.add_arc_from_to(t_1, p_2, net_con)
petri_utils.add_arc_from_to(p_1, t_2, net_con)
petri_utils.add_arc_from_to(p_1, t_3, net_con)
petri_utils.add_arc_from_to(t_3, p_5, net_con)
petri_utils.add_arc_from_to(t_2, p_3, net_con)
petri_utils.add_arc_from_to(p_3, mv, net_con)
petri_utils.add_arc_from_to(mv, p_4, net_con)
petri_utils.add_arc_from_to(p_4, t_5, net_con)
petri_utils.add_arc_from_to(p_4, t_6, net_con)
petri_utils.add_arc_from_to(t_6, p_3, net_con)
petri_utils.add_arc_from_to(t_5, p_5, net_con)
petri_utils.add_arc_from_to(p_5, t_15, net_con)
petri_utils.add_arc_from_to(t_15, sink, net_con)
petri_utils.add_arc_from_to(p_2, fc, net_con)
petri_utils.add_arc_from_to(p_2, t_8, net_con)
petri_utils.add_arc_from_to(t_8, p_12, net_con)
petri_utils.add_arc_from_to(p_12, t_15, net_con)
petri_utils.add_arc_from_to(fc, p_6, net_con)
petri_utils.add_arc_from_to(p_6, t_9, net_con)
petri_utils.add_arc_from_to(t_9, p_12, net_con)
petri_utils.add_arc_from_to(p_6, t_4, net_con)
petri_utils.add_arc_from_to(t_4, p_7, net_con)
petri_utils.add_arc_from_to(p_7, ot, net_con)
petri_utils.add_arc_from_to(ot, p_8, net_con)
petri_utils.add_arc_from_to(p_8, t_10, net_con)
petri_utils.add_arc_from_to(t_10, p_11, net_con)
petri_utils.add_arc_from_to(p_11, t_13, net_con)
petri_utils.add_arc_from_to(t_13, p_12, net_con)
petri_utils.add_arc_from_to(p_8, t_7, net_con)
petri_utils.add_arc_from_to(t_7, p_9, net_con)
petri_utils.add_arc_from_to(p_9, op, net_con)
petri_utils.add_arc_from_to(op, p_10, net_con)
petri_utils.add_arc_from_to(p_10, t_11, net_con)
petri_utils.add_arc_from_to(p_10, t_12, net_con)
petri_utils.add_arc_from_to(t_12, p_9, net_con)
petri_utils.add_arc_from_to(t_11, p_11, net_con)
petri_utils.add_arc_from_to(p_11, t_14, net_con)
petri_utils.add_arc_from_to(t_14, p_7, net_con)
# Add tokens
initial_marking = Marking()
initial_marking[source] = 1
final_marking = Marking()
final_marking[sink] = 1
pm4py.view_petri_net(net_con, initial_marking, final_marking)
pm4py.write_pnml(net_con, initial_marking, final_marking, "results/haum/conformative_petrinet_con.pnml")
pm4py.vis.save_vis_petri_net(net_con, initial_marking, final_marking,
"results/processmaps/conformative_petrinet_con.png")
bpmn = pm4py.convert.convert_to_bpmn(net_con, initial_marking, final_marking)
pm4py.view_bpmn(bpmn)
pm4py.vis.save_vis_bpmn(bpmn, "results/processmaps/conformative_bpmn_con.png")