@@ -37,9 +37,12 @@ class Parameters(Enum):
3737 NO_TRACES = "noTraces"
3838 MAX_TRACE_LENGTH = "maxTraceLength"
3939 PETRI_SEMANTICS = "petri_semantics"
40+ INITIAL_TIMESTAMP = "initial_timestamp"
41+ INITIAL_CASE_ID = "initial_case_id"
4042
4143
4244def apply_playout (net , initial_marking , no_traces = 100 , max_trace_length = 100 ,
45+ initial_timestamp = 10000000 , initial_case_id = 0 ,
4346 case_id_key = xes_constants .DEFAULT_TRACEID_KEY ,
4447 activity_key = xes_constants .DEFAULT_NAME_KEY , timestamp_key = xes_constants .DEFAULT_TIMESTAMP_KEY ,
4548 final_marking = None , return_visited_elements = False , semantics = petri_net .semantics .ClassicSemantics ()):
@@ -56,6 +59,10 @@ def apply_playout(net, initial_marking, no_traces=100, max_trace_length=100,
5659 Number of traces to generate
5760 max_trace_length
5861 Maximum number of events per trace (do break)
62+ initial_timestamp
63+ Increased timestamp from 1970 for the first event
64+ initial_case_id
65+ Case id of the first event
5966 case_id_key
6067 Trace attribute that is the case ID
6168 activity_key
@@ -68,7 +75,7 @@ def apply_playout(net, initial_marking, no_traces=100, max_trace_length=100,
6875 Semantics of the Petri net to be used (default: petri_net.semantics.ClassicSemantics())
6976 """
7077 # assigns to each event an increased timestamp from 1970
71- curr_timestamp = 10000000
78+ curr_timestamp = initial_timestamp
7279 all_visited_elements = []
7380
7481 for i in range (no_traces ):
@@ -104,7 +111,7 @@ def apply_playout(net, initial_marking, no_traces=100, max_trace_length=100,
104111
105112 for index , visited_elements in enumerate (all_visited_elements ):
106113 trace = log_instance .Trace ()
107- trace .attributes [case_id_key ] = str (index )
114+ trace .attributes [case_id_key ] = str (index + initial_case_id )
108115 for element in visited_elements :
109116 if type (element ) is PetriNet .Transition and element .label is not None :
110117 event = log_instance .Event ()
@@ -135,6 +142,8 @@ def apply(net: PetriNet, initial_marking: Marking, final_marking: Marking = None
135142 Parameters of the algorithm:
136143 Parameters.NO_TRACES -> Number of traces of the log to generate
137144 Parameters.MAX_TRACE_LENGTH -> Maximum trace length
145+ Parameters.INITIAL_TIMESTAMP -> The first event is set with INITIAL_TIMESTAMP increased from 1970
146+ Parameters.INITIAL_CASE_ID -> Numeric case id for the first trace
138147 Parameters.PETRI_SEMANTICS -> Petri net semantics to be used (default: petri_nets.semantics.ClassicSemantics())
139148 """
140149 if parameters is None :
@@ -145,10 +154,15 @@ def apply(net: PetriNet, initial_marking: Marking, final_marking: Marking = None
145154 xes_constants .DEFAULT_TIMESTAMP_KEY )
146155 no_traces = exec_utils .get_param_value (Parameters .NO_TRACES , parameters , 1000 )
147156 max_trace_length = exec_utils .get_param_value (Parameters .MAX_TRACE_LENGTH , parameters , 1000 )
157+ initial_timestamp = exec_utils .get_param_value (Parameters .INITIAL_TIMESTAMP , parameters , 10000000 )
158+ initial_case_id = exec_utils .get_param_value (Parameters .INITIAL_CASE_ID , parameters , 0 )
148159 return_visited_elements = exec_utils .get_param_value (Parameters .RETURN_VISITED_ELEMENTS , parameters , False )
149160 semantics = exec_utils .get_param_value (Parameters .PETRI_SEMANTICS , parameters , petri_net .semantics .ClassicSemantics ())
150161
151- return apply_playout (net , initial_marking , max_trace_length = max_trace_length , no_traces = no_traces ,
162+ return apply_playout (net , initial_marking , max_trace_length = max_trace_length ,
163+ initial_timestamp = initial_timestamp ,
164+ initial_case_id = initial_case_id ,
165+ no_traces = no_traces ,
152166 case_id_key = case_id_key , activity_key = activity_key , timestamp_key = timestamp_key ,
153167 final_marking = final_marking , return_visited_elements = return_visited_elements ,
154168 semantics = semantics )
0 commit comments