|
@@ -93,13 +93,48 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
|
|
|
typename = read_type(schedule_model, current_element)
|
|
|
original_typename = string_substr(typename, 4, string_len(typename))
|
|
|
guaranteed_instance = False
|
|
|
+
|
|
|
+ /////// NEW CODE
|
|
|
+ // Is a node, so find whether or not there are some connections that are already resolved
|
|
|
+ Element ic
|
|
|
+ Element oc
|
|
|
+ String poll
|
|
|
+ String value
|
|
|
+
|
|
|
+ oc = allOutgoingAssociationInstances(schedule_model, current_element, "PreElement")
|
|
|
+ while (bool_and(set_len(oc) > 0, set_len(options) < 2)):
|
|
|
+ poll = set_pop(oc)
|
|
|
+ if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
|
|
|
+ // This incoming link is already defined, so we just have one option: the destination of the link we matched
|
|
|
+ value = readAssociationSource(host_model, map[read_attribute(schedule_model, poll, "label")])
|
|
|
+ if (bool_not(set_in(options, value))):
|
|
|
+ set_add(options, value)
|
|
|
+
|
|
|
+ if (set_len(options) < 2):
|
|
|
+ ic = allIncomingAssociationInstances(schedule_model, current_element, "PreElement")
|
|
|
+ while (bool_and(set_len(ic) > 0, set_len(options) < 2)):
|
|
|
+ poll = set_pop(ic)
|
|
|
+ if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
|
|
|
+ // This incoming link is already defined, so we just have one option: the destination of the link we matched
|
|
|
+ value = readAssociationDestination(host_model, map[read_attribute(schedule_model, poll, "label")])
|
|
|
+ if (bool_not(set_in(options, value))):
|
|
|
+ set_add(options, value)
|
|
|
+
|
|
|
+ if (set_len(options) == 0):
|
|
|
+ // Is a node and no connections, so we just pick all options
|
|
|
+ options = allInstances(host_model, original_typename)
|
|
|
+ guaranteed_instance = True
|
|
|
+
|
|
|
+ elif (set_len(options) > 1):
|
|
|
+ // Multiple "only" options, which will not work out: no options!
|
|
|
+ return set_create()!
|
|
|
|
|
|
if (is_edge(schedule_model["model"][current_element])):
|
|
|
Boolean src_in
|
|
|
Boolean dst_in
|
|
|
// Is an edge, so check for already bound source/target
|
|
|
- src_label = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_src(schedule_model["model"][current_element])), "label")
|
|
|
- dst_label = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_dst(schedule_model["model"][current_element])), "label")
|
|
|
+ src_label = read_attribute(schedule_model, readAssociationSource(schedule_model, current_element), "label")
|
|
|
+ dst_label = read_attribute(schedule_model, readAssociationDestination(schedule_model, current_element), "label")
|
|
|
src_in = set_in(dict_keys(map), src_label)
|
|
|
dst_in = set_in(dict_keys(map), dst_label)
|
|
|
|
|
@@ -107,56 +142,23 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
|
|
|
|
|
|
if (bool_and(src_in, dst_in)):
|
|
|
// Source and destination are bound
|
|
|
- options = allOutgoingAssociationInstances(host_model, map[src_label], original_typename)
|
|
|
+ if (set_len(options) > 0):
|
|
|
+ options = set_overlap(options, allOutgoingAssociationInstances(host_model, map[src_label], original_typename))
|
|
|
if (set_len(options) > 0):
|
|
|
options = set_overlap(options, allIncomingAssociationInstances(host_model, map[dst_label], original_typename))
|
|
|
|
|
|
elif (src_in):
|
|
|
// Source is bound
|
|
|
- options = allOutgoingAssociationInstances(host_model, map[src_label], original_typename)
|
|
|
+ options = set_overlap(options, allOutgoingAssociationInstances(host_model, map[src_label], original_typename))
|
|
|
|
|
|
elif (dst_in):
|
|
|
// Destination is bound
|
|
|
- options = allIncomingAssociationInstances(host_model, map[dst_label], original_typename)
|
|
|
+ options = set_overlap(options, allIncomingAssociationInstances(host_model, map[dst_label], original_typename))
|
|
|
|
|
|
else:
|
|
|
// Neither is bound, so just get all of them
|
|
|
- options = allInstances(host_model, original_typename)
|
|
|
- else:
|
|
|
- // Is a node, so find whether or not there are some connections that are already resolved
|
|
|
- Element ic
|
|
|
- Element oc
|
|
|
- String poll
|
|
|
- String value
|
|
|
-
|
|
|
- oc = allOutgoingAssociationInstances(schedule_model, current_element, "PreElement")
|
|
|
- while (bool_and(set_len(oc) > 0, set_len(options) < 2)):
|
|
|
- poll = set_pop(oc)
|
|
|
- if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
|
|
|
- // This incoming link is already defined, so we just have one option: the destination of the link we matched
|
|
|
- value = readAssociationSource(host_model, map[read_attribute(schedule_model, poll, "label")])
|
|
|
- if (bool_not(set_in(options, value))):
|
|
|
- set_add(options, value)
|
|
|
-
|
|
|
- if (set_len(options) < 2):
|
|
|
- ic = allIncomingAssociationInstances(schedule_model, current_element, "PreElement")
|
|
|
- String value
|
|
|
- while (bool_and(set_len(ic) > 0, set_len(options) < 2)):
|
|
|
- poll = set_pop(ic)
|
|
|
- if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
|
|
|
- // This incoming link is already defined, so we just have one option: the destination of the link we matched
|
|
|
- value = readAssociationDestination(host_model, map[read_attribute(schedule_model, poll, "label")])
|
|
|
- if (bool_not(set_in(options, value))):
|
|
|
- set_add(options, value)
|
|
|
-
|
|
|
- if (set_len(options) == 0):
|
|
|
- // Is a node and no connections, so we just pick all options
|
|
|
- options = allInstances(host_model, original_typename)
|
|
|
- guaranteed_instance = True
|
|
|
-
|
|
|
- elif (set_len(options) > 1):
|
|
|
- // Multiple "only" options, which will not work out: no options!
|
|
|
- return set_create()!
|
|
|
+ options = options
|
|
|
+ ////////// END CODE
|
|
|
|
|
|
// Filter options further
|
|
|
Element filtered_options
|
|
@@ -200,7 +202,6 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
|
|
|
|
|
|
Element attributes
|
|
|
String attribute
|
|
|
- Element value
|
|
|
Element func
|
|
|
Boolean result
|
|
|
Element attributes_copy
|
|
@@ -545,6 +546,8 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
|
|
|
Element mapping
|
|
|
Boolean result
|
|
|
|
|
|
+ log("Executing rule: " + current)
|
|
|
+
|
|
|
mappings = full_match(host_model, schedule_model, current, False)
|
|
|
|
|
|
if (set_len(mappings) > 0):
|
|
@@ -552,7 +555,7 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
|
|
|
else:
|
|
|
result = False
|
|
|
|
|
|
- //log("Matches in forall: " + cast_v2s(set_len(mappings)))
|
|
|
+ log("Matches in forall: " + cast_v2s(set_len(mappings)))
|
|
|
while (set_len(mappings) > 0):
|
|
|
mapping = set_pop(mappings)
|
|
|
RHS = set_pop(allAssociationDestinations(schedule_model, current, "RHSLink"))
|