|
|
@@ -55,7 +55,6 @@ Element function printNode(tf_pn_model: Element, tf_pn_node: Element):
|
|
|
if (isAttributeRelated(tf_pn_model, tf_pn_node)):
|
|
|
log(">attribute related")
|
|
|
|
|
|
-
|
|
|
//print attributes
|
|
|
|
|
|
log("attributes:")
|
|
|
@@ -79,16 +78,17 @@ 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):
|
|
|
- //NOTE maybe get rid of LHS postfix? maybe not
|
|
|
+ //type equality
|
|
|
String type1
|
|
|
type1 = getTypeName(transf_model, transf_elem)
|
|
|
String type2
|
|
|
type2 = string_join(getTypeName(host_model, host_elem), "_LHS")
|
|
|
if (type1 != type2):
|
|
|
return False
|
|
|
- log(string_join(string_join(type1, " : "), getName(transf_model, transf_elem)))
|
|
|
- log(string_join(string_join(type2, " : "), getName(host_model, host_elem)))
|
|
|
- return True
|
|
|
+ //semantic check
|
|
|
+ Element func
|
|
|
+ func = transf_model["semantic_checks"][read_attribute(transf_model, getName(transf_model,transf_elem), "function")]
|
|
|
+ return func(host_model, host_elem)
|
|
|
|
|
|
Integer function are_connected(model: Element, el1:Element, el2:Element):
|
|
|
String el1_mmt
|
|
|
@@ -246,17 +246,14 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
// get the current match from the search-state
|
|
|
Element current_match
|
|
|
current_match = dict_read(SearchState,"curmatch")
|
|
|
-
|
|
|
- //TODO semantic check (eg, call function that compares attributes)
|
|
|
- // --> need to check with assistent
|
|
|
-
|
|
|
+
|
|
|
//if match is complete: add to matches and return
|
|
|
Integer pattern_size
|
|
|
pattern_size = SearchState["pattern_size"]
|
|
|
if pattern_size == list_len(current_match):
|
|
|
set_add(SearchState["matches"], SearchState["curmatch"])
|
|
|
return SearchState
|
|
|
-
|
|
|
+
|
|
|
//feasability checks
|
|
|
if (list_len(SearchState["N_pattern_out"]) > list_len(SearchState["N_host_out"])):
|
|
|
return SearchState
|
|
|
@@ -264,7 +261,7 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
return SearchState
|
|
|
if (list_len(SearchState["V_pattern"]) > list_len(SearchState["V_host"])):
|
|
|
return SearchState
|
|
|
-
|
|
|
+
|
|
|
//initialise some variables
|
|
|
Integer index2 //an index used for looping trough host_list
|
|
|
Element host_list // the set with host nodes to be considered
|
|
|
@@ -336,6 +333,7 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
|
|
|
list_append(tf_ma_ramified_nodes, tf_ma_ramified_node)
|
|
|
|
|
|
//find all nodes in the graph that are not related to attributes: ie a userdefined type
|
|
|
+
|
|
|
Element hostmodel_mm //metamodel of hostgraph
|
|
|
hostmodel_mm = tf_ma_model["metamodel"]["model"]
|
|
|
Element hostmodel_keys //keys of all elements in the model
|
|
|
@@ -364,8 +362,9 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
|
|
|
dict_add(SearchState, "pattern_size", list_len(tf_ma_ramified_nodes))
|
|
|
|
|
|
//call vf2 for the matching
|
|
|
- SearchState = transf_vf2(SearchState, tf_ma_transformation, tf_ma_model)
|
|
|
|
|
|
+ SearchState = transf_vf2(SearchState, tf_ma_transformation, tf_ma_model)
|
|
|
+
|
|
|
return SearchState["matches"]
|
|
|
|
|
|
Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element):
|
|
|
@@ -470,6 +469,7 @@ Element function petrinet_transformation(root: Element):
|
|
|
//Transition_LHS: lhs_find_all
|
|
|
instantiate_node(my_model, "Transition_LHS","lhs_find_all")
|
|
|
instantiate_attribute(my_model, "lhs_find_all", "plabel", 1)
|
|
|
+ instantiate_attribute(my_model, "lhs_find_all", "function", "always_true")
|
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "lhs_precondition", "lhs_find_all")
|
|
|
|
|
|
@@ -481,24 +481,47 @@ Element function petrinet_transformation(root: Element):
|
|
|
//Transition_LHS: nac_transition_place_before
|
|
|
instantiate_node(my_model, "Transition_LHS","nac_transition_before")
|
|
|
instantiate_attribute(my_model, "nac_transition_before", "plabel", 1)
|
|
|
+ instantiate_attribute(my_model, "nac_transition_before", "function", "always_true")
|
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_transition_before")
|
|
|
|
|
|
//Place_LHS: nac_place_before
|
|
|
instantiate_node(my_model, "Place_LHS","nac_place_before")
|
|
|
instantiate_attribute(my_model, "nac_place_before", "plabel", 2)
|
|
|
- instantiate_attribute(my_model, "nac_place_before", "tokens", "lambda x: sum([1 for i in x.out if i.weight<x.tokens]) == len(x.transition)")
|
|
|
+ instantiate_attribute(my_model, "nac_place_before", "function", "always_true")
|
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_place_before")
|
|
|
|
|
|
//P2T_LHS: nac_ft_p2t
|
|
|
instantiate_link(my_model, "P2T_LHS", "nac_p2tlhs_before", "nac_place_before", "nac_transition_before")
|
|
|
instantiate_attribute(my_model, "nac_p2tlhs_before", "plabel", 3)
|
|
|
- instantiate_attribute(my_model, "nac_p2tlhs_before", "weight", "lambda x: True")
|
|
|
+ instantiate_attribute(my_model, "nac_p2tlhs_before", "function", "is_not_consumable")
|
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_p2tlhs_before")
|
|
|
+
|
|
|
+ Element semantic_checks
|
|
|
+ semantic_checks = create_node()
|
|
|
+ dict_add(semantic_checks, "always_true", always_true)
|
|
|
+ dict_add(semantic_checks, "is_not_consumable", is_not_consumable)
|
|
|
+ dict_add(my_model, "semantic_checks", semantic_checks)
|
|
|
|
|
|
return my_model
|
|
|
+
|
|
|
+Boolean function is_not_consumable(model : Element, matched_node : Element):
|
|
|
+ //get place before
|
|
|
+ Element place_before
|
|
|
+ place_before = read_edge_src(matched_node)
|
|
|
+ //get tokens from place
|
|
|
+ Integer tokens
|
|
|
+ tokens = read_attribute(model, getName(model, place_before), "tokens")
|
|
|
+ //get weight from matched_node
|
|
|
+ Integer weight
|
|
|
+ weight = read_attribute(model, getName(model, matched_node), "weight")
|
|
|
+ return weight > tokens
|
|
|
+
|
|
|
+Boolean function always_true(model : Element, self : Element):
|
|
|
+ return True
|
|
|
+
|
|
|
|
|
|
Element function pn_operations():
|
|
|
Element ops
|