Преглед на файлове

Revert "Patches to a (working?) BFS algorithm to make it faster: crashes..."

This reverts commit 5144ea9ac21dd7f41a57ffd4abc63bf0be525f85.
Yentl Van Tendeloo преди 8 години
родител
ревизия
c9f9c5ed86
променени са 2 файла, в които са добавени 7 реда и са изтрити 28 реда
  1. 4 0
      core/core_algorithm.alc
  2. 3 28
      models/bfs.alc

+ 4 - 0
core/core_algorithm.alc

@@ -497,6 +497,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 		value = read_attribute(pm, readAssociationDestination(pm, consumes_link), "name")
 		dict_add(inputs, name, prefix + value)
 		dict_add(types, name, read_attribute(pm, readAssociationDestination(pm, consumes_link), "type"))
+		log("Added inputs: " + cast_v2s(prefix + value))
 
 	// Find all outputs and their types (i.e., key)
 	lst = allAssociationDestinations(pm, element, "Produces")
@@ -546,6 +547,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			input_keys = dict_keys(inputs)
 			while (read_nr_out(input_keys) > 0):
 				key = set_pop(input_keys)
+				log("READ model with name " + cast_v2s(inputs[key]))
 				model_join(merged_model, get_full_model(get_model_id(inputs[key])), string_join(types[key], "/"))
 
 			// 3) Transform
@@ -562,6 +564,8 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 				desired_metamodel_id = get_model_id(key)
 				split_off_model = model_split(merged_model, get_full_model(desired_metamodel_id), key + "/")
 
+				log("Wrote model to " + cast_v2s(outputs[key]))
+
 				// Check if the destination model already exists
 				if (get_model_id(outputs[key]) == ""):
 					// New model

+ 3 - 28
models/bfs.alc

@@ -11,30 +11,18 @@ Element function bfs(params : Element, output_mms : Element):
 	String state
 	Element path
 	Element path_copy
-	Element visited
-	Element visited_copy
 	String option
-	String dest
 
 	model = params["reachability_graph"]
 
 	worklist = create_node()
 	initial = set_pop(allInstances(model, "InitialState"))
-	work_unit = create_node()
-	list_append(work_unit, initial)
-	path = create_node()
-	list_append(work_unit, path)
-	visited = create_node()
-	set_add(visited, initial)
-	list_append(work_unit, visited)
-
-	list_append(worklist, work_unit)
+	list_append(worklist, create_tuple(initial, create_node()))
 
 	while (read_nr_out(worklist) > 0):
 		work_unit = list_pop(worklist, 0)
 		state = work_unit[0]
 		path = work_unit[1]
-		visited = work_unit[2]
 		log("Searching for length " + cast_v2s(read_nr_out(path)))
 
 		if (value_eq(read_attribute(model, state, "error"), True)):
@@ -46,24 +34,11 @@ Element function bfs(params : Element, output_mms : Element):
 			break!
 
 		options = allOutgoingAssociationInstances(model, state, "Transition")
+
 		while (read_nr_out(options) > 0):
 			option = set_pop(options)
-			dest = readAssociationDestination(model, option)
-			
-			if (set_in(visited, dest)):
-				// Already visited this node, so skip
-				continue!
-
 			path_copy = dict_copy(path)
-			visited_copy = set_copy(visited)
-
-			set_add(visited_copy, dest)
 			list_append(path_copy, read_attribute(model, option, "name"))
-
-			work_unit = create_node()
-			list_append(work_unit, dest)
-			list_append(work_unit, path_copy)
-			list_append(work_unit, visited_copy)
-			list_append(worklist, work_unit)
+			list_append(worklist, create_tuple(readAssociationDestination(model, option), path_copy))
 
 	return create_node()!