|
|
@@ -78,16 +78,14 @@ Element function printNode(tf_pn_model: Element, tf_pn_node: Element):
|
|
|
|
|
|
|
|
|
Boolean function node_match(transf_model : Element, transf_elem : Element, host_model : Element, host_elem : Element, pivots : Element):
|
|
|
- log(string_join(" matching:", getName(host_model,host_elem)))
|
|
|
+ log(string_join(string_join(string_join(" matching: ", getName(host_model,host_elem)), " with "), getName(transf_model, transf_elem)))
|
|
|
//type equality
|
|
|
String type1
|
|
|
type1 = getTypeName(transf_model, transf_elem)
|
|
|
String type2
|
|
|
type2 = string_join(getTypeName(host_model, host_elem), "_LHS")
|
|
|
|
|
|
- //log(string_join(string_join(type1, ", "), type2))
|
|
|
if (type1 != type2):
|
|
|
- //log("type doesn't match")
|
|
|
return False
|
|
|
//semantic check
|
|
|
Element func
|
|
|
@@ -95,20 +93,16 @@ Boolean function node_match(transf_model : Element, transf_elem : Element, host_
|
|
|
//pivot check
|
|
|
String pivotInName
|
|
|
pivotInName = read_attribute(transf_model, getName(transf_model, transf_elem), "pivotIn")
|
|
|
- //log(string_join("pivotInName: ", pivotInName))
|
|
|
if(func(host_model, host_elem)):
|
|
|
- //log("function returned true")
|
|
|
if( pivotInName == ""):
|
|
|
- //log("no pivot")
|
|
|
+ log(" empty pivot")
|
|
|
return True
|
|
|
else:
|
|
|
- if(set_in(pivots[pivotInName], host_elem)):
|
|
|
- //log("in pivot set")
|
|
|
+ if(set_in(pivots[pivotInName], getName(host_model,host_elem))):
|
|
|
+ log(" in pivot, apparantly")
|
|
|
return True
|
|
|
else:
|
|
|
- //log("not in pivot set")
|
|
|
return False
|
|
|
- //log("= END MATCHING")
|
|
|
return False
|
|
|
|
|
|
Integer function are_connected(model: Element, el1:Element, el2:Element):
|
|
|
@@ -149,9 +143,6 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
Integer index // used for list looping
|
|
|
Element elem // reusable loop variable
|
|
|
|
|
|
- log("adding")
|
|
|
- log(getName(HostModel, NewHostElem))
|
|
|
-
|
|
|
//new MATCHES
|
|
|
dict_add(nss, "matches", OldSearchState["matches"]) //hopefully works as a reference
|
|
|
|
|
|
@@ -233,14 +224,8 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
list_append(nl, elem)
|
|
|
elif (connectedness == 1): //if connected in outwards manner, don't keep in v and add to outlist
|
|
|
list_append(nss["N_pattern_out"], elem)
|
|
|
- log("adding to out(pattern)")
|
|
|
- //log(getName(TransfModel,elem))
|
|
|
- //log(cast_i2s(list_len(nss["N_pattern_out"])))
|
|
|
elif (connectedness == 2): //if connected in inwards manner, don't keep in v and add to inlist
|
|
|
list_append(nss["N_pattern_in"], elem)
|
|
|
- log("adding to in(pattern)")
|
|
|
- //log(getName(TransfModel,elem))
|
|
|
- //log(cast_i2s(list_len(nss["N_pattern_in"])))
|
|
|
else:
|
|
|
log("new_SearchState: unsupported connectedness value")
|
|
|
log(cast_i2s(connectedness))
|
|
|
@@ -259,14 +244,8 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
list_append(nl, elem)
|
|
|
elif (connectedness == 1): //if connected in outwards manner, don't keep in v and add to outlist
|
|
|
list_append(nss["N_host_out"], elem)
|
|
|
- log("adding to out(host)")
|
|
|
- //log(getName(HostModel,elem))
|
|
|
- //log(cast_i2s(list_len(nss["N_host_out"])))
|
|
|
elif (connectedness == 2): //if connected in inwards manner, don't keep in v and add to inlist
|
|
|
list_append(nss["N_host_in"], elem)
|
|
|
- log("adding to in(host)")
|
|
|
- //log(getName(HostModel,elem))
|
|
|
- //log(cast_i2s(list_len(nss["N_host_in"])))
|
|
|
else:
|
|
|
log("new_SearchState: unsupported connectedness value")
|
|
|
log(cast_i2s(connectedness))
|
|
|
@@ -314,7 +293,6 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
|
|
|
//search candidate
|
|
|
if ( list_len(SearchState["N_pattern_out"]) > 0 ):
|
|
|
- log("I GOT HERE")
|
|
|
//check for candidates in (N_pattern_out, N_host_out)
|
|
|
host_list = SearchState["N_host_out"]
|
|
|
pattern_node = list_read(SearchState["N_pattern_out"], 0)
|
|
|
@@ -323,12 +301,12 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
host_node = list_read(host_list, index2)
|
|
|
index2= index2 + 1
|
|
|
if(node_match(transf_m, pattern_node, host_m, host_node, SearchState["pivots"])):
|
|
|
+ log(" 3 match succeeded")
|
|
|
nss = new_SearchState(SearchState, transf_m, pattern_node, host_m, host_node)
|
|
|
nss = transf_vf2(nss, transf_m, host_m)
|
|
|
dict_delete(SearchState, "matches")
|
|
|
dict_add(SearchState, "matches", nss["matches"])
|
|
|
elif ( list_len(SearchState["N_pattern_in"]) > 0 ):
|
|
|
- //log("AND I, I GOT HERE!!")
|
|
|
//check for candidates in (N_pattern_in, N_host_in)
|
|
|
host_list = SearchState["N_host_in"]
|
|
|
pattern_node = list_read(SearchState["N_pattern_in"], 0)
|
|
|
@@ -337,6 +315,7 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
host_node = list_read(host_list, index2)
|
|
|
index2= index2 + 1
|
|
|
if(node_match(transf_m, pattern_node, host_m, host_node, SearchState["pivots"])):
|
|
|
+ log(" 2 match succeeded")
|
|
|
nss = new_SearchState(SearchState, transf_m, pattern_node, host_m, host_node)
|
|
|
nss = transf_vf2(nss, transf_m, host_m)
|
|
|
dict_delete(SearchState, "matches")
|
|
|
@@ -350,6 +329,7 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
host_node = list_read(host_list, index2)
|
|
|
index2= index2 + 1
|
|
|
if(node_match(transf_m, pattern_node, host_m, host_node, SearchState["pivots"])):
|
|
|
+ log(" 1 match succeeded")
|
|
|
nss = new_SearchState(SearchState, transf_m, pattern_node, host_m, host_node)
|
|
|
nss = transf_vf2(nss, transf_m, host_m)
|
|
|
dict_delete(SearchState, "matches")
|
|
|
@@ -424,11 +404,16 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
|
|
|
Integer nr_of_lhs_matches
|
|
|
nr_of_lhs_matches = list_len(tf_er_lhs)
|
|
|
|
|
|
- log("first matched lhs transition")
|
|
|
- log(getName(tf_er_model, dict_read(dict_read(list_read(tf_er_lhs, 0),1),"hn")))
|
|
|
- if(read_nr_out(dict_keys(list_read(tf_er_lhs, 0)))>0):
|
|
|
- log(getName(tf_er_model, dict_read(dict_read(list_read(tf_er_lhs, 0),3),"hn")))
|
|
|
- log(getName(tf_er_model, dict_read(dict_read(list_read(tf_er_lhs, 0),2),"hn")))
|
|
|
+ log("matched lhs transition")
|
|
|
+ Integer locallindex
|
|
|
+ locallindex = 0
|
|
|
+ while locallindex < nr_of_lhs_matches:
|
|
|
+ log(getName(tf_er_model, dict_read(dict_read(list_read(tf_er_lhs, locallindex),1),"hn")))
|
|
|
+ if(read_nr_out(dict_keys(list_read(tf_er_lhs, 0)))>1):
|
|
|
+ log(getName(tf_er_model, dict_read(dict_read(list_read(tf_er_lhs, locallindex),3),"hn")))
|
|
|
+ log(getName(tf_er_model, dict_read(dict_read(list_read(tf_er_lhs, locallindex),2),"hn")))
|
|
|
+ locallindex = locallindex+ 1
|
|
|
+ log("-")
|
|
|
|
|
|
//find NACs if at least one lhs is found (otherwise not needed)
|
|
|
Integer nr_of_nac_matches
|
|
|
@@ -445,13 +430,6 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
|
|
|
list_append(tf_er_nac, set_pop(partial_nac_matches))
|
|
|
nr_of_nac_matches = list_len(tf_er_nac)
|
|
|
|
|
|
- if(nr_of_nac_matches > 0):
|
|
|
- log("first matched nac transition")
|
|
|
- log(getName(tf_er_model, dict_read(dict_read(list_read(tf_er_nac, 0),1),"hn")))
|
|
|
- if(read_nr_out(dict_keys(list_read(tf_er_nac, 0)))>0):
|
|
|
- log(getName(tf_er_model, dict_read(dict_read(list_read(tf_er_nac, 0),3),"hn")))
|
|
|
- log(getName(tf_er_model, dict_read(dict_read(list_read(tf_er_nac, 0),2),"hn")))
|
|
|
-
|
|
|
//remove from lhs matches that share a node with a nac match
|
|
|
//TODO if nac is not related to match
|
|
|
Element final_matches
|
|
|
@@ -501,14 +479,7 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
|
|
|
if (dict_in(pivots, pivotOutName)):
|
|
|
dict_delete(pivots, pivotOutName)
|
|
|
dict_add(pivots, pivotOutName, create_node())
|
|
|
- set_add(pivots[pivotOutName], host_match_node)
|
|
|
-
|
|
|
- log("matched transition")
|
|
|
- log(getName(tf_er_model, dict_read(dict_read(list_read(final_matches, 0),1),"hn")))
|
|
|
- if(read_nr_out(dict_keys(list_read(final_matches, 0)))>0):
|
|
|
- log(getName(tf_er_model, dict_read(dict_read(list_read(final_matches, 0),3),"hn")))
|
|
|
- log(getName(tf_er_model, dict_read(dict_read(list_read(final_matches, 0),2),"hn")))
|
|
|
- log(string_join("number of allowed matches: ", cast_i2s(list_len(final_matches))))
|
|
|
+ set_add(pivots[pivotOutName], getName(tf_er_model,host_match_node))
|
|
|
|
|
|
//rhs part
|
|
|
|
|
|
@@ -588,7 +559,7 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
|
|
|
set_add(rhs_plabels, rhs_plabel)
|
|
|
else:
|
|
|
log("unsupported metatype in rhs")
|
|
|
- return 0
|
|
|
+ return pivots
|
|
|
|
|
|
Element function tf_transform(tf_tf_transformation: Element, tf_tf_model: Element):
|
|
|
//create a list of all rules
|
|
|
@@ -604,7 +575,9 @@ Element function tf_transform(tf_tf_transformation: Element, tf_tf_model: Elemen
|
|
|
//tf_printNode(tf_tf_transformation, tf_tf_rule)
|
|
|
log("= EXECUTING RULE")
|
|
|
log(getName(tf_tf_transformation, tf_tf_rule))
|
|
|
- tf_executeRule(tf_tf_transformation, tf_tf_rule, tf_tf_model, pivots)
|
|
|
+ pivots = tf_executeRule(tf_tf_transformation, tf_tf_rule, tf_tf_model, pivots)
|
|
|
+ log("length of pivots")
|
|
|
+ log(cast_i2s(read_nr_out(pivots)))
|
|
|
return 0
|
|
|
|
|
|
Element function test_simple_petrinet1(root:Element):
|
|
|
@@ -745,7 +718,7 @@ Element function petrinet_transformation(root: Element):
|
|
|
instantiate_attribute(my_model, "ct_lhs_place", "plabel", 2)
|
|
|
instantiate_attribute(my_model, "ct_lhs_place", "function", "always_true")
|
|
|
instantiate_attribute(my_model, "ct_lhs_place", "pivotOut", "")
|
|
|
- instantiate_attribute(my_model, "ct_lhs_place", "pivotIn", "enabled")
|
|
|
+ instantiate_attribute(my_model, "ct_lhs_place", "pivotIn", "")
|
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "ct_lhs_precondition", "ct_lhs_place")
|
|
|
|