|
@@ -14,9 +14,7 @@ Element function make_matching_schedule(LHS_model : Element):
|
|
// Initialize
|
|
// Initialize
|
|
schedule = create_node()
|
|
schedule = create_node()
|
|
workset = create_node()
|
|
workset = create_node()
|
|
- log("Fetching all instances")
|
|
|
|
all_elements = allInstances(LHS_model, "Pre_Element")
|
|
all_elements = allInstances(LHS_model, "Pre_Element")
|
|
- log("Got all instances")
|
|
|
|
required_size = read_nr_out(all_elements)
|
|
required_size = read_nr_out(all_elements)
|
|
|
|
|
|
// Need to keep adding to the schedule
|
|
// Need to keep adding to the schedule
|
|
@@ -25,32 +23,44 @@ Element function make_matching_schedule(LHS_model : Element):
|
|
// workset is empty, but we still need to add to the list
|
|
// workset is empty, but we still need to add to the list
|
|
// Therefore, we pick a random, unbound node, and add it to the workset
|
|
// Therefore, we pick a random, unbound node, and add it to the workset
|
|
new_element = set_pop(all_elements)
|
|
new_element = set_pop(all_elements)
|
|
|
|
+ log("Pick random: " + cast_v2s(new_element))
|
|
while (bool_or(set_in(schedule, new_element), is_edge(LHS_model["model"][new_element]))):
|
|
while (bool_or(set_in(schedule, new_element), is_edge(LHS_model["model"][new_element]))):
|
|
|
|
+ log("Picked stupid: " + cast_v2s(new_element))
|
|
// Element is not usable, so pick another one
|
|
// Element is not usable, so pick another one
|
|
new_element = set_pop(all_elements)
|
|
new_element = set_pop(all_elements)
|
|
|
|
+ log("Picked: " + cast_v2s(new_element))
|
|
set_add(workset, new_element)
|
|
set_add(workset, new_element)
|
|
|
|
|
|
// Handle the workset
|
|
// Handle the workset
|
|
while (read_nr_out(workset) > 0):
|
|
while (read_nr_out(workset) > 0):
|
|
// Still elements in the workset, so pop from these first
|
|
// Still elements in the workset, so pop from these first
|
|
next = set_pop(workset)
|
|
next = set_pop(workset)
|
|
|
|
+ log("Working on " + cast_v2s(next))
|
|
|
|
|
|
// Check if element might not be already used somewhere
|
|
// Check if element might not be already used somewhere
|
|
|
|
+ log("Check if already in schedule")
|
|
if (bool_not(set_in(schedule, next))):
|
|
if (bool_not(set_in(schedule, next))):
|
|
|
|
+ log("NO")
|
|
list_append(schedule, next)
|
|
list_append(schedule, next)
|
|
|
|
|
|
// If it is an edge, we should also add the target and source
|
|
// If it is an edge, we should also add the target and source
|
|
|
|
+ log("Edge?")
|
|
if (is_edge(LHS_model["model"][next])):
|
|
if (is_edge(LHS_model["model"][next])):
|
|
|
|
+ log("YES")
|
|
// Add the target/source to the schedule
|
|
// Add the target/source to the schedule
|
|
- set_add(workset, read_edge_src(LHS_model["model"][next]))
|
|
|
|
- set_add(workset, read_edge_dst(LHS_model["model"][next]))
|
|
|
|
|
|
+ set_add(workset, reverseKeyLookup(LHS_model["model"], read_edge_src(LHS_model["model"][next])))
|
|
|
|
+ set_add(workset, reverseKeyLookup(LHS_model["model"], read_edge_dst(LHS_model["model"][next])))
|
|
|
|
|
|
// Also add all outgoing links
|
|
// Also add all outgoing links
|
|
|
|
+ log("Recurse")
|
|
counter = read_nr_out(LHS_model["model"][next])
|
|
counter = read_nr_out(LHS_model["model"][next])
|
|
while (counter > 0):
|
|
while (counter > 0):
|
|
|
|
+ log("Check")
|
|
counter = counter - 1
|
|
counter = counter - 1
|
|
if (set_in_node(LHS_model["model"], read_out(LHS_model["model"][next], counter))):
|
|
if (set_in_node(LHS_model["model"], read_out(LHS_model["model"][next], counter))):
|
|
|
|
+ log("ADD")
|
|
set_add(workset, reverseKeyLookup(LHS_model["model"], read_out(LHS_model["model"][next], counter)))
|
|
set_add(workset, reverseKeyLookup(LHS_model["model"], read_out(LHS_model["model"][next], counter)))
|
|
|
|
+ log("DONE")
|
|
|
|
|
|
return schedule!
|
|
return schedule!
|
|
|
|
|