|
@@ -77,7 +77,7 @@ Element function printNode(tf_pn_model: Element, tf_pn_node: Element):
|
|
|
return 0
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
-Boolean function node_match(transf_model : Element, transf_elem : Element, host_model : Element, host_elem : Element):
|
|
|
|
|
|
|
+Boolean function node_match(transf_model : Element, transf_elem : Element, host_model : Element, host_elem : Element, pivots : Element):
|
|
|
//type equality
|
|
//type equality
|
|
|
String type1
|
|
String type1
|
|
|
type1 = getTypeName(transf_model, transf_elem)
|
|
type1 = getTypeName(transf_model, transf_elem)
|
|
@@ -88,7 +88,15 @@ Boolean function node_match(transf_model : Element, transf_elem : Element, host_
|
|
|
//semantic check
|
|
//semantic check
|
|
|
Element func
|
|
Element func
|
|
|
func = transf_model["semantic_checks"][read_attribute(transf_model, getName(transf_model,transf_elem), "function")]
|
|
func = transf_model["semantic_checks"][read_attribute(transf_model, getName(transf_model,transf_elem), "function")]
|
|
|
- return func(host_model, host_elem)
|
|
|
|
|
|
|
+ //pivot check
|
|
|
|
|
+ String pivotInName
|
|
|
|
|
+ pivotInName = read_attribute(transf_model, getName(transf_model, transf_elem), "pivotIn")
|
|
|
|
|
+ if(func(host_model, host_elem)):
|
|
|
|
|
+ if( pivotInName == ""):
|
|
|
|
|
+ return True
|
|
|
|
|
+ else:
|
|
|
|
|
+ return set_in(pivots[pivotInName], host_elem)
|
|
|
|
|
+ return False
|
|
|
|
|
|
|
|
Integer function are_connected(model: Element, el1:Element, el2:Element):
|
|
Integer function are_connected(model: Element, el1:Element, el2:Element):
|
|
|
String el1_mmt
|
|
String el1_mmt
|
|
@@ -239,6 +247,9 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
// copy pattern_size
|
|
// copy pattern_size
|
|
|
dict_add(nss, "pattern_size", OldSearchState["pattern_size"])
|
|
dict_add(nss, "pattern_size", OldSearchState["pattern_size"])
|
|
|
|
|
|
|
|
|
|
+ //copy pivots
|
|
|
|
|
+ dict_add(nss, "pivots",OldSearchState["pivots"])
|
|
|
|
|
+
|
|
|
return nss
|
|
return nss
|
|
|
|
|
|
|
|
Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : Element):
|
|
Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : Element):
|
|
@@ -278,7 +289,7 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
while (index2 < list_len(host_list)):
|
|
while (index2 < list_len(host_list)):
|
|
|
host_node = list_read(host_list, index2)
|
|
host_node = list_read(host_list, index2)
|
|
|
index2= index2 + 1
|
|
index2= index2 + 1
|
|
|
- if(node_match(transf_m, pattern_node, host_m, host_node)):
|
|
|
|
|
|
|
+ if(node_match(transf_m, pattern_node, host_m, host_node, SearchState["pivots"])):
|
|
|
nss = new_SearchState(SearchState, transf_m, pattern_node, host_m, host_node)
|
|
nss = new_SearchState(SearchState, transf_m, pattern_node, host_m, host_node)
|
|
|
nss = transf_vf2(nss, transf_m, host_m)
|
|
nss = transf_vf2(nss, transf_m, host_m)
|
|
|
dict_delete(SearchState, "matches")
|
|
dict_delete(SearchState, "matches")
|
|
@@ -291,7 +302,7 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
while (index2 < list_len(host_list)):
|
|
while (index2 < list_len(host_list)):
|
|
|
host_node = list_read(host_list, index2)
|
|
host_node = list_read(host_list, index2)
|
|
|
index2= index2 + 1
|
|
index2= index2 + 1
|
|
|
- if(node_match(transf_m, pattern_node, host_m, host_node)):
|
|
|
|
|
|
|
+ if(node_match(transf_m, pattern_node, host_m, host_node, SearchState["pivots"])):
|
|
|
nss = new_SearchState(SearchState, transf_m, pattern_node, host_m, host_node)
|
|
nss = new_SearchState(SearchState, transf_m, pattern_node, host_m, host_node)
|
|
|
nss = transf_vf2(nss, transf_m, host_m)
|
|
nss = transf_vf2(nss, transf_m, host_m)
|
|
|
dict_delete(SearchState, "matches")
|
|
dict_delete(SearchState, "matches")
|
|
@@ -304,7 +315,7 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
while (index2 < list_len(host_list)):
|
|
while (index2 < list_len(host_list)):
|
|
|
host_node = list_read(host_list, index2)
|
|
host_node = list_read(host_list, index2)
|
|
|
index2= index2 + 1
|
|
index2= index2 + 1
|
|
|
- if(node_match(transf_m, pattern_node, host_m, host_node)):
|
|
|
|
|
|
|
+ if(node_match(transf_m, pattern_node, host_m, host_node, SearchState["pivots"])):
|
|
|
nss = new_SearchState(SearchState, transf_m, pattern_node, host_m, host_node)
|
|
nss = new_SearchState(SearchState, transf_m, pattern_node, host_m, host_node)
|
|
|
nss = transf_vf2(nss, transf_m, host_m)
|
|
nss = transf_vf2(nss, transf_m, host_m)
|
|
|
dict_delete(SearchState, "matches")
|
|
dict_delete(SearchState, "matches")
|
|
@@ -315,7 +326,7 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
|
|
|
|
|
|
|
|
|
|
// given a pattern, this function will return all matches in a model
|
|
// given a pattern, this function will return all matches in a model
|
|
|
-Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Element, tf_ma_model: Element ):
|
|
|
|
|
|
|
+Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Element, tf_ma_model: Element, pivots:Element ):
|
|
|
|
|
|
|
|
//find all nodes in the pattern
|
|
//find all nodes in the pattern
|
|
|
|
|
|
|
@@ -360,6 +371,7 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
|
|
|
dict_add(SearchState, "V_pattern", tf_ma_ramified_nodes)
|
|
dict_add(SearchState, "V_pattern", tf_ma_ramified_nodes)
|
|
|
dict_add(SearchState, "V_host", host_nodes)
|
|
dict_add(SearchState, "V_host", host_nodes)
|
|
|
dict_add(SearchState, "pattern_size", list_len(tf_ma_ramified_nodes))
|
|
dict_add(SearchState, "pattern_size", list_len(tf_ma_ramified_nodes))
|
|
|
|
|
+ dict_add(SearchState, "pivots", pivots)
|
|
|
|
|
|
|
|
//call vf2 for the matching
|
|
//call vf2 for the matching
|
|
|
|
|
|
|
@@ -371,13 +383,12 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
|
|
|
//TODO support for multiple ruleTypes
|
|
//TODO support for multiple ruleTypes
|
|
|
|
|
|
|
|
//find LHS
|
|
//find LHS
|
|
|
- //TODO if no lhs (is this allowed to happen?)
|
|
|
|
|
|
|
+ //TODO if no lhs (is this allowed to happen?) // or empty lhs
|
|
|
Element tf_er_lhs
|
|
Element tf_er_lhs
|
|
|
tf_er_lhs = allOutgoingAssociationInstances(tf_er_transformation, tf_er_rule, dict_read(dict_read(dict_read(tf_er_transformation, "metamodel"), "model"), "lhs"))
|
|
tf_er_lhs = allOutgoingAssociationInstances(tf_er_transformation, tf_er_rule, dict_read(dict_read(dict_read(tf_er_transformation, "metamodel"), "model"), "lhs"))
|
|
|
- tf_er_lhs = tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_lhs)), tf_er_model)
|
|
|
|
|
|
|
+ tf_er_lhs = tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_lhs)), tf_er_model, pivots)
|
|
|
Integer nr_of_lhs_matches
|
|
Integer nr_of_lhs_matches
|
|
|
nr_of_lhs_matches = list_len(tf_er_lhs)
|
|
nr_of_lhs_matches = list_len(tf_er_lhs)
|
|
|
- //log(string_join(cast_i2s(list_len(tf_er_lhs)), " matches found"))
|
|
|
|
|
|
|
|
|
|
//find NACs if at least one lhs is found (otherwise not needed)
|
|
//find NACs if at least one lhs is found (otherwise not needed)
|
|
|
Integer nr_of_nac_matches
|
|
Integer nr_of_nac_matches
|
|
@@ -389,11 +400,10 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
|
|
|
tf_er_nac_ = allOutgoingAssociationInstances(tf_er_transformation, tf_er_rule, dict_read(dict_read(dict_read(tf_er_transformation, "metamodel"), "model"), "nac"))
|
|
tf_er_nac_ = allOutgoingAssociationInstances(tf_er_transformation, tf_er_rule, dict_read(dict_read(dict_read(tf_er_transformation, "metamodel"), "model"), "nac"))
|
|
|
Element partial_nac_matches
|
|
Element partial_nac_matches
|
|
|
while (read_nr_out(tf_er_nac_) > 0):
|
|
while (read_nr_out(tf_er_nac_) > 0):
|
|
|
- partial_nac_matches = tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_nac_)), tf_er_model)
|
|
|
|
|
|
|
+ partial_nac_matches = tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_nac_)), tf_er_model, pivots)
|
|
|
while (read_nr_out(partial_nac_matches)>0):
|
|
while (read_nr_out(partial_nac_matches)>0):
|
|
|
list_append(tf_er_nac, set_pop(partial_nac_matches))
|
|
list_append(tf_er_nac, set_pop(partial_nac_matches))
|
|
|
nr_of_nac_matches = list_len(tf_er_nac)
|
|
nr_of_nac_matches = list_len(tf_er_nac)
|
|
|
- //log(string_join(cast_i2s(list_len(tf_er_nac)), " matches found"))
|
|
|
|
|
|
|
|
|
|
//remove from lhs matches that share a node with a nac match
|
|
//remove from lhs matches that share a node with a nac match
|
|
|
Element final_matches
|
|
Element final_matches
|
|
@@ -538,6 +548,7 @@ Element function petrinet_transformation(root: Element):
|
|
|
instantiate_attribute(my_model, "lhs_find_all", "plabel", 1)
|
|
instantiate_attribute(my_model, "lhs_find_all", "plabel", 1)
|
|
|
instantiate_attribute(my_model, "lhs_find_all", "function", "always_true")
|
|
instantiate_attribute(my_model, "lhs_find_all", "function", "always_true")
|
|
|
instantiate_attribute(my_model, "lhs_find_all", "pivotOut", "enabled")
|
|
instantiate_attribute(my_model, "lhs_find_all", "pivotOut", "enabled")
|
|
|
|
|
+ instantiate_attribute(my_model, "lhs_find_all", "pivotIn", "")
|
|
|
//connect to rule
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "lhs_precondition", "lhs_find_all")
|
|
instantiate_link(my_model, "pre2ram", "", "lhs_precondition", "lhs_find_all")
|
|
|
|
|
|
|
@@ -551,6 +562,7 @@ Element function petrinet_transformation(root: Element):
|
|
|
instantiate_attribute(my_model, "nac_transition_before", "plabel", 1)
|
|
instantiate_attribute(my_model, "nac_transition_before", "plabel", 1)
|
|
|
instantiate_attribute(my_model, "nac_transition_before", "function", "always_true")
|
|
instantiate_attribute(my_model, "nac_transition_before", "function", "always_true")
|
|
|
instantiate_attribute(my_model, "nac_transition_before", "pivotOut", "")
|
|
instantiate_attribute(my_model, "nac_transition_before", "pivotOut", "")
|
|
|
|
|
+ instantiate_attribute(my_model, "nac_transition_before", "pivotIn", "")
|
|
|
//connect to rule
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_transition_before")
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_transition_before")
|
|
|
|
|
|
|
@@ -559,6 +571,7 @@ Element function petrinet_transformation(root: Element):
|
|
|
instantiate_attribute(my_model, "nac_place_before", "plabel", 2)
|
|
instantiate_attribute(my_model, "nac_place_before", "plabel", 2)
|
|
|
instantiate_attribute(my_model, "nac_place_before", "function", "always_true")
|
|
instantiate_attribute(my_model, "nac_place_before", "function", "always_true")
|
|
|
instantiate_attribute(my_model, "nac_place_before", "pivotOut", "")
|
|
instantiate_attribute(my_model, "nac_place_before", "pivotOut", "")
|
|
|
|
|
+ instantiate_attribute(my_model, "nac_place_before", "pivotIn", "")
|
|
|
//connect to rule
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_place_before")
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_place_before")
|
|
|
|
|
|
|
@@ -567,6 +580,7 @@ Element function petrinet_transformation(root: Element):
|
|
|
instantiate_attribute(my_model, "nac_p2tlhs_before", "plabel", 3)
|
|
instantiate_attribute(my_model, "nac_p2tlhs_before", "plabel", 3)
|
|
|
instantiate_attribute(my_model, "nac_p2tlhs_before", "function", "is_not_consumable")
|
|
instantiate_attribute(my_model, "nac_p2tlhs_before", "function", "is_not_consumable")
|
|
|
instantiate_attribute(my_model, "nac_p2tlhs_before", "pivotOut", "")
|
|
instantiate_attribute(my_model, "nac_p2tlhs_before", "pivotOut", "")
|
|
|
|
|
+ instantiate_attribute(my_model, "nac_p2tlhs_before", "pivotIn", "")
|
|
|
//connect to rule
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_p2tlhs_before")
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_p2tlhs_before")
|
|
|
|
|
|