|
@@ -31,6 +31,7 @@ Element function reachability_graph(params : Element, output_mms : Element):
|
|
|
Boolean possible
|
|
|
Element all_places
|
|
|
Element dict_repr
|
|
|
+ Element new_dict_repr
|
|
|
Element work_unit
|
|
|
|
|
|
result = create_node()
|
|
@@ -43,6 +44,7 @@ Element function reachability_graph(params : Element, output_mms : Element):
|
|
|
all_transitions = allInstances(in_model, "Transition")
|
|
|
while (read_nr_out(all_transitions) > 0):
|
|
|
transition = set_pop(all_transitions)
|
|
|
+ log("Consider transition " + transition)
|
|
|
|
|
|
tv = create_node()
|
|
|
links = allIncomingAssociationInstances(in_model, transition, "P2T")
|
|
@@ -102,6 +104,9 @@ Element function reachability_graph(params : Element, output_mms : Element):
|
|
|
all_transitions = set_copy(all_transitions_original)
|
|
|
while (read_nr_out(all_transitions) > 0):
|
|
|
transition = set_pop(all_transitions)
|
|
|
+
|
|
|
+ log("Test transition: " + cast_v2s(read_attribute(in_model, transition, "name")))
|
|
|
+
|
|
|
keys = dict_keys(transition_vectors_consume[transition])
|
|
|
possible = True
|
|
|
while (read_nr_out(keys) > 0):
|
|
@@ -111,22 +116,24 @@ Element function reachability_graph(params : Element, output_mms : Element):
|
|
|
if (integer_lt(dict_repr[key], transition_vectors_consume[transition][key])):
|
|
|
// Impossible transition, so discard this one
|
|
|
possible = False
|
|
|
+ log("Not applicable!")
|
|
|
break!
|
|
|
|
|
|
if (possible):
|
|
|
- dict_repr = dict_copy(dict_repr)
|
|
|
+ log("Applicable!")
|
|
|
+ new_dict_repr = dict_copy(dict_repr)
|
|
|
// Transition can execute, so compute and add the new state based on the consume/produce vectors
|
|
|
- log("Before transition: " + dict_to_string(dict_repr))
|
|
|
+ log("Before transition: " + dict_to_string(new_dict_repr))
|
|
|
keys = dict_keys(transition_vectors_consume[transition])
|
|
|
while (read_nr_out(keys) > 0):
|
|
|
key = set_pop(keys)
|
|
|
- dict_overwrite(dict_repr, key, integer_subtraction(dict_repr[key], transition_vectors_consume[transition][key]))
|
|
|
+ dict_overwrite(new_dict_repr, key, integer_subtraction(new_dict_repr[key], transition_vectors_consume[transition][key]))
|
|
|
|
|
|
keys = dict_keys(transition_vectors_produce[transition])
|
|
|
while (read_nr_out(keys) > 0):
|
|
|
key = set_pop(keys)
|
|
|
- dict_overwrite(dict_repr, key, integer_addition(dict_repr[key], transition_vectors_produce[transition][key]))
|
|
|
- log("After transition: " + dict_to_string(dict_repr))
|
|
|
+ dict_overwrite(new_dict_repr, key, integer_addition(new_dict_repr[key], transition_vectors_produce[transition][key]))
|
|
|
+ log("After transition: " + dict_to_string(new_dict_repr))
|
|
|
|
|
|
// Check if this state already has an associated ID
|
|
|
Integer other_state_id
|
|
@@ -137,7 +144,7 @@ Element function reachability_graph(params : Element, output_mms : Element):
|
|
|
while (read_nr_out(keys) > 0):
|
|
|
other_state_id = set_pop(keys)
|
|
|
|
|
|
- if (dict_eq(reachable_states[other_state_id], dict_repr)):
|
|
|
+ if (dict_eq(reachable_states[other_state_id], new_dict_repr)):
|
|
|
target_id = other_state_id
|
|
|
break!
|
|
|
|
|
@@ -147,7 +154,7 @@ Element function reachability_graph(params : Element, output_mms : Element):
|
|
|
next_id = next_id + 1
|
|
|
|
|
|
// Add to all data structures
|
|
|
- dict_add(reachable_states, target_id, dict_repr)
|
|
|
+ dict_add(reachable_states, target_id, new_dict_repr)
|
|
|
dict_add(mappings, target_id, create_node())
|
|
|
set_add(workset, target_id)
|
|
|
|
|
@@ -155,12 +162,12 @@ Element function reachability_graph(params : Element, output_mms : Element):
|
|
|
state = instantiate_node(out_model, "State", cast_i2s(target_id))
|
|
|
instantiate_attribute(out_model, state, "name", cast_i2s(target_id))
|
|
|
|
|
|
- keys = dict_keys(dict_repr)
|
|
|
+ keys = dict_keys(new_dict_repr)
|
|
|
while (read_nr_out(keys) > 0):
|
|
|
key = set_pop(keys)
|
|
|
place = instantiate_node(out_model, "Place", "")
|
|
|
instantiate_attribute(out_model, place, "name", read_attribute(in_model, key, "name"))
|
|
|
- instantiate_attribute(out_model, place, "tokens", dict_repr[key])
|
|
|
+ instantiate_attribute(out_model, place, "tokens", new_dict_repr[key])
|
|
|
instantiate_link(out_model, "Contains", "", state, place)
|
|
|
|
|
|
// Anyway, we have found a transition, which we should store
|