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

Merge remote-tracking branch 'origin/concrete_syntax' into testing

Yentl Van Tendeloo преди 8 години
родител
ревизия
c221be64f5

+ 145 - 79
bootstrap/model_management.alc

@@ -140,119 +140,185 @@ Element function model_retype_on_name(model : Element, new_MM : Element, operati
 
 	return model!
 
-Void function model_join(dst_model : Element, src_model : Element, retyping_key : String):
+Element function model_join(models : Element, metamodel : Element, tracability_model : Element):
+	Element new_model
+	Element tagged_model
+	String retyping_key
+	Element elem_map
+	Element model
 	Element keys
+	String new_name
 	Element second_keys
-	Element mapping
-	String name
-	String type
 	String src
 	String dst
-	Element elem
+	String key
+	String type
 
-	mapping = create_node()
+	new_model = instantiate_model(metamodel)
+	elem_map = create_node()
 
-	second_keys = create_node()
+	// Do the iteration
+	while (read_nr_out(models) > 0):
+		tagged_model = set_pop(models)
+		retyping_key = string_join(list_read(tagged_model, 0), "/")
+		model = list_read(tagged_model, 1)
 
-	Element reverse
-	reverse = make_reverse_dictionary(src_model["model"])
+		// Add all elements from 'model'
+		keys = dict_keys(model["model"])
+		second_keys = create_node()
 
-	keys = dict_keys(src_model["model"])
-	while (read_nr_out(keys) > 0):
-		name = set_pop(keys)
-		elem = src_model["model"][name]
-		type = read_type(src_model, name)
+		while (read_nr_out(keys) > 0):
+			// Copy the new element
+			key = set_pop(keys)
+			type = read_type(model, key)
 
-		if (is_edge(elem)):
-			// Is an edge, so potentially queue it
-			String src
-			String dst
+			if (is_edge(model["model"][key])):
+				src = cast_id2s(read_edge_src(model["model"][key]))
+				dst = cast_id2s(read_edge_dst(model["model"][key]))
+				if (bool_and(dict_in(elem_map, src), dict_in(elem_map, dst))):
+					new_name = instantiate_link(new_model, retyping_key + type, "", elem_map[src], elem_map[dst])
+				else:
+					set_add(second_keys, key)
+					new_name = ""
+			elif (has_value(model["model"][key])):
+				new_name = instantiate_value(new_model, retyping_key + type, "", model["model"][key])
+			else:
+				new_name = instantiate_node(new_model, retyping_key + type, "")
 
-			src = reverse[cast_id2s(read_edge_src(elem))]
-			dst = reverse[cast_id2s(read_edge_dst(elem))]
+			if (new_name != ""):
+				// Add the new name to a map which registers the mapping to the new name
+				dict_add_fast(elem_map, cast_id2s(model["model"][key]), new_name)
 
-			if (bool_and(dict_in(mapping, src), dict_in(mapping, dst))):
-				// All present, so create the link between them
-				dict_add_fast(mapping, name, instantiate_link(dst_model, retyping_key + type, "", mapping[src], mapping[dst]))
-			else:
-				set_add(second_keys, name)
+			if (read_nr_out(keys) == 0):
+				keys = second_keys
+				second_keys = create_node()
 
-		elif (has_value(elem)):
-			// Has a value, so copy that as well
-			dict_add_fast(mapping, name, instantiate_value(dst_model, retyping_key + type, "", elem))
+	// Now link in the tracability model
+	// Go over all TracabilityLink elements and connect them in the merged model as well
 
-		else:
-			// Is a node
-			dict_add_fast(mapping, name, instantiate_node(dst_model, retyping_key + type, ""))
+	if (element_neq(tracability_model, read_root())):
+		Element tracability_links
+		String tracability_link
+		String new_name_src
+		String new_name_dst
 
-		if (read_nr_out(keys) == 0):
-			keys = second_keys
-			second_keys = create_node()
+		tracability_links = allInstances(tracability_model, "TracabilityLink")
 
-	return!
-	
-Element function model_split(src_model : Element, target_metamodel : Element, retyping_key : String):
-	Element dst_model
+		while (read_nr_out(tracability_links) > 0):
+			tracability_link = set_pop(tracability_links)
+
+			// Get necessary information from the tracability link
+			new_name_src = elem_map[cast_id2s(read_edge_src(tracability_model["model"][tracability_link]))]
+			new_name_dst = elem_map[cast_id2s(read_edge_dst(tracability_model["model"][tracability_link]))]
+			type = read_attribute(tracability_model, tracability_link, "type")
 
-	dst_model = instantiate_model(target_metamodel)
+			// Connect the two with the info we have
+			new_name = instantiate_link(new_model, type, "", new_name_src, new_name_dst)
 
+			if (new_name == ""):
+				log("ERROR: could not create a tracability link; ignoring")
+
+	return new_model!
+	
+Element function model_split(merged_model : Element, models : Element, tracability : Boolean):
+	if (read_nr_out(models) == 0):
+		// No results needed, so stop immediately unless tracability is True
+		if (bool_not(tracability)):
+			return create_node()!
+
+	Element result
+	Element metamodel
+	Element model_tuple
+	Element tracability_model
 	Element keys
-	Element second_keys
-	Element mapping
-	String name
-	String type
+	String key
 	String src
 	String dst
-	Integer length
-	String new_type
+	Element reverse
+	Element mapping
+	String retyping_key
+	String original_type
 	Element elem
-
+	Element second_keys
+	String type
+	Element splitted
+	String source
+	String target
+	String link
+
+	result = create_node()
+	tracability_model = instantiate_model(import_node("models/Tracability"))
+	reverse = make_reverse_dictionary(merged_model["model"])
 	mapping = create_node()
-	length = string_len(retyping_key)
-
 	second_keys = create_node()
 
-	Element reverse
-	reverse = make_reverse_dictionary(src_model["model"])
+	while (read_nr_out(models) > 0):
+		model_tuple = set_pop(models)
+		retyping_key = model_tuple[0]
+		metamodel = model_tuple[1]
+		dict_add_fast(result, retyping_key, instantiate_model(metamodel))
 
-	keys = dict_keys(src_model["model"])
+	keys = dict_keys(merged_model["model"])
 	while (read_nr_out(keys) > 0):
-		name = set_pop(keys)
-		elem = src_model["model"][name]
-
-		type = read_type(src_model, name)
-		if (string_startswith(type, retyping_key)):
-			new_type = string_substr(type, length, string_len(type))
-			if (is_edge(elem)):
-				// Is an edge, so potentially queue it
-				String src
-				String dst
+		key = set_pop(keys)
+		elem = merged_model["model"][key]
+		type = read_type(merged_model, key)
+		splitted = string_split(type, "/")
+
+		if (list_len(splitted) == 1):
+			// Only one, so no split possible
+			// Indicates a tracability element!
+			if (bool_and(tracability, is_edge(elem))):
+				// Got a tracability link!
+				// Is always an edge (for now?)
+				// Find out source and target and hope that they are already present
 
 				src = reverse[cast_id2s(read_edge_src(elem))]
 				dst = reverse[cast_id2s(read_edge_dst(elem))]
 
-				if (bool_and(dict_in(mapping, src), dict_in(mapping, dst))):
-					// All present, so create the link between them
-					dict_add_fast(mapping, name, instantiate_link(dst_model, new_type, "", mapping[src], mapping[dst]))
-				elif (bool_not(bool_or(set_in(keys, src), set_in(keys, dst)))):
-					// Source/target not in the queue, but we need it to split!
-					// This is an error as it indicates problems with links crossing different formalisms
-					log("ERROR: source/target of link to be included is not included!")
-					return create_node()!
-				else:
-					// Still source or destination in the queue, so we wait for that
-					set_add(second_keys, name)
+				// All present, so create the link between them
+				source = reuse_element(tracability_model, "Reference", "", read_edge_src(elem))
+				target = reuse_element(tracability_model, "Reference", "", read_edge_dst(elem))
 
-			elif (has_value(elem)):
-				// Has a value, so copy that as well
-				dict_add_fast(mapping, name, instantiate_value(dst_model, new_type, "", elem))
+				link = instantiate_link(tracability_model, "TracabilityLink", "", source, target)
+				instantiate_attribute(tracability_model, link, "type", type)
+		else:
+			retyping_key = splitted[0]
+
+			if (dict_in(result, retyping_key)):
+				original_type = splitted[1]
+
+				if (is_edge(elem)):
+					// Is an edge, so potentially queue it
+					src = reverse[cast_id2s(read_edge_src(elem))]
+					dst = reverse[cast_id2s(read_edge_dst(elem))]
+
+					if (bool_and(dict_in(mapping, src), dict_in(mapping, dst))):
+						// All present, so create the link between them
+						// Though we first check the model to which it was mapped, as this should be the same as we have now
+						if (bool_and(dict_in(result[retyping_key]["model"], mapping[src]), dict_in(result[retyping_key]["model"], mapping[dst]))):
+							// The matching worked fine
+							dict_add_fast(mapping, key, instantiate_link(result[retyping_key], original_type, "", mapping[src], mapping[dst]))
+						else:
+							log("ERROR mapping: source/target mapped to model, but not found in expected model; ignoring")
+					else:
+						// Still source or destination in the queue, so we wait for that
+						set_add(second_keys, key)
+
+				elif (has_value(elem)):
+					// Has a value, so copy that as well
+					dict_add_fast(mapping, key, instantiate_value(result[retyping_key], original_type, "", elem))
 
-			else:
-				// Is a node
-				dict_add_fast(mapping, name, instantiate_node(dst_model, new_type, ""))
+				else:
+					// Is a node
+					dict_add_fast(mapping, key, instantiate_node(result[retyping_key], original_type, ""))
 
 		if (read_nr_out(keys) == 0):
 			keys = second_keys
 			second_keys = create_node()
 
-	return dst_model!
+	// Finally, we also add tracability information as a separate model
+	if (tracability):
+		dict_add_fast(result, "__tracability", tracability_model)
+
+	return result!

+ 14 - 1
bootstrap/modelling.alc

@@ -98,6 +98,19 @@ Element function instantiate_model(metamodel : Element):
 	retype_model(model, metamodel)
 	return model!
 
+String function reuse_element(model : Element, type_name : String, instance_name : String, element : Element):
+	String actual_name
+
+	if (bool_not(dict_in(model["metamodel"]["model"], type_name))):
+		log("ERROR: (instantiate_node) no such type in metamodel: " + type_name)
+		log("    for " + instance_name)
+		return ""!
+
+	actual_name = instantiated_name(element, instance_name)
+	dict_add_fast(model["model"], actual_name, element)
+	dict_add_fast(model["type_mapping"], actual_name, type_name)
+	return actual_name!
+
 String function instantiate_node(model : Element, type_name : String, instance_name : String):
 	String actual_name
 
@@ -414,7 +427,7 @@ Void function unset_attribute(model : Element, element : String, attribute : Str
 		attr_link = set_pop(attr_links)
 		dict_delete(model["type_mapping"], reverseKeyLookup(model["model"], read_edge_dst(model["model"][attr_link])))
 		dict_delete(model["type_mapping"], attr_link)
-		dict_delete_node(model["model"], reverseKeyLookup(model["model"], read_edge_dst(model["model"][attr_link])))
+		dict_delete(model["model"], reverseKeyLookup(model["model"], read_edge_dst(model["model"][attr_link])))
 		delete_element(model["model"][attr_link])
 
 	return!

+ 0 - 13
bootstrap/object_operations.alc

@@ -221,18 +221,6 @@ String function readAssociationSource(model : Element, name : String):
 String function readAssociationDestination(model : Element, name : String):
 	return reverseKeyLookup(model["model"], read_edge_dst(model["model"][name]))!
 
-String function followAssociation(model : Element, element_name : String, association_name : String):
-	Element assocs
-	String assoc
-	Element result
-
-	assocs = allOutgoingAssociationInstances(model, element_name, association_name)
-	result = create_node()
-	while (0 < list_len(assocs)):
-		set_add(result, readAssociationDestination(model, set_pop(assocs)))
-
-	return result!
-
 Element function allAssociationDestinations(model : Element, name : String, association_type : String):
 	Element tmp
 	Element result
@@ -310,7 +298,6 @@ String function read_type(model : Element, name : String):
 				return ""!
 		else:
 			log("Untyped " + name)
-			log("Type mapping: " + dict_to_string(model["type_mapping"]))
 			return ""!
 	else:
 		log("Couldn't find type of " + name)

Файловите разлики са ограничени, защото са твърде много
+ 336 - 449
core/core_algorithm.alc


+ 0 - 2
core/core_formalism.mvc

@@ -117,10 +117,8 @@ SimpleClassDiagrams CoreFormalism {
     Class ManualOperation : Transformation {}
 
     Association transformInput (Model, Transformation) {
-        name : String
     }
     Association transformOutput (Transformation, Model) {
-        name : String
     }
 
     Association tracability (Model, Model) {

+ 53 - 64
core/mini_modify.alc

@@ -8,6 +8,49 @@ include "metamodels.alh"
 include "modelling.alh"
 include "compilation_manager.alh"
 
+String function pretty_print(model : Element):
+	Element keys_m
+	String type
+	String v_m
+	Element attr_list
+	Element attr_keys
+	String attr_key
+	String result
+
+	result = ""
+	keys_m = dict_keys(model["model"])
+
+	while (read_nr_out(keys_m) > 0):
+		v_m = set_pop(keys_m)
+		type = read_type(model["metamodel"], read_type(model, v_m))
+
+		if (bool_or(type == "Class", type == "Association")):
+			result = result + ((("  " + v_m) + " : ") + read_type(model, v_m))
+			result = result + "\n"
+			if (type == "Association"):
+				result = result + ((("    " + reverseKeyLookup(model["model"], read_edge_src(model["model"][v_m]))) + " --> ") + reverseKeyLookup(model["model"], read_edge_dst(model["model"][v_m])))
+				result = result + "\n"
+
+			// Defines attributes
+			attr_list = getInstantiatableAttributes(model, v_m)
+			attr_keys = dict_keys(attr_list)
+			while (0 < read_nr_out(attr_keys)):
+				attr_key = set_pop(attr_keys)
+				result = result + (((("      " + attr_key) + " : ") + cast_v2s(attr_list[attr_key])))
+				result = result + "\n"
+
+			// Has attributes
+			attr_list = getAttributeList(model, v_m)
+			attr_keys = dict_keys(attr_list)
+			while (0 < read_nr_out(attr_keys)):
+				attr_key = set_pop(attr_keys)
+				if (element_eq(read_attribute(model, v_m, attr_key), read_root())):
+					result = result + (((("      " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = (undefined)")
+				else:
+					result = result + ((((("      " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = ") + cast_v2s(read_attribute(model, v_m, attr_key)))
+				result = result + "\n"
+	return result!
+
 Element function modify(model : Element, write : Boolean):
 	String cmd
 
@@ -84,6 +127,9 @@ Element function modify(model : Element, write : Boolean):
 								else:
 									output("Unknown destination; aborting")
 							else:
+								log("Unknown source!")
+								log("SRC: " + src_name)
+								log("In set: " + set_to_string(dict_keys(model["model"])))
 								output("Unknown source; aborting")
 						else:
 							element_name = instantiate_node(model, mm_type_name, element_name)
@@ -95,33 +141,10 @@ Element function modify(model : Element, write : Boolean):
 			else:
 				output("Permission denied")
 
-		elif (cmd == "attr_modify"):
-			if (write):
-				String model_name
-				output("Element to modify?")
-				model_name = input()
-				if (dict_in(model["model"], model_name)):
-					Element attrs
-					attrs = getAttributeList(model, model_name)
-					String attr_name
-					output("Attribute to modify?")
-					attr_name = input()
-					if (set_in(dict_keys(attrs), attr_name)):
-						output("New value?")
-						unset_attribute(model, model_name, attr_name)
-						instantiate_attribute(model, model_name, attr_name, input())
-						output("Modified!")
-					else:
-						output("No such attribute!")
-				else:
-					output("No such model!")
-			else:
-				output("Permission denied")
-
 		elif (cmd == "attr_add"):
 			if (write):
 				String model_name
-				output("Which model do you want to assign an attribute to?")
+				output("Which element do you want to assign an attribute to?")
 				model_name = input()
 				if (dict_in(model["model"], model_name)):
 					Element attrs
@@ -136,14 +159,14 @@ Element function modify(model : Element, write : Boolean):
 					else:
 						output("No such attribute!")
 				else:
-					output("No such model!")
+					output("No such element!")
 			else:
 				output("Permission denied")
 
 		elif (cmd == "attr_add_code"):
 			if (write):
 				String model_name
-				output("Which model do you want to assign a coded attribute to?")
+				output("Which element do you want to assign a coded attribute to?")
 				model_name = input()
 				if (dict_in(model["model"], model_name)):
 					Element attrs
@@ -158,14 +181,14 @@ Element function modify(model : Element, write : Boolean):
 					else:
 						output("No such attribute!")
 				else:
-					output("No such model!")
+					output("No such element!")
 			else:
 				output("Permission denied")
 
 		elif (cmd == "attr_del"):
 			if (write):
 				String model_name
-				output("Which model do you want to remove an attribute of?")
+				output("Which element do you want to remove an attribute of?")
 				model_name = input()
 				if (dict_in(model["model"], model_name)):
 					Element attrs
@@ -179,7 +202,7 @@ Element function modify(model : Element, write : Boolean):
 					else:
 						output("No such attribute!")
 				else:
-					output("No such model!")
+					output("No such element!")
 			else:
 				output("Permission denied")
 
@@ -196,41 +219,7 @@ Element function modify(model : Element, write : Boolean):
 				output("Permission denied")
 
 		elif (cmd == "nice_list"):
-			Element keys_m
-			String type
-			String v_m
-			Element attr_list
-			Element attr_keys
-			String attr_key
-
-			// TODO change log to output
-			keys_m = dict_keys(model["model"])
-
-			while (read_nr_out(keys_m) > 0):
-				v_m = set_pop(keys_m)
-				type = read_type(model["metamodel"], read_type(model, v_m))
-
-				if (bool_or(type == "Class", type == "Association")):
-					log((("  " + v_m) + " : ") + read_type(model, v_m))
-					if (type == "Association"):
-						log((("    " + reverseKeyLookup(model["model"], read_edge_src(model["model"][v_m]))) + " --> ") + reverseKeyLookup(model["model"], read_edge_dst(model["model"][v_m])))
-
-					// Defines attributes
-					attr_list = getInstantiatableAttributes(model, v_m)
-					attr_keys = dict_keys(attr_list)
-					while (0 < read_nr_out(attr_keys)):
-						attr_key = set_pop(attr_keys)
-						log(((("      " + attr_key) + " : ") + cast_v2s(attr_list[attr_key])))
-
-					// Has attributes
-					attr_list = getAttributeList(model, v_m)
-					attr_keys = dict_keys(attr_list)
-					while (0 < read_nr_out(attr_keys)):
-						attr_key = set_pop(attr_keys)
-						if (element_eq(read_attribute(model, v_m, attr_key), read_root())):
-							log(((("      " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = (undefined)")
-						else:
-							log((((("      " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = ") + cast_v2s(read_attribute(model, v_m, attr_key)))
+			pretty_print(model)
 
 		elif (cmd == "list"):
 			Element keys_m

+ 1 - 0
core/mini_modify.alh

@@ -1 +1,2 @@
 Element function modify(model : Element, write : Boolean)
+String function pretty_print(model : Element)

+ 1 - 3
core/pm.mvc

@@ -44,9 +44,7 @@ SimpleClassDiagrams ProcessModel {
     }
 
     Association Produces (Exec, Data) {}
-    Association Consumes (Exec, Data) {
-        name : String
-    }
+    Association Consumes (Exec, Data) {}
     Association Then (Decision, Activity) {}
     Association Else (Decision, Activity) {}
     Association Next (Activity, Activity) {}

+ 15 - 0
core/tracability.mvc

@@ -0,0 +1,15 @@
+import models/SimpleClassDiagrams as SimpleClassDiagrams
+
+include "primitives.alh"
+include "object_operations.alh"
+
+SimpleClassDiagrams Tracability {
+    SimpleAttribute String {}
+
+    Class Reference {}
+    Association TracabilityLink {
+        type : String
+    }
+}
+
+export Tracability to models/Tracability

+ 4 - 4
integration/code/cbd_design.mvc

@@ -2,9 +2,9 @@ import models/SimpleClassDiagrams as SCD
 include "primitives.alh"
 
 SCD CausalBlockDiagrams_Design{
-    AttributeValue Float {
+    SimpleAttribute Float {
         constraint = $
-            String constraint(model : Element, name : String):
+            String function constraint(model : Element, name : String):
                 if (bool_not(is_physical_float(model["model"][name]))):
                     return "Float has no float value"!
                 else:
@@ -12,9 +12,9 @@ SCD CausalBlockDiagrams_Design{
             $
     }
 
-    AttributeValue String {
+    SimpleAttribute String {
         constraint = $
-            String constraint(model : Element, name : String):
+            String function constraint(model : Element, name : String):
                 if (bool_not(is_physical_string(model["model"][name]))):
                     return "String has no string value"!
                 else:

+ 0 - 3
integration/code/pm_pn_reachability.mvc

@@ -31,14 +31,11 @@ ProcessModel combo_reach {
 
     Produces (initializePN, pn) {}
     Consumes (refinePN, pn) {
-        name = "pn"
     }
     Produces (refinePN, pn) {}
     Consumes (reachability, pn) {
-        name = "pn"
     }
     Produces (reachability, reachability_graph) {}
     Consumes (reachability_print, reachability_graph) {
-        name = "reachability_graph"
     }
 }

+ 9 - 21
integration/code/pn_simulate.alc

@@ -5,23 +5,9 @@ include "model_management.alh"
 include "object_operations.alh"
 include "modelling.alh"
 
-Element function simulate(inputs : Element):
-	log("Start PN step!")
-	Element outputs
-	outputs = create_node()
-
-	log("Inputs: " + dict_to_string(inputs))
-	log("PN input: " + cast_e2s(inputs["PetriNets_Runtime"]))
-	log("Outgoing: " + set_to_string(dict_keys(inputs["PetriNets_Runtime"])))
-
-	// Copy over the model to the output dictionary
-	dict_add(outputs, "PetriNets_Runtime", model_copy(inputs["PetriNets_Runtime"]))
-
-	log("Copy OK!")
-
+Boolean function simulate(model : Element):
 	// Do a single simulation step
-	Element model
-	model = outputs["PetriNets_Runtime"]
+	log("Start PN step!")
 
 	// Find enabled transitions
 	Element all_transitions
@@ -31,7 +17,9 @@ Element function simulate(inputs : Element):
 	Element in_arcs
 	String arc_under_study
 
-	all_transitions = allInstances(model, "Transition")
+	log("Got types: " + set_to_string(dict_keys(model["metamodel"]["model"])))
+
+	all_transitions = allInstances(model, "PetriNets_Runtime/Transition")
 	enabled_transitions = create_node()
 
 	while (0 < read_nr_out(all_transitions)):
@@ -39,7 +27,7 @@ Element function simulate(inputs : Element):
 		enabled = True
 
 		// Find all incoming transitions
-		in_arcs = allIncomingAssociationInstances(model, under_study, "P2T")
+		in_arcs = allIncomingAssociationInstances(model, under_study, "PetriNets_Runtime/P2T")
 
 		while (0 < read_nr_out(in_arcs)):
 			arc_under_study = set_pop(in_arcs)
@@ -68,7 +56,7 @@ Element function simulate(inputs : Element):
 	String working_place
 	Integer new_value
 
-	workset = allIncomingAssociationInstances(model, transition, "P2T")
+	workset = allIncomingAssociationInstances(model, transition, "PetriNets_Runtime/P2T")
 	while (0 < read_nr_out(workset)):
 		working_arc = set_pop(workset)
 		working_place = reverseKeyLookup(model["model"], read_edge_src(model["model"][working_arc]))
@@ -76,7 +64,7 @@ Element function simulate(inputs : Element):
 		instantiate_attribute(model, working_place, "tokens", new_value)
 
 	// Add tokens
-	workset = allOutgoingAssociationInstances(model, transition, "T2P")
+	workset = allOutgoingAssociationInstances(model, transition, "PetriNets_Runtime/T2P")
 	while (0 < read_nr_out(workset)):
 		working_arc = set_pop(workset)
 		working_place = reverseKeyLookup(model["model"], read_edge_dst(model["model"][working_arc]))
@@ -85,4 +73,4 @@ Element function simulate(inputs : Element):
 
 	// Finish up
 	log("Finished PN Step!")
-	return outputs!
+	return True!

+ 31 - 36
integration/code/reachability.alc

@@ -2,12 +2,8 @@ include "primitives.alh"
 include "modelling.alh"
 include "object_operations.alh"
 
-Element function reachability_graph(params : Element, output_mms : Element):
-	Element result
-	Element model
+Boolean function reachability_graph(model : Element):
 	Element workset
-	Element out_model
-	Element in_model
 	Element transition_vectors_produce
 	Element transition_vectors_consume
 	Element all_transitions
@@ -37,44 +33,40 @@ Element function reachability_graph(params : Element, output_mms : Element):
 	Element cache
 	cache = create_node()
 
-	result = create_node()
-	out_model = instantiate_model(output_mms["ReachabilityGraph"])
-	in_model = params["pn"]
-
 	// Create a dictionary representation for each transition
 	transition_vectors_produce = create_node()
 	transition_vectors_consume = create_node()
-	all_transitions = allInstances(in_model, "Transition")
+	all_transitions = allInstances(model, "PetriNet/Transition")
 	while (read_nr_out(all_transitions) > 0):
 		transition = set_pop(all_transitions)
 
 		tv = create_node()
-		links = allIncomingAssociationInstances(in_model, transition, "P2T")
+		links = allIncomingAssociationInstances(model, transition, "PetriNet/P2T")
 		while (read_nr_out(links) > 0):
 			link = set_pop(links)
-			name = reverseKeyLookup(in_model["model"], read_edge_src(in_model["model"][link]))
-			link_weight = read_attribute(in_model, link, "weight")
+			name = reverseKeyLookup(model["model"], read_edge_src(model["model"][link]))
+			link_weight = read_attribute(model, link, "weight")
 			dict_add_fast(tv, name, link_weight)
 		dict_add_fast(transition_vectors_consume, transition, tv)
 
 		tv = create_node()
-		links = allOutgoingAssociationInstances(in_model, transition, "T2P")
+		links = allOutgoingAssociationInstances(model, transition, "PetriNet/T2P")
 		while (read_nr_out(links) > 0):
 			link = set_pop(links)
-			name = reverseKeyLookup(in_model["model"], read_edge_dst(in_model["model"][link]))
-			link_weight = read_attribute(in_model, link, "weight")
+			name = reverseKeyLookup(model["model"], read_edge_dst(model["model"][link]))
+			link_weight = read_attribute(model, link, "weight")
 			dict_add_fast(tv, name, link_weight)
 		dict_add_fast(transition_vectors_produce, transition, tv)
 
 	workset = create_node()
 
-	all_places = allInstances(in_model, "Place")
+	all_places = allInstances(model, "PetriNet/Place")
 	dict_repr = create_node()
 	while (read_nr_out(all_places) > 0):
 		place = set_pop(all_places)
-		dict_add_fast(dict_repr, place, read_attribute(in_model, place, "tokens"))
+		dict_add_fast(dict_repr, place, read_attribute(model, place, "tokens"))
 
-	all_transitions_original = allInstances(in_model, "Transition")
+	all_transitions_original = allInstances(model, "PetriNet/Transition")
 
 	mappings = create_node()
 	state_id = 0
@@ -85,15 +77,16 @@ Element function reachability_graph(params : Element, output_mms : Element):
 	set_add(workset, state_id)
 
 	// And add in the model itself
-	state = instantiate_node(out_model, "State", cast_i2s(state_id))
-	instantiate_attribute(out_model, state, "name", cast_i2s(state_id))
+	state = instantiate_node(model, "ReachabilityGraph/InitialState", cast_i2s(state_id))
+	instantiate_attribute(model, state, "name", cast_i2s(state_id))
+	instantiate_attribute(model, state, "error", False)
 	keys = dict_keys(dict_repr)
 	while (read_nr_out(keys) > 0):
 		key = set_pop(keys)
-		place = instantiate_node(out_model, "Place", "")
-		instantiate_attribute(out_model, place, "name", read_attribute(in_model, key, "name"))
-		instantiate_attribute(out_model, place, "tokens", dict_repr[key])
-		instantiate_link(out_model, "Contains", "", state, place)
+		place = instantiate_node(model, "ReachabilityGraph/Place", "")
+		instantiate_attribute(model, place, "name", read_attribute(model, key, "name"))
+		instantiate_attribute(model, place, "tokens", dict_repr[key])
+		instantiate_link(model, "ReachabilityGraph/Contains", "", state, place)
 
 	while (read_nr_out(workset) > 0):
 		state_id = set_pop(workset)
@@ -136,6 +129,7 @@ Element function reachability_graph(params : Element, output_mms : Element):
 
 				keys = dict_keys(reachable_states)
 				target_id = -1
+				Float start
 				while (read_nr_out(keys) > 0):
 					other_state_id = set_pop(keys)
 
@@ -154,33 +148,34 @@ Element function reachability_graph(params : Element, output_mms : Element):
 					set_add(workset, target_id)
 
 					// And add in the model itself
-					state = instantiate_node(out_model, "State", cast_i2s(target_id))
-					instantiate_attribute(out_model, state, "name", cast_i2s(target_id))
+					state = instantiate_node(model, "ReachabilityGraph/State", cast_i2s(target_id))
+					instantiate_attribute(model, state, "name", cast_i2s(target_id))
+					instantiate_attribute(model, state, "error", False)
 
 					keys = dict_keys(new_dict_repr)
 					Element sub
 					String name
 					while (read_nr_out(keys) > 0):
 						key = set_pop(keys)
-						name = read_attribute(in_model, key, "name")
+						name = read_attribute(model, key, "name")
 						if (bool_not(dict_in(cache, name))):
 							dict_add_fast(cache, name, create_node())
 						sub = cache[name]
 						if (bool_not(dict_in(sub, new_dict_repr[key]))):
-							place = instantiate_node(out_model, "Place", "")
-							instantiate_attribute(out_model, place, "name", name)
-							instantiate_attribute(out_model, place, "tokens", new_dict_repr[key])
+							place = instantiate_node(model, "ReachabilityGraph/Place", "")
+							instantiate_attribute(model, place, "name", name)
+							instantiate_attribute(model, place, "tokens", new_dict_repr[key])
 							dict_add_fast(sub, new_dict_repr[key], place)
 						else:
 							place = sub[new_dict_repr[key]]
-						instantiate_link(out_model, "Contains", "", state, place)
+						instantiate_link(model, "ReachabilityGraph/Contains", "", state, place)
 
 				// Anyway, we have found a transition, which we should store
 				dict_add_fast(mappings[state_id], transition, target_id)
 
 				// And also store it in the model itself
-				new_transition = instantiate_link(out_model, "Transition", "", cast_i2s(state_id), cast_i2s(target_id))
-				instantiate_attribute(out_model, new_transition, "name", read_attribute(in_model, transition, "name"))
+				new_transition = instantiate_link(model, "ReachabilityGraph/Transition", "", cast_i2s(state_id), cast_i2s(target_id))
+				instantiate_attribute(model, new_transition, "name", read_attribute(model, transition, "name"))
 
-	dict_add_fast(result, "ReachabilityGraph", out_model)
-	return result!
+	log("# reachable states: " + cast_v2s(next_id))
+	return True!

+ 7 - 0
integration/code/reachability_graph.mvc

@@ -5,10 +5,17 @@ include "modelling.alh"
 SimpleClassDiagrams ReachabilityGraph {
     SimpleAttribute String {}
     SimpleAttribute Natural {}
+    SimpleAttribute Boolean {}
 
     Class State {
         name : String
+        error : Boolean
     }
+    Class InitialState : State {
+        lower_cardinality = 1
+        upper_cardinality = 1
+    }
+
     Class Place {
         name : String
         tokens : Natural

+ 257 - 155
integration/test_mvc.py

@@ -7,6 +7,7 @@ model_list = set(["  SimpleClassDiagrams : SimpleClassDiagrams",
                   "  ManualOperation : SimpleClassDiagrams",
                   "  ActionLanguage : SimpleClassDiagrams",
                   "  ProcessModel : SimpleClassDiagrams",
+                  "  Tracability : SimpleClassDiagrams",
                   "  core : CoreFormalism"])
 
 model_full_list = set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
@@ -14,12 +15,14 @@ model_full_list = set(["  221  root admin   SimpleClassDiagrams : SimpleClassDia
                        "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                        "  221  root admin   ManualOperation : SimpleClassDiagrams",
                        "  221  root admin   ProcessModel : SimpleClassDiagrams",
+                       "  221  root admin   Tracability : SimpleClassDiagrams",
                        "  200  root admin   core : CoreFormalism"])
 
 all_files = [   "core/mini_modify.alc",
                 "core/core_formalism.mvc",
                 "core/core_algorithm.alc",
                 "core/pm.mvc",
+                "core/tracability.mvc",
                 "primitives.alc",
                 "object_operations.alc",
                 "conformance_scd.alc",
@@ -315,10 +318,9 @@ class TestModelverseCore(unittest.TestCase):
                 "Supported metamodels:",
                 set(["  PetriNets",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 set(model_full_list) |
@@ -385,10 +387,9 @@ class TestModelverseCore(unittest.TestCase):
                 "Supported metamodels:",
                 set(["  PetriNets",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 set(["  200  root nobody   [ModelTransformation] PetriNets_Print : PetriNets_RAM"
@@ -462,22 +463,20 @@ class TestModelverseCore(unittest.TestCase):
                 "Supported metamodels:",
                 set(["  PetriNets",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 set(["  200  root nobody   [ModelTransformation] PetriNets_Print : PetriNets_RAM"
                     ]),
                 "Ready for command...",
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
+                "Which model to bind for source type PetriNets",
                 set(['"p1" --> 1',
                      '"p2" --> 2',
                      '"p3" --> 3',
                     ]),
-                "Transformation executed with result: True",
                 "Ready for command...",
             ]))
 
@@ -687,10 +686,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
@@ -699,10 +697,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
@@ -711,10 +708,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
@@ -723,10 +719,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # model_list
@@ -750,39 +745,34 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 # transformation_execute (pn_print)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
+                "Which model to bind for source type PetriNets",
                 set(['"p1" --> 1',
                      '"p2" --> 2',
                      '"p3" --> 3',
                     ]),
-                "Transformation executed with result: True",
                 "Ready for command...",
                 # transformation_execute (pn_design_to_runtime)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
-                "Which model to create for target element PetriNets_Runtime",
-                "Transformation executed with result: True",
+                "Which model to bind for source type PetriNets",
+                "Which model to create for target type PetriNets_Runtime",
                 "Ready for command...",
                 # transformation_execute (pn_step)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets_Runtime",
-                "Which model to create for target element PetriNets_Runtime",
-                "Transformation executed with result: True",
+                "Which model to bind for source type PetriNets_Runtime",
+                "Which model to create for target type PetriNets_Runtime",
                 "Ready for command...",
                 # transformation_execute (pn_runtime_to_design)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets_Runtime",
-                "Which model to create for target element PetriNets",
-                "Transformation executed with result: True",
+                "Which model to bind for source type PetriNets_Runtime",
+                "Which model to create for target type PetriNets",
                 "Ready for command...",
                 # transformation_execute (pn_print)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
+                "Which model to bind for source type PetriNets",
                 set(['"p1" --> 0',
                      '"p2" --> 1',
                      '"p3" --> 5',
                     ]),
-                "Transformation executed with result: True",
                 "Ready for command...",
             ]))
 
@@ -792,23 +782,20 @@ class TestModelverseCore(unittest.TestCase):
             return [ \
                 # transformation_execute (pn_step)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets_Runtime",
-                "Which model to create for target element PetriNets_Runtime",
-                "Transformation executed with result: True",
+                "Which model to bind for source type PetriNets_Runtime",
+                "Which model to create for target type PetriNets_Runtime",
                 "Ready for command...",
                 # transformation_execute (pn_runtime_to_design)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets_Runtime",
-                "Which model to create for target element PetriNets",
-                "Transformation executed with result: True",
+                "Which model to bind for source type PetriNets_Runtime",
+                "Which model to create for target type PetriNets",
                 "Ready for command...",
                 # transformation_execute (pn_print)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
+                "Which model to bind for source type PetriNets",
                 None,
                 None,
                 None,
-                "Transformation executed with result: True",
                 "Ready for command...",
                 ]
 
@@ -1005,10 +992,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
@@ -1017,10 +1003,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
@@ -1029,10 +1014,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
@@ -1041,10 +1025,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # model_list
@@ -1068,18 +1051,16 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 # transformation_execute (pn_print)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
+                "Which model to bind for source type PetriNets",
                 set(['"lock_available" --> 1',
                      '"critical_section_1" --> 0',
                      '"critical_section_2" --> 0',
                     ]),
-                "Transformation executed with result: True",
                 "Ready for command...",
                 # transformation_execute (pn_design_to_runtime)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
-                "Which model to create for target element PetriNets_Runtime",
-                "Transformation executed with result: True",
+                "Which model to bind for source type PetriNets",
+                "Which model to create for target type PetriNets_Runtime",
                 "Ready for command...",
                 ] + \
                     step_and_print() * 10 +
@@ -1276,10 +1257,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
@@ -1288,16 +1268,15 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_AL
-                "Which metamodels do you want to use as source for the action code (empty string to finish)?",
-                "Which metamodels do you want to use as target for the action code (empty string to finish)?",
-                "Name of Action Language model?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of operation model?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
@@ -1306,10 +1285,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # model_list
@@ -1321,6 +1299,7 @@ class TestModelverseCore(unittest.TestCase):
                      "  pn_design_to_runtime : PetriNets_RAM",
                      "  pn_runtime_to_design : PetriNets_RAM",
                      "  pn_step : ActionLanguage",
+                     "  __merged_pn_step : SimpleClassDiagrams",
                      "  __merged_PetriNets_RAM : SimpleClassDiagrams",
                      "  PetriNets_RAM : SimpleClassDiagrams",
                      "  my_pn : PetriNets",]),
@@ -1333,38 +1312,34 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 # transformation_execute (pn_print)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
+                "Which model to bind for source type PetriNets",
                 set(['"p1" --> 1',
                      '"p2" --> 2',
                      '"p3" --> 3',
                     ]),
-                "Transformation executed with result: True",
                 "Ready for command...",
                 # transformation_execute (pn_design_to_runtime)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
-                "Which model to create for target element PetriNets_Runtime",
-                "Transformation executed with result: True",
+                "Which model to bind for source type PetriNets",
+                "Which model to create for target type PetriNets_Runtime",
                 "Ready for command...",
                 # transformation_execute (pn_step)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets_Runtime",
-                "Which model to create for target element PetriNets_Runtime",
+                "Which model to bind for source type PetriNets_Runtime",
+                "Which model to create for target type PetriNets_Runtime",
                 "Ready for command...",
                 # transformation_execute (pn_runtime_to_design)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets_Runtime",
-                "Which model to create for target element PetriNets",
-                "Transformation executed with result: True",
+                "Which model to bind for source type PetriNets_Runtime",
+                "Which model to create for target type PetriNets",
                 "Ready for command...",
                 # transformation_execute (pn_print)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
+                "Which model to bind for source type PetriNets",
                 set(['"p1" --> 0',
                      '"p2" --> 1',
                      '"p3" --> 5',
                     ]),
-                "Transformation executed with result: True",
                 "Ready for command...",
             ]))
 
@@ -1573,9 +1548,9 @@ class TestModelverseCore(unittest.TestCase):
                 "Where do you want to store the RAMified metamodel?",
                 "Ready for command...",
                 # transformation_add_MANUAL
-                "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
-                "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
-                "Name of Manual operation model?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of operation model?",
                 "Ready for command...",
                 # transformation_add_MT
                 "RAMified metamodel to use?",
@@ -1583,10 +1558,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
@@ -1595,10 +1569,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
@@ -1607,10 +1580,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  PetriNets",
                      "  PetriNets_Runtime",
                     ]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # model_list
@@ -1635,17 +1607,17 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 # transformation_execute (pn_print)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
+                "Which model to bind for source type PetriNets",
                 set(['"p1" --> 1',
                      '"p2" --> 2',
                      '"p3" --> 3',
                     ]),
-                "Transformation executed with result: True",
                 "Ready for command...",
                 # transformation_execute (pn_design_to_runtime)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
-                "Which model to create for target element PetriNets_Runtime",
+                "Which model to bind for source type PetriNets",
+                "Which model to create for target type PetriNets_Runtime",
+                "Please perform manual operation \"pn_design_to_runtime\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
@@ -1654,12 +1626,12 @@ class TestModelverseCore(unittest.TestCase):
                     "Name of new element?",
                     "Instantiation successful!",
                     "Please give your command.",
-                    "Which model do you want to assign an attribute to?",
+                    "Which element do you want to assign an attribute to?",
                     "Which attribute do you wish to assign?",
                     "Value of attribute?",
                     "Added attribute!",
                     "Please give your command.",
-                    "Which model do you want to assign an attribute to?",
+                    "Which element do you want to assign an attribute to?",
                     "Which attribute do you wish to assign?",
                     "Value of attribute?",
                     "Added attribute!",
@@ -1669,12 +1641,12 @@ class TestModelverseCore(unittest.TestCase):
                     "Name of new element?",
                     "Instantiation successful!",
                     "Please give your command.",
-                    "Which model do you want to assign an attribute to?",
+                    "Which element do you want to assign an attribute to?",
                     "Which attribute do you wish to assign?",
                     "Value of attribute?",
                     "Added attribute!",
                     "Please give your command.",
-                    "Which model do you want to assign an attribute to?",
+                    "Which element do you want to assign an attribute to?",
                     "Which attribute do you wish to assign?",
                     "Value of attribute?",
                     "Added attribute!",
@@ -1684,12 +1656,12 @@ class TestModelverseCore(unittest.TestCase):
                     "Name of new element?",
                     "Instantiation successful!",
                     "Please give your command.",
-                    "Which model do you want to assign an attribute to?",
+                    "Which element do you want to assign an attribute to?",
                     "Which attribute do you wish to assign?",
                     "Value of attribute?",
                     "Added attribute!",
                     "Please give your command.",
-                    "Which model do you want to assign an attribute to?",
+                    "Which element do you want to assign an attribute to?",
                     "Which attribute do you wish to assign?",
                     "Value of attribute?",
                     "Added attribute!",
@@ -1699,7 +1671,7 @@ class TestModelverseCore(unittest.TestCase):
                     "Name of new element?",
                     "Instantiation successful!",
                     "Please give your command.",
-                    "Which model do you want to assign an attribute to?",
+                    "Which element do you want to assign an attribute to?",
                     "Which attribute do you wish to assign?",
                     "Value of attribute?",
                     "Added attribute!",
@@ -1711,7 +1683,7 @@ class TestModelverseCore(unittest.TestCase):
                     "Destination name?",
                     "Instantiation successful!",
                     "Please give your command.",
-                    "Which model do you want to assign an attribute to?",
+                    "Which element do you want to assign an attribute to?",
                     "Which attribute do you wish to assign?",
                     "Value of attribute?",
                     "Added attribute!",
@@ -1723,7 +1695,7 @@ class TestModelverseCore(unittest.TestCase):
                     "Destination name?",
                     "Instantiation successful!",
                     "Please give your command.",
-                    "Which model do you want to assign an attribute to?",
+                    "Which element do you want to assign an attribute to?",
                     "Which attribute do you wish to assign?",
                     "Value of attribute?",
                     "Added attribute!",
@@ -1735,7 +1707,7 @@ class TestModelverseCore(unittest.TestCase):
                     "Destination name?",
                     "Instantiation successful!",
                     "Please give your command.",
-                    "Which model do you want to assign an attribute to?",
+                    "Which element do you want to assign an attribute to?",
                     "Which attribute do you wish to assign?",
                     "Value of attribute?",
                     "Added attribute!",
@@ -1743,24 +1715,21 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 # transformation_execute (pn_step)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets_Runtime",
-                "Which model to create for target element PetriNets_Runtime",
-                "Transformation executed with result: True",
+                "Which model to bind for source type PetriNets_Runtime",
+                "Which model to create for target type PetriNets_Runtime",
                 "Ready for command...",
                 # transformation_execute (pn_runtime_to_design)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets_Runtime",
-                "Which model to create for target element PetriNets",
-                "Transformation executed with result: True",
+                "Which model to bind for source type PetriNets_Runtime",
+                "Which model to create for target type PetriNets",
                 "Ready for command...",
                 # transformation_execute (pn_print)
                 "Which transformation do you want to execute?",
-                "Which model to bind for source element PetriNets",
+                "Which model to bind for source type PetriNets",
                 set(['"p1" --> 0',
                      '"p2" --> 1',
                      '"p3" --> 5',
                     ]),
-                "Transformation executed with result: True",
                 "Ready for command...",
             ]))
 
@@ -1889,31 +1858,29 @@ class TestModelverseCore(unittest.TestCase):
                 "RAMified metamodel to use?",
                 "Supported metamodels:",
                 set(["  PetriNet",]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MANUAL
-                "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
-                "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
-                "Name of Manual operation model?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of operation model?",
                 "Ready for command...",
                 # transformation_add_AL
-                "Which metamodels do you want to use as source for the action code (empty string to finish)?",
-                "Which metamodels do you want to use as target for the action code (empty string to finish)?",
-                "Name of Action Language model?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of operation model?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # transformation_add_MT
                 "RAMified metamodel to use?",
                 "Supported metamodels:",
                 set(["  ReachabilityGraph",]),
-                "",
-                "Which ones do you want to use as source (empty string to finish)?",
-                "Which ones do you want to use as target (empty string to finish)?",
-                "Name of new transformation?",
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
                 # model_add
@@ -1938,12 +1905,13 @@ class TestModelverseCore(unittest.TestCase):
                      "  __merged_PetriNet_RAM : SimpleClassDiagrams",
                      "  __merged_ReachabilityGraph_RAM : SimpleClassDiagrams",
                      "  __merged_refine_PN : SimpleClassDiagrams",
+                     "  __merged_reachability : SimpleClassDiagrams",
                      ]),
                 "Ready for command...",
                 # process_execute
                 "Which process model do you want to execute?",
                 "Model prefix to use?",
-                    "Please perform manual transformation \"refine_PN\"",
+                    "Please perform manual operation \"refine_PN\"",
                     "Model loaded, ready for commands!",
                     "Use 'help' command for a list of possible commands",
                     "Please give your command.",
@@ -1952,12 +1920,12 @@ class TestModelverseCore(unittest.TestCase):
                         "Name of new element?",
                         "Instantiation successful!",
                         "Please give your command.",
-                        "Which model do you want to assign an attribute to?",
+                        "Which element do you want to assign an attribute to?",
                         "Which attribute do you wish to assign?",
                         "Value of attribute?",
                         "Added attribute!",
                         "Please give your command.",
-                        "Which model do you want to assign an attribute to?",
+                        "Which element do you want to assign an attribute to?",
                         "Which attribute do you wish to assign?",
                         "Value of attribute?",
                         "Added attribute!",
@@ -1967,7 +1935,7 @@ class TestModelverseCore(unittest.TestCase):
                         "Name of new element?",
                         "Instantiation successful!",
                         "Please give your command.",
-                        "Which model do you want to assign an attribute to?",
+                        "Which element do you want to assign an attribute to?",
                         "Which attribute do you wish to assign?",
                         "Value of attribute?",
                         "Added attribute!",
@@ -1979,7 +1947,7 @@ class TestModelverseCore(unittest.TestCase):
                         "Destination name?",
                         "Instantiation successful!",
                         "Please give your command.",
-                        "Which model do you want to assign an attribute to?",
+                        "Which element do you want to assign an attribute to?",
                         "Which attribute do you wish to assign?",
                         "Value of attribute?",
                         "Added attribute!",
@@ -2007,6 +1975,140 @@ class TestModelverseCore(unittest.TestCase):
                      "  __merged_PetriNet_RAM : SimpleClassDiagrams",
                      "  __merged_ReachabilityGraph_RAM : SimpleClassDiagrams",
                      "  __merged_refine_PN : SimpleClassDiagrams",
+                     "  __merged_reachability : SimpleClassDiagrams",
                      ]),
                 "Ready for command...",
             ]))
+
+    def test_render(self):
+        self.assertTrue(run_file(all_files,
+            [ "root", "root", "root", 
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "CausalBlockDiagrams",
+                    ] + get_model_constructor(open("integration/code/cbd_design.mvc", "r").read()) + [
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "MM_rendered_graphical",
+                    ] + get_model_constructor(open("models/MM_rendered_graphical.mvc", "r").read()) + [
+                "model_add",
+                    "CausalBlockDiagrams",
+                    "my_CBD",
+                    ] + get_model_constructor(open("integration/code/my_cbd.mvc", "r").read()) + [
+                "model_list",
+                "transformation_add_MT_language",
+                "CausalBlockDiagrams",
+                "MM_rendered_graphical",
+                "",
+                "CBD_RAM",
+                "model_modify",
+                    "__merged_CBD_RAM",
+                        "instantiate",
+                            "Association",
+                            "TracabilityLink",
+                            "CausalBlockDiagrams/Block",
+                            "MM_rendered_graphical/Group",
+                        "exit",
+                "transformation_RAMify",
+                    "__merged_CBD_RAM",
+                    "CBD_RAM",
+                "transformation_add_MT",
+                    "CBD_RAM",
+                    "CausalBlockDiagrams",
+                    "MM_rendered_graphical",
+                    "",
+                    "MM_rendered_graphical",
+                    "",
+                    "render_graphical_CBD",
+                    ] + get_model_constructor(open("models/CBD_mapper.mvc", "r").read()) + [
+                "model_list",
+                "model_render",
+                    "my_CBD",
+                    "render_graphical_CBD",
+            ],
+            [   # bootup phase
+                "Desired username for admin user?",
+                "Desired password for admin user?",
+                "Please repeat the password",
+                "Passwords match!",
+                "Welcome to the Model Management Interface v2.0!",
+                "Use the 'help' command for a list of possible commands",
+                "Ready for command...",
+                # model_add
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                # model_add
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                # model_add
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                # model_list
+                set(model_list) |
+                set([
+                    "  CausalBlockDiagrams : SimpleClassDiagrams",
+                    "  MM_rendered_graphical : SimpleClassDiagrams",
+                    "  my_CBD : CausalBlockDiagrams",
+                    ]),
+                "Ready for command...",
+                # transformation_add_MT_language
+                "Formalisms to include (terminate with empty string)?",
+                "Name of the RAMified transformation metamodel?",
+                "Ready for command...",
+                # model_modify
+                "Which model do you want to modify?",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                    # instantiate
+                    "Type to instantiate?",
+                    "Name of new element?",
+                    "Source name?",
+                    "Destination name?",
+                    "Instantiation successful!",
+                    "Please give your command.",
+                "Ready for command...",
+                # transformation_RAMify
+                "Which metamodel do you want to RAMify?",
+                "Where do you want to store the RAMified metamodel?",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  CausalBlockDiagrams",
+                     "  MM_rendered_graphical",
+                    ]),
+                "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                "Name of new operation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # model_list
+                set(model_list) |
+                set([
+                    "  CausalBlockDiagrams : SimpleClassDiagrams",
+                    "  MM_rendered_graphical : SimpleClassDiagrams",
+                    "  CBD_RAM : SimpleClassDiagrams",
+                    "  my_CBD : CausalBlockDiagrams",
+                    "  render_graphical_CBD : CBD_RAM",
+                    "  __merged_CBD_RAM : SimpleClassDiagrams",
+                     ]),
+                "Ready for command...",
+                # model_render
+                "Model to render?",
+                "Mapper to use?",
+                "Mapping success",
+                None,
+            ]))

+ 69 - 90
integration/test_powerwindow.py

@@ -7,6 +7,7 @@ model_list = set(["  SimpleClassDiagrams : SimpleClassDiagrams",
                   "  ManualOperation : SimpleClassDiagrams",
                   "  ActionLanguage : SimpleClassDiagrams",
                   "  ProcessModel : SimpleClassDiagrams",
+                  "  Tracability : SimpleClassDiagrams",
                   "  core : CoreFormalism"])
 
 model_full_list = set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
@@ -14,6 +15,7 @@ model_full_list = set(["  221  root admin   SimpleClassDiagrams : SimpleClassDia
                        "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                        "  221  root admin   ManualOperation : SimpleClassDiagrams",
                        "  221  root admin   ProcessModel : SimpleClassDiagrams",
+                       "  221  root admin   Tracability : SimpleClassDiagrams",
                        "  200  root admin   core : CoreFormalism"])
 
 all_files = [   "core/mini_modify.alc",
@@ -233,18 +235,6 @@ class TestPowerWindow(unittest.TestCase):
                     "",
                     "reachability",
                     ] + get_constructor(open("models/reachability.alc", "r").read()) + [
-                "transformation_add_AL",
-                    "PetriNet",
-                    "",
-                    "",
-                    "pn_print",
-                    ] + get_constructor(open("models/pn_print.alc", "r").read()) + [
-                "transformation_add_AL",
-                    "Encapsulated_PetriNet",
-                    "",
-                    "",
-                    "epn_print",
-                    ] + get_constructor(open("models/epn_print.alc", "r").read()) + [
                 "transformation_add_AL",
                     "ReachabilityGraph",
                     "",
@@ -333,9 +323,9 @@ class TestPowerWindow(unittest.TestCase):
                 "Ready for command...",
                 # transformation_add_MANUAL * 6
                 ] + [
-                    "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
-                    "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
-                    "Name of Manual operation model?",
+                    "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                    "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                    "Name of operation model?",
                     "Ready for command...",
                     ] * 6 + [
                 # transformation_add_MT * 6
@@ -352,19 +342,18 @@ class TestPowerWindow(unittest.TestCase):
                          "  PW_Control",
                          "  ReachabilityGraph",
                         ]),
-                    "",
-                    "Which ones do you want to use as source (empty string to finish)?",
-                    "Which ones do you want to use as target (empty string to finish)?",
-                    "Name of new transformation?",
+                    "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                    "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                    "Name of new operation?",
                     "Waiting for model constructors...",
                     "Ready for command...",
                     ] * 6 + [
-                # transformation_add_AL * 4
-                ] + [   "Which metamodels do you want to use as source for the action code (empty string to finish)?",
-                        "Which metamodels do you want to use as target for the action code (empty string to finish)?",
-                        "Name of Action Language model?",
+                # transformation_add_AL * 2
+                ] + [   "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                        "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                        "Name of operation model?",
                         "Waiting for model constructors...",
-                        "Ready for command...", ] * 4 + [
+                        "Ready for command...", ] * 2 + [
                 # model_list
                 model_list |
                 set([
@@ -382,6 +371,8 @@ class TestPowerWindow(unittest.TestCase):
                      "  revise_environment : ManualOperation",
                      "  revise_query : ManualOperation",
                      "  revise_architecture : ManualOperation",
+                     "  __merged_bfs : SimpleClassDiagrams",
+                     "  __merged_reachability : SimpleClassDiagrams",
                      "  __merged_revise_req : SimpleClassDiagrams",
                      "  __merged_All_RAM : SimpleClassDiagrams",
                      "  __merged_revise_plant : SimpleClassDiagrams",
@@ -389,8 +380,6 @@ class TestPowerWindow(unittest.TestCase):
                      "  __merged_revise_environment : SimpleClassDiagrams",
                      "  __merged_revise_query : SimpleClassDiagrams",
                      "  __merged_revise_architecture : SimpleClassDiagrams",
-                     "  pn_print : ActionLanguage",
-                     "  epn_print : ActionLanguage",
                      "  match : All_RAM",
                      "  All_RAM : SimpleClassDiagrams",
                      "  make_initial_models : All_RAM",
@@ -408,42 +397,42 @@ class TestPowerWindow(unittest.TestCase):
                 "Which process model do you want to execute?",
                 "Model prefix to use?",
                 # Manual transformation revise_req
-                "Please perform manual transformation \"revise_req\"",
+                "Please perform manual operation \"revise_req\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_plant
-                "Please perform manual transformation \"revise_plant\"",
+                "Please perform manual operation \"revise_plant\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_environment
-                "Please perform manual transformation \"revise_environment\"",
+                "Please perform manual operation \"revise_environment\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_control
-                "Please perform manual transformation \"revise_control\"",
+                "Please perform manual operation \"revise_control\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_query
-                "Please perform manual transformation \"revise_query\"",
+                "Please perform manual operation \"revise_query\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_architecture
-                "Please perform manual transformation \"revise_architecture\"",
+                "Please perform manual operation \"revise_architecture\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
@@ -775,9 +764,9 @@ class TestPowerWindow(unittest.TestCase):
                 "Ready for command...",
                 # transformation_add_MANUAL * 6
                 ] + [
-                    "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
-                    "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
-                    "Name of Manual operation model?",
+                    "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                    "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                    "Name of operation model?",
                     "Ready for command...",
                     ] * 6 + [
                 # transformation_add_MT * 6
@@ -794,17 +783,16 @@ class TestPowerWindow(unittest.TestCase):
                          "  PW_Control",
                          "  ReachabilityGraph",
                         ]),
-                    "",
-                    "Which ones do you want to use as source (empty string to finish)?",
-                    "Which ones do you want to use as target (empty string to finish)?",
-                    "Name of new transformation?",
+                    "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                    "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                    "Name of new operation?",
                     "Waiting for model constructors...",
                     "Ready for command...",
                     ] * 6 + [
                 # transformation_add_AL * 4
-                ] + [   "Which metamodels do you want to use as source for the action code (empty string to finish)?",
-                        "Which metamodels do you want to use as target for the action code (empty string to finish)?",
-                        "Name of Action Language model?",
+                ] + [   "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                        "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                        "Name of operation model?",
                         "Waiting for model constructors...",
                         "Ready for command...", ] * 4 + [
                 # model_list
@@ -824,6 +812,7 @@ class TestPowerWindow(unittest.TestCase):
                      "  revise_environment : ManualOperation",
                      "  revise_query : ManualOperation",
                      "  revise_architecture : ManualOperation",
+                     "  __merged_reachability : SimpleClassDiagrams",
                      "  __merged_revise_req : SimpleClassDiagrams",
                      "  __merged_All_RAM : SimpleClassDiagrams",
                      "  __merged_revise_plant : SimpleClassDiagrams",
@@ -831,6 +820,9 @@ class TestPowerWindow(unittest.TestCase):
                      "  __merged_revise_environment : SimpleClassDiagrams",
                      "  __merged_revise_query : SimpleClassDiagrams",
                      "  __merged_revise_architecture : SimpleClassDiagrams",
+                     "  __merged_pn_print : SimpleClassDiagrams",
+                     "  __merged_epn_print : SimpleClassDiagrams",
+                     "  __merged_bfs : SimpleClassDiagrams",
                      "  pn_print : ActionLanguage",
                      "  epn_print : ActionLanguage",
                      "  match : All_RAM",
@@ -850,42 +842,42 @@ class TestPowerWindow(unittest.TestCase):
                 "Which process model do you want to execute?",
                 "Model prefix to use?",
                 # Manual transformation revise_req
-                "Please perform manual transformation \"revise_req\"",
+                "Please perform manual operation \"revise_req\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_plant
-                "Please perform manual transformation \"revise_plant\"",
+                "Please perform manual operation \"revise_plant\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_environment
-                "Please perform manual transformation \"revise_environment\"",
+                "Please perform manual operation \"revise_environment\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_control
-                "Please perform manual transformation \"revise_control\"",
+                "Please perform manual operation \"revise_control\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_query
-                "Please perform manual transformation \"revise_query\"",
+                "Please perform manual operation \"revise_query\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_architecture
-                "Please perform manual transformation \"revise_architecture\"",
+                "Please perform manual operation \"revise_architecture\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
@@ -896,35 +888,35 @@ class TestPowerWindow(unittest.TestCase):
                 "Found error path:",
                 None,
                 # Manual transformation revise_plant
-                "Please perform manual transformation \"revise_plant\"",
+                "Please perform manual operation \"revise_plant\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_environment
-                "Please perform manual transformation \"revise_environment\"",
+                "Please perform manual operation \"revise_environment\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_control
-                "Please perform manual transformation \"revise_control\"",
+                "Please perform manual operation \"revise_control\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_query
-                "Please perform manual transformation \"revise_query\"",
+                "Please perform manual operation \"revise_query\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_architecture
-                "Please perform manual transformation \"revise_architecture\"",
+                "Please perform manual operation \"revise_architecture\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
@@ -1133,18 +1125,6 @@ class TestPowerWindow(unittest.TestCase):
                     "",
                     "reachability",
                     ] + get_constructor(open("models/reachability.alc", "r").read()) + [
-                "transformation_add_AL",
-                    "PetriNet",
-                    "",
-                    "",
-                    "pn_print",
-                    ] + get_constructor(open("models/pn_print.alc", "r").read()) + [
-                "transformation_add_AL",
-                    "Encapsulated_PetriNet",
-                    "",
-                    "",
-                    "epn_print",
-                    ] + get_constructor(open("models/epn_print.alc", "r").read()) + [
                 "transformation_add_AL",
                     "ReachabilityGraph",
                     "",
@@ -1255,9 +1235,9 @@ class TestPowerWindow(unittest.TestCase):
                 "Ready for command...",
                 # transformation_add_MANUAL * 6
                 ] + [
-                    "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
-                    "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
-                    "Name of Manual operation model?",
+                    "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                    "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                    "Name of operation model?",
                     "Ready for command...",
                     ] * 6 + [
                 # transformation_add_MT * 6
@@ -1274,19 +1254,18 @@ class TestPowerWindow(unittest.TestCase):
                          "  PW_Control",
                          "  ReachabilityGraph",
                         ]),
-                    "",
-                    "Which ones do you want to use as source (empty string to finish)?",
-                    "Which ones do you want to use as target (empty string to finish)?",
-                    "Name of new transformation?",
+                    "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                    "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                    "Name of new operation?",
                     "Waiting for model constructors...",
                     "Ready for command...",
                     ] * 6 + [
-                # transformation_add_AL * 4
-                ] + [   "Which metamodels do you want to use as source for the action code (empty string to finish)?",
-                        "Which metamodels do you want to use as target for the action code (empty string to finish)?",
-                        "Name of Action Language model?",
+                # transformation_add_AL * 2
+                ] + [   "Which metamodels do you want to use as source for the operation (empty string to finish)?",
+                        "Which metamodels do you want to use as target for the operation (empty string to finish)?",
+                        "Name of operation model?",
                         "Waiting for model constructors...",
-                        "Ready for command...", ] * 4 + [
+                        "Ready for command...", ] * 2 + [
                 # model_list
                 model_list |
                 set([
@@ -1304,6 +1283,8 @@ class TestPowerWindow(unittest.TestCase):
                      "  revise_environment : ManualOperation",
                      "  revise_query : ManualOperation",
                      "  revise_architecture : ManualOperation",
+                     "  __merged_bfs : SimpleClassDiagrams",
+                     "  __merged_reachability : SimpleClassDiagrams",
                      "  __merged_revise_req : SimpleClassDiagrams",
                      "  __merged_All_RAM : SimpleClassDiagrams",
                      "  __merged_revise_plant : SimpleClassDiagrams",
@@ -1311,8 +1292,6 @@ class TestPowerWindow(unittest.TestCase):
                      "  __merged_revise_environment : SimpleClassDiagrams",
                      "  __merged_revise_query : SimpleClassDiagrams",
                      "  __merged_revise_architecture : SimpleClassDiagrams",
-                     "  pn_print : ActionLanguage",
-                     "  epn_print : ActionLanguage",
                      "  match : All_RAM",
                      "  All_RAM : SimpleClassDiagrams",
                      "  make_initial_models : All_RAM",
@@ -1330,42 +1309,42 @@ class TestPowerWindow(unittest.TestCase):
                 "Which process model do you want to execute?",
                 "Model prefix to use?",
                 # Manual transformation revise_req
-                "Please perform manual transformation \"revise_req\"",
+                "Please perform manual operation \"revise_req\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_plant
-                "Please perform manual transformation \"revise_plant\"",
+                "Please perform manual operation \"revise_plant\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_environment
-                "Please perform manual transformation \"revise_environment\"",
+                "Please perform manual operation \"revise_environment\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_control
-                "Please perform manual transformation \"revise_control\"",
+                "Please perform manual operation \"revise_control\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_query
-                "Please perform manual transformation \"revise_query\"",
+                "Please perform manual operation \"revise_query\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_architecture
-                "Please perform manual transformation \"revise_architecture\"",
+                "Please perform manual operation \"revise_architecture\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
@@ -1376,35 +1355,35 @@ class TestPowerWindow(unittest.TestCase):
                 "Found error path:",
                 None,
                 # Manual transformation revise_plant
-                "Please perform manual transformation \"revise_plant\"",
+                "Please perform manual operation \"revise_plant\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_environment
-                "Please perform manual transformation \"revise_environment\"",
+                "Please perform manual operation \"revise_environment\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_control
-                "Please perform manual transformation \"revise_control\"",
+                "Please perform manual operation \"revise_control\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_query
-                "Please perform manual transformation \"revise_query\"",
+                "Please perform manual operation \"revise_query\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
                 # Manual transformation revise_architecture
-                "Please perform manual transformation \"revise_architecture\"",
+                "Please perform manual operation \"revise_architecture\"",
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",

+ 1 - 1
integration/utils.py

@@ -175,7 +175,7 @@ def run_file(files, parameters, expected, wait=False):
                     # Modelverse has already terminated, which isn't a good sign!
                     raise Exception("Modelverse died!")
 
-                #print("Got %s, expect %s" % (val, e))
+                print("Got %s, expect %s" % (val, e))
                 if isinstance(e, set):
                     assert val in e
                     if val not in e:

+ 2 - 2
interface/HUTN/includes/model_management.alh

@@ -1,5 +1,5 @@
 Element function model_fuse(models : Element)
 Element function model_copy(model : Element)
 Element function model_retype_on_name(model : Element, new_MM : Element, operation : String, name : String)
-Void function model_join(target_model : Element, source_model : Element, retyping_key : String)
-Element function model_split(source_model : Element, target_metamodel : Element, retyping_key : String)
+Element function model_join(models : Element, metamodel : Element, tracability : Element)
+Element function model_split(merged_model : Element, models : Element, tracability : Boolean)

+ 5 - 4
interface/HUTN/includes/modelling.alh

@@ -7,15 +7,16 @@ Void function retype_model(model : Element, metamodel : Element)
 Void function retype(model : Element, element : String, type : String)
 Element function instantiate_model(metamodel : Element)
 String function instantiate_node(model : Element, type_name : String, instance_name : String)
+String function instantiate_link(model : Element, type : String, name : String, source : String, destination : String)
 String function instantiate_value(model : Element, type_name : String, instance_name : String, value : Element)
+Void function instantiate_attribute(model : Element, element : String, attribute_name : String, value : Element)
+Void function instantiate_attribute_code(model : Element, element : String, attribute_name : String, code : Element)
+Void function instantiate_existing_attribute(model : Element, element : String, attribute_name : String, attribute_ref : String)
+String function reuse_element(model : Element, type_name : String, instance_name : String, element : Element)
 Element function find_attribute_type(model : Element, elem : String, name : String)
 Element function get_superclasses(model : Element, elem : Element)
 Element function get_subclasses(model : Element, elem : Element)
 Element function find_attribute_definer(model : Element, elem : Element, name : String)
-Void function instantiate_attribute(model : Element, element : String, attribute_name : String, value : Element)
-Void function instantiate_attribute_code(model : Element, element : String, attribute_name : String, code : Element)
-Void function instantiate_existing_attribute(model : Element, element : String, attribute_name : String, attribute_ref : String)
-String function instantiate_link(model : Element, type : String, name : String, source : String, destination : String)
 Void function unset_attribute(model : Element, elem : String, name : String)
 Void function construct_model()
 Element function read_attribute(model : Element, elem : String, name : String)

+ 0 - 1
interface/HUTN/includes/object_operations.alh

@@ -10,7 +10,6 @@ Element function reverseKeyLookupMulti(a: Element, b: Element)
 String function print_dict(dict : Element)
 String function readAssociationSource(model : Element, name : String)
 String function readAssociationDestination(model : Element, name : String)
-String function followAssociation(model : Element, element_name : String, association_name : String)
 Element function allAssociationDestinations(model : Element, name : String, association_type : String)
 Element function allAssociationOrigins(model : Element, name : String, association_type : String)
 Element function allowedAssociationsBetween(model : Element, src : String, dst : String)

+ 1 - 1
kernel/modelverse_jit/intrinsics.py

@@ -298,7 +298,7 @@ MISC_INTRINSICS = {
     'dict_len' : __read_nr_out,
 
     # Set operations
-    'set_add' : __set_add,
+    #'set_add' : __set_add,
 
     # List operations
     'list_len' : __read_nr_out,

+ 3 - 1
kernel/modelverse_jit/jit.py

@@ -834,7 +834,9 @@ def favor_small_functions(body_bytecode):
 
 ADAPTIVE_JIT_LOOP_INSTRUCTION_MULTIPLIER = 4
 
-ADAPTIVE_BASELINE_JIT_TEMPERATURE_THRESHOLD = 100
+#ADAPTIVE_BASELINE_JIT_TEMPERATURE_THRESHOLD = 100
+# TODO bug in the ByteCode Interpreter results in erroneous execution with random jumps; disable for now!
+ADAPTIVE_BASELINE_JIT_TEMPERATURE_THRESHOLD = -float('inf')
 """The threshold temperature at which the adaptive JIT will use the baseline JIT."""
 
 ADAPTIVE_FAST_JIT_TEMPERATURE_THRESHOLD = 250

+ 79 - 324
kernel/modelverse_kernel/compiled_legacy.py

@@ -1,6 +1,29 @@
 from modelverse_kernel.primitives import PrimitiveFinished
 
+
+def reverseKeyLookupMulti(a, b, **remainder):
+    edges, = yield [("RO", [a])]
+    b_val, = yield [("RV", [b])]
+    expanded_edges = yield [("RE", [i]) for i in edges]
+    values = yield [("RV", [i[1]]) for i in expanded_edges]
+    result, = yield [("CN", [])]
+
+    for i, edge in enumerate(values):
+        if b_val == edge:
+            # Found our edge: edges[i]
+            outgoing, = yield [("RO", [edges[i]])]
+            value, = yield [("RE", [outgoing[0]])]
+            yield [("CE", [result, value[1]])]
+
+    raise PrimitiveFinished(result)
+
 def reverseKeyLookup(a, b, **remainder):
+    # Guess, which might work
+    guess, = yield [("RD", [a, "__%s" % b])]
+    if guess == b:
+        result, = yield [("CNV", ["__%s" % b])]
+        raise PrimitiveFinished(result)
+
     edges, = yield [("RO", [a])]
     expanded_edges = yield [("RE", [i]) for i in edges]
     for i, edge in enumerate(expanded_edges):
@@ -13,41 +36,6 @@ def reverseKeyLookup(a, b, **remainder):
     result, = yield [("CNV", ["(unknown: %s)" % b])]
     raise PrimitiveFinished(result)
 
-"""
-def read_attribute(a, b, c, **remainder):
-    model_dict, b_val, c_val, type_mapping = \
-                    yield [("RD", [a, "model"]),
-                           ("RV", [b]),
-                           ("RV", [c]),
-                           ("RD", [a, "type_mapping"]),
-                           ]
-    model_instance, = \
-                    yield [("RD", [model_dict, b_val])]
-    edges, =        yield [("RO", [model_instance])]
-    edge_types =    yield [("RDN", [type_mapping, i]) for i in edges]
-    type_edge_val = yield [("RE", [i]) for i in edge_types]
-
-    src_nodes = set([i[0] for i in type_edge_val])
-
-    found_edges =   yield [("RDE", [i, c_val]) for i in src_nodes]
-
-    for e1 in found_edges:
-        if e1 is not None:
-            # Found an edge!
-            for i, e2 in enumerate(edge_types):
-                if e1 == e2:
-                    # The instance of this edge is the one we want!
-                    edge = edges[i]
-                    edge_val, = yield [("RE", [edge])]
-                    result = edge_val[1]
-                    raise PrimitiveFinished(result)
-    else:
-        result, = yield [("RR", [])]
-        raise PrimitiveFinished(result)
-
-    raise Exception("Error in reading edge!")
-"""
-
 def set_copy(a, **remainder):
     b, =         yield [("CN", [])]
     links, =     yield [("RO", [a])]
@@ -55,294 +43,6 @@ def set_copy(a, **remainder):
     _ =         yield [("CE", [b, i[1]]) for i in exp_links]
     raise PrimitiveFinished(b)
 
-"""
-def allInstances(a, b, **remainder):
-    b_val, =     yield [("RV", [b])]
-    model_dict,= yield [("RD", [a, "model"])]
-    metamodel, = yield [("RD", [a, "metamodel"])]
-    m3, =        yield [("RD", [metamodel, "metamodel"])]
-    m3_model, =  yield [("RD", [m3, "model"])]
-    mm_dict, =   yield [("RD", [metamodel, "model"])]
-    typing, =    yield [("RD", [a, "type_mapping"])]
-    elem_keys, = yield [("RDK", [model_dict])]
-    elems =     yield [("RDN", [model_dict, i]) for i in elem_keys]
-    mms =       yield [("RDN", [typing, i]) for i in elems]
-
-    # Have the type for each name
-    types_to_name_nodes = {}
-    for key, mm in zip(elem_keys, mms):
-        types_to_name_nodes.setdefault(mm, set()).add(key)
-    # And now we have the inverse mapping: for each type, we have the node containing the name
-
-    # Get the inheritance link type
-    inheritance_type, =  yield [("RD", [m3_model, "Inheritance"])]
-
-    # Now we figure out which types are valid for the specified model
-    desired_types = set()
-    mm_element, =    yield [("RD", [mm_dict, b_val])]
-
-    work_list = []
-    work_list.append(mm_element)
-    mm_typing, =     yield [("RD", [metamodel, "type_mapping"])]
-
-    while work_list:
-        mm_element = work_list.pop()
-        if mm_element in desired_types:
-            # Already been here, so stop
-            continue
-
-        # New element, so continue
-        desired_types.add(mm_element)
-
-        # Follow all inheritance links that COME IN this node, as all these are subtypes and should also match
-        incoming, =  yield [("RI", [mm_element])]
-        for i in incoming:
-            t, =     yield [("RDN", [mm_typing, i])]
-            if t == inheritance_type:
-                e, = yield [("RE", [i])]
-                # Add the source of the inheritance link to the work list
-                work_list.append(e[0])
-
-    # Now desired_types holds all the direct types that we are interested in!
-    # Construct the result out of all models that are direct instances of our specified type
-    final = set()
-    for t in desired_types:
-        final |= types_to_name_nodes.get(t, set())
-
-    # Result is a Python set with nodes, so just make this a Mv set
-    result, =    yield [("CN", [])]
-    v =         yield [("RV", [i]) for i in final]
-    _ =    yield [("CE", [result, i]) for i in final]
-    raise PrimitiveFinished(result)
-"""
-
-"""
-def add_AL(a, b, **remainder):
-    worklist = [(b, "funcdef")]
-    added = set()
-    type_cache = {}
-
-    model_dict, = yield [("RD", [a, "model"])]
-    metamodel, = yield [("RD", [a, "metamodel"])]
-    metamodel_dict, = yield [("RD", [metamodel, "model"])]
-    type_map, = yield [("RD", [a, "type_mapping"])]
-    outgoing, = yield [("RO", [model_dict])]
-    edges = yield [("RE", [i]) for i in outgoing]
-    added |= set([i[1] for i in edges])
-
-    result, = yield [("CNV", ["__%s" % b])]
-
-    # All the action language elements and their expected output links
-    type_links = {
-            "if":       [("cond", ""), ("then", ""), ("else", ""), ("next", "")],
-            "while":    [("cond", ""), ("body", ""), ("next", "")],
-            "assign":   [("var", ""), ("value", ""), ("next", "")],
-            "break":    [("while", "while")],
-            "continue": [("while", "while")],
-            "return":   [("value", "")],
-            "resolve":  [("var", "")],
-            "access":   [("var", "")],
-            "constant": [("node", "")],
-            "output":   [("node", ""), ("next", "")],
-            "global":   [("var", "String"), ("next", "")],
-            "param":    [("name", "String"), ("value", ""), ("next_param", "param")],
-            "funcdef":  [("body", ""), ("next", "")],
-            "call":     [("func", ""), ("params", "param"), ("last_param", "param"), ("next", "")],
-        }
-
-    # Already add some often used types to the type cache, so we don't have to check for their presence
-    to_str, string = yield [("RD", [metamodel_dict, "to_str"]),
-                            ("RD", [metamodel_dict, "String"])]
-
-    type_cache = {"to_str": to_str,
-                  "String": string}
-
-    while worklist:
-        # Fetch the element and see if we need to add it
-        worknode, expected_type = worklist.pop(0)
-        if worknode in added:
-            continue
-
-        # Determine type of element
-        if expected_type == "":
-            value, = yield [("RV", [worknode])]
-            if (isinstance(value, dict)) and ("value" in value):
-                v = value["value"]
-                if v in ["if", "while", "assign", "call", "break", "continue", "return", "resolve", "access", "constant", "global", "declare"]:
-                    expected_type = v
-                else:
-                    expected_type = "Any"
-            else:
-                expected_type = "Any"
-
-        # Fill the cache
-        if expected_type not in type_cache:
-            type_cache[expected_type], = yield [("RD", [metamodel_dict, expected_type])]
-
-        # Need to add it now
-        yield [("CD", [model_dict, "__%s" % worknode, worknode])]
-        added.add(worknode)
-        # NOTE can't just use CD here, as the key is a node and not a value
-        t1, = yield [("CE", [type_map, type_cache[expected_type]])]
-        t2, = yield [("CE", [t1, worknode])]
-        if t1 is None or t2 is None:
-            raise Exception("ERROR")
-
-        # Now add all its outgoing links, depending on the type we actually saw
-        links = type_links.get(expected_type, [])
-        for link in links:
-            link_name, destination_type = link
-
-            # Check if the link actually exists
-            destination, = yield [("RD", [worknode, link_name])]
-            if destination is not None:
-                # If so, we add it and continue
-                edge, = yield [("RDE", [worknode, link_name])]
-                edge_outlinks, = yield [("RO", [edge])]
-                edge_outlink = edge_outlinks[0]
-                edge_name, = yield [("RE", [edge_outlink])]
-                edge_name = edge_name[1]
-                # Now add: edge, edge_outlink, edge_name
-
-                # Add 'edge'
-                yield [("CD", [model_dict, "__%s" % edge, edge])]
-                added.add(edge)
-                link_type = "%s_%s" % (expected_type, link_name)
-                if link_type not in type_cache:
-                    type_cache[link_type], = yield [("RD", [metamodel_dict, link_type])]
-                t, = yield [("CE", [type_map, type_cache[link_type]])]
-                yield [("CE", [t, edge])]
-
-                # Add 'edge_outlink'
-                yield [("CD", [model_dict, "__%s" % edge_outlink, edge_outlink])]
-                added.add(edge_outlink)
-                t, = yield [("CE", [type_map, type_cache["to_str"]])]
-                yield [("CE", [t, edge_outlink])]
-
-                # Add 'edge_name' (if not present)
-                if edge_name not in added:
-                    yield [("CD", [model_dict, "__%s" % edge_name, edge_name])]
-                    t, = yield [("CE", [type_map, type_cache["String"]])]
-                    yield [("CE", [t, edge_name])]
-                    added.add(edge_name)
-
-                # Add the destination to the worklist
-                worklist.append((destination, destination_type))
-
-    raise PrimitiveFinished(result)
-"""
-
-"""
-def get_superclasses(a, b, **remainder):
-    mm, =            yield [("RD", [a, "metamodel"])]
-    mm, =            yield [("RD", [mm, "metamodel"])]
-    m, =             yield [("RD", [mm, "model"])]
-    inheritance, =   yield [("RD", [m, "Inheritance"])]
-    model_dict, =    yield [("RD", [a, "model"])]
-    b_v, =           yield [("RV", [b])]
-    subclass, =      yield [("RD", [model_dict, b_v])]
-    type_mapping, =  yield [("RD", [a, "type_mapping"])]
-    names, =         yield [("RDK", [model_dict])]
-    elems =         yield [("RDN", [model_dict, i]) for i in names]
-    elem_to_name =  dict(zip(elems, names))
-
-    result, =        yield [("CN", [])]
-    worklist = [subclass]
-
-    touched = set()
-
-    while worklist:
-        subclass = worklist.pop()
-        res = elem_to_name[subclass]
-
-        if subclass not in touched:
-            touched.add(subclass)
-            yield [("CE", [result, res])]
-
-            outgoing, =      yield [("RO", [subclass])]
-            types =         yield [("RDN", [type_mapping, i]) for i in outgoing]
-
-            for i, t in enumerate(types):
-                if t == inheritance:
-                    # Found an inheritance link!
-                    elem = outgoing[i]
-                    srcdst, = yield [("RE", [elem])]
-                    src, dst = srcdst
-                    # Find elem in elems
-                    worklist.append(dst)
-
-    raise PrimitiveFinished(result)
-"""
-
-"""
-def selectPossibleIncoming(a, b, c, **remainder):
-    model_dict, =    yield [("RD", [a, "model"])]
-    limit_set_links, = \
-                    yield [("RO", [c])]
-    limit_set =     yield [("RE", [i]) for i in limit_set_links]
-    limit_set_names = [i[1] for i in limit_set]
-    name_values =   yield [("RV", [i]) for i in limit_set_names]
-    limit_set =     yield [("RD", [model_dict, i]) for i in name_values]
-
-    try:
-        gen = get_superclasses(a, b)
-        inp = None
-        while 1:
-            inp =   yield gen.send(inp)
-    except PrimitiveFinished as e:
-        superclasses = e.result
-        vals, = yield [("RO", [superclasses])]
-        superclasses = yield [("RE", [i]) for i in vals]
-        superclasses = [i[1] for i in superclasses]
-
-    superclass_names = yield [("RV", [i]) for i in superclasses]
-    elems =         yield [("RD", [model_dict, i]) for i in superclass_names]
-
-    result, =        yield [("CN", [])]
-    for i, edge in enumerate(limit_set):
-        srcdst, =  yield [("RE", [edge])]
-        src, dst = srcdst
-        if dst in elems:
-            yield [("CE", [result, limit_set_names[i]])]
-
-    raise PrimitiveFinished(result)
-"""
-
-"""
-def selectPossibleOutgoing(a, b, c, **remainder):
-    model_dict, =    yield [("RD", [a, "model"])]
-    limit_set_links, = \
-                    yield [("RO", [c])]
-    limit_set =     yield [("RE", [i]) for i in limit_set_links]
-    limit_set_names = \
-                    [i[1] for i in limit_set]
-    name_values =   yield [("RV", [i]) for i in limit_set_names]
-    limit_set =     yield [("RD", [model_dict, i]) for i in name_values]
-
-    try:
-        gen = get_superclasses(a, b)
-        inp = None
-        while 1:
-            inp =  yield gen.send(inp)
-    except PrimitiveFinished as e:
-        superclasses = e.result
-        vals, = yield [("RO", [superclasses])]
-        superclasses = yield [("RE", [i]) for i in vals]
-        superclasses = [i[1] for i in superclasses]
-
-    superclass_names = yield [("RV", [i]) for i in superclasses]
-    elems =         yield [("RD", [model_dict, i]) for i in superclass_names]
-
-    result, =        yield [("CN", [])]
-    for i, edge in enumerate(limit_set):
-        srcdst, =  yield [("RE", [edge])]
-        src, dst = srcdst
-        if src in elems:
-            yield [("CE", [result, limit_set_names[i]])]
-
-    raise PrimitiveFinished(result)
-"""
-
 def check_symbols(a, b, c, **remainder):
     symbols = {}
     function_name, = yield [("RV", [b])]
@@ -363,7 +63,7 @@ def check_symbols(a, b, c, **remainder):
             k = key
             v = value
             if v and symbols.get(k, False):
-                result = yield [("CNV", ["ERROR: multiple definition of symbol " + str(key)])]
+                result, = yield [("CNV", ["ERROR: multiple definition of symbol " + str(key)])]
                 raise PrimitiveFinished(result)
             elif v and not symbols.get(k, False):
                 symbols[k] = True
@@ -419,3 +119,58 @@ def __get_input(parameters):
             else:
                 # No input, so yield None but don't stop
                 yield None
+
+def instantiated_name(a, b, **remainder):
+    name_value, = yield [("RV", [b])]
+    if name_value == "":
+        b, = yield [("CNV", ["__" + str(a)])]
+    raise PrimitiveFinished(b)
+
+def set_merge(a, b, **remainder):
+    outputs, = yield [("RO", [b])]
+    values = yield [("RE", [i]) for i in outputs]
+    yield [("CE", [a, i[1]]) for i in values]
+    raise PrimitiveFinished(a)
+
+def has_value(a, **remainder):
+    v, = yield [("RV", [a])]
+    if v is None:
+        result, = yield [("CNV", [False])]
+    else:
+        result, = yield [("CNV", [True])]
+    raise PrimitiveFinished(result)
+
+def make_reverse_dictionary(a, **remainder):
+    reverse, = yield [("CN", [])]
+    key_nodes, = yield [("RDK", [a])]
+    values = yield [("RDN", [a, i]) for i in key_nodes]
+    yield [("CD", [reverse, str(v), k]) for k, v in zip(key_nodes, values)]
+    raise PrimitiveFinished(reverse)
+
+def dict_eq(a, b, **remainder):
+    key_nodes, = yield [("RDK", [a])]
+    key_values = yield [("RV", [i]) for i in key_nodes]
+    values = yield [("RD", [a, i]) for i in key_values]
+    values = yield [("RV", [i]) for i in values]
+    a_dict = dict(zip(key_values, values))
+
+    key_nodes, = yield [("RDK", [b])]
+    key_values = yield [("RV", [i]) for i in key_nodes]
+    values = yield [("RD", [b, i]) for i in key_values]
+    values = yield [("RV", [i]) for i in values]
+    b_dict = dict(zip(key_values, values))
+
+    result, = yield [("CNV", [a_dict == b_dict])]
+    raise PrimitiveFinished(result)
+
+def string_substr(a, b, c, **remainder):
+    a_val, b_val, c_val = yield [("RV", [a]),
+                                 ("RV", [b]),
+                                 ("RV", [c])]
+    try:
+        new_value = a_val[b_val:c_val]
+    except:
+        new_value = ""
+
+    result, = yield [("CNV", [new_value])]
+    raise PrimitiveFinished(result)

+ 4 - 1
kernel/modelverse_kernel/primitives.py

@@ -440,11 +440,14 @@ def read_root(root, **remainder):
 def set_add(a, b, **remainder):
     #yield [("CE", [a, b])]
     #raise PrimitiveFinished(a)
+
     outgoing, b_value = yield [("RO", [a]), ("RV", [b])]
     if outgoing:
         elements = yield [("RE", [i]) for i in outgoing]
         values = yield [("RV", [i[1]]) for i in elements]
-        if b_value in values:
+        if b_value is not None and b_value in values:
+            raise PrimitiveFinished(a)
+        elif b_value is None and b in elements:
             raise PrimitiveFinished(a)
         else:
             yield [("CE", [a, b])]

+ 216 - 0
models/CBD_mapper.mvc

@@ -0,0 +1,216 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+
+A B {
+    Composite schedule {
+        {Contains} Success success {}
+
+        {Contains} ForAll render_blocks {
+            LHS {
+                Pre_CausalBlockDiagrams/Block pre_block_0 {
+                    label = "0"
+                }
+            }
+            RHS {
+                Post_CausalBlockDiagrams/Block post_block_0 {
+                    label = "0"
+                }
+                Post_MM_rendered_graphical/Group post_block_1 {
+                    label = "1"
+                    value_x = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                    value_y = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                }
+                Post_MM_rendered_graphical/Rectangle post_block_2 {
+                    label = "2"
+                    value_x = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                    value_y = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                    value_width = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 10!
+                        $
+                    value_height = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 10!
+                        $
+                    value_lineWidth = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 2!
+                        $
+                    value_lineColour = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "black"!
+                        $
+                    value_fillColour = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "white"!
+                        $
+                }
+                Post_MM_rendered_graphical/Text post_block_3 {
+                    label = "3"
+                    value_x = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 10!
+                        $
+                    value_y = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 10!
+                        $
+                    value_lineWidth = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 1!
+                        $
+                    value_lineColour = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "black"!
+                        $
+                    value_text = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            String type
+                            type = read_type(model, mapping["0"])
+                            if (type == "CausalBlockDiagrams/AdditionBlock"):
+                                return "+"!
+                            elif (type == "CausalBlockDiagrams/NegatorBlock"):
+                                return "-"!
+                            elif (type == "CausalBlockDiagrams/ConstantBlock"):
+                                return "c"!
+                            elif (type == "CausalBlockDiagrams/MultiplyBlock"):
+                                return "*"!
+                            elif (type == "CausalBlockDiagrams/InverseBlock"):
+                                return "/"!
+                            elif (type == "CausalBlockDiagrams/DerivatorBlock"):
+                                return "d/dx"!
+                            elif (type == "CausalBlockDiagrams/IntegratorBlock"):
+                                return "1/s"!
+                            elif (type == "CausalBlockDiagrams/DelayBlock"):
+                                return "DELAY"!
+                            elif (type == "CausalBlockDiagrams/ProbeBlock"):
+                                return "PROBE"!
+                            else:
+                                return ("Unknown type: " + type)!
+                        $
+                }
+                Post_MM_rendered_graphical/contains (post_block_1, post_block_2) {
+                    label = "4"
+                }
+                Post_MM_rendered_graphical/contains (post_block_1, post_block_3) {
+                    label = "5"
+                }
+
+                Post_TracabilityLink (post_block_0, post_block_1) {
+                    label = "6"
+                }
+            }
+        }
+
+        {Contains} ForAll render_connections {
+            LHS {
+                Pre_CausalBlockDiagrams/Block pre_conn_0 {
+                    label = "0"
+                }
+
+                Pre_CausalBlockDiagrams/Block pre_conn_1 {
+                    label = "1"
+                }
+
+                Pre_CausalBlockDiagrams/Link (pre_conn_0, pre_conn_1){
+                    label = "2"
+                }
+
+                Pre_MM_rendered_graphical/Group pre_conn_3 {
+                    label = "3"
+                }
+
+                Pre_MM_rendered_graphical/Group pre_conn_4 {
+                    label = "4"
+                }
+
+                Pre_TracabilityLink (pre_conn_0, pre_conn_3) {
+                    label = "5"
+                }
+                Pre_TracabilityLink (pre_conn_1, pre_conn_4) {
+                    label = "6"
+                }
+            }
+            RHS {
+                Post_CausalBlockDiagrams/Block post_conn_0 {
+                    label = "0"
+                }
+
+                Post_CausalBlockDiagrams/Block post_conn_1 {
+                    label = "1"
+                }
+
+                Post_CausalBlockDiagrams/Link (post_conn_0, post_conn_1){
+                    label = "2"
+                }
+
+                Post_MM_rendered_graphical/Group post_conn_3 {
+                    label = "3"
+                }
+
+                Post_MM_rendered_graphical/Group post_conn_4 {
+                    label = "4"
+                }
+
+                Post_TracabilityLink (post_conn_0, post_conn_3) {
+                    label = "5"
+                }
+                Post_TracabilityLink (post_conn_1, post_conn_4) {
+                    label = "6"
+                }
+
+                Post_MM_rendered_graphical/Line {
+                    label = "7"
+                    value_x = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["3"], "x")!
+                        $
+                    value_y = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["3"], "y")!
+                        $
+                    value_lineWidth = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 1!
+                        $
+                    value_lineColour = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            if (read_type(model, name) == "ICLink"):
+                                return "red"!
+                            else:
+                                return "black"!
+                        $
+                    value_targetX = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["4"], "x")!
+                        $
+                    value_targetY = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["4"], "y")!
+                        $
+                }
+            }
+        }
+    }
+
+    Initial (schedule, render_blocks) {}
+
+    OnSuccess (render_blocks, render_connections) {}
+    OnFailure (render_blocks, render_connections) {}
+
+    OnSuccess (render_connections, success) {}
+    OnFailure (render_connections, success) {}
+}

+ 59 - 0
models/MM_rendered_graphical.mvc

@@ -0,0 +1,59 @@
+include "primitives.alh"
+
+SimpleClassDiagram MM_rendered_graphical{
+    SimpleAttribute Natural {}
+    SimpleAttribute String {}
+
+    Class GraphicalElement {
+        x : Natural
+        y : Natural
+    }
+
+    Class Group : GraphicalElement {
+    }
+
+    Class LineElement : GraphicalElement {
+        lineWidth : Natural
+        lineColour : String
+    }
+
+    Class Text : LineElement {
+        text : String
+    }
+
+    Class Line : LineElement {
+        targetX : Natural
+        targetY : Natural
+    }
+
+    Class Shape : LineElement {
+        fillColour : String
+        width : Natural
+        height : Natural
+    }
+
+    Class Figure : GraphicalElement {
+        width : Natural
+        height : Natural
+    }
+
+    Class SVG {
+        data : String
+    }
+
+    Class Rectangle : Shape {
+    }
+
+    Class Ellipse : Shape {
+    }
+
+    Class Polygon : Shape {
+    }
+
+    Association contains (Group, GraphicalElement) {}
+    Association renders (Figure, SVG) {
+        source_lower_cardinality = 1
+        target_lower_cardinality = 1
+        target_upper_cardinality = 1
+    }
+}

+ 5 - 7
models/bfs.alc

@@ -2,8 +2,7 @@ include "primitives.alh"
 include "modelling.alh"
 include "object_operations.alh"
 
-Element function bfs(params : Element, output_mms : Element):
-	Element model
+Boolean function bfs(model : Element):
 	String initial
 	Element options
 	Element worklist
@@ -16,12 +15,11 @@ Element function bfs(params : Element, output_mms : Element):
 	String dest
 	Integer total_states
 
-	model = params["reachability_graph"]
-	total_states = read_nr_out(allInstances(model, "State"))
+	total_states = read_nr_out(allInstances(model, "ReachabilityGraph/State"))
 
 	worklist = create_node()
 	visited = create_node()
-	initial = set_pop(allInstances(model, "InitialState"))
+	initial = set_pop(allInstances(model, "ReachabilityGraph/InitialState"))
 	list_append(worklist, create_tuple(initial, create_node()))
 	set_add(visited, initial)
 
@@ -42,7 +40,7 @@ Element function bfs(params : Element, output_mms : Element):
 			output(list_to_string(path))
 			break!
 
-		options = allOutgoingAssociationInstances(model, state, "Transition")
+		options = allOutgoingAssociationInstances(model, state, "ReachabilityGraph/Transition")
 
 		while (read_nr_out(options) > 0):
 			option = set_pop(options)
@@ -56,4 +54,4 @@ Element function bfs(params : Element, output_mms : Element):
 				list_append(worklist, create_tuple(dest, path_copy))
 				set_add(visited, dest)
 
-	return create_node()!
+	return True!

+ 7 - 10
models/epn_print.alc

@@ -2,10 +2,7 @@ include "primitives.alh"
 include "modelling.alh"
 include "object_operations.alh"
 
-Element function pn_print(params : Element, output_mms : Element):
-	Element model
-	model = params["epn"]
-
+Boolean function pn_print(model : Element):
 	Element all_places
 	String place
 	String name
@@ -14,7 +11,7 @@ Element function pn_print(params : Element, output_mms : Element):
 	String t
 
 	log("Places:")
-	all_places = allInstances(model, "Place")
+	all_places = allInstances(model, "Encapsulated_PetriNet/Place")
 	while (read_nr_out(all_places) > 0):
 		place = set_pop(all_places)
 		name = read_attribute(model, place, "name")
@@ -23,28 +20,28 @@ Element function pn_print(params : Element, output_mms : Element):
 		log((("  " + name) + ": ") + cast_v2s(tokens))
 
 	log("Transitions:")
-	all_places = allInstances(model, "Transition")
+	all_places = allInstances(model, "Encapsulated_PetriNet/Transition")
 	while (read_nr_out(all_places) > 0):
 		place = set_pop(all_places)
 		name = read_attribute(model, place, "name")
 
 		log("  " + name)
 
-		all_t = allIncomingAssociationInstances(model, place, "P2T")
+		all_t = allIncomingAssociationInstances(model, place, "Encapsulated_PetriNet/P2T")
 		while (read_nr_out(all_t) > 0):
 			t = set_pop(all_t)
 			log("    <-- " + cast_v2s(read_attribute(model, readAssociationSource(model, t), "name")))
-		all_t = allOutgoingAssociationInstances(model, place, "T2P")
+		all_t = allOutgoingAssociationInstances(model, place, "Encapsulated_PetriNet/T2P")
 		while (read_nr_out(all_t) > 0):
 			t = set_pop(all_t)
 			log("    --> " + cast_v2s(read_attribute(model, readAssociationDestination(model, t), "name")))
 
 	log("Ports:")
-	all_places = allInstances(model, "Port")
+	all_places = allInstances(model, "Encapsulated_PetriNet/Port")
 	while (read_nr_out(all_places) > 0):
 		place = set_pop(all_places)
 		name = read_attribute(model, place, "name")
 
 		log("  " + name)
 
-	return create_node()!
+	return True!

+ 3 - 3
models/matches.mvc

@@ -30,12 +30,12 @@ A B {
                 Pre_Query/Place {
                     label = "2"
                 }
-                Pre_ReachabilityGraph/State pre_4 {
-                    label = "4"
-                }
                 Pre_ReachabilityGraph/Place pre_3 {
                     label = "3"
                 }
+                Pre_ReachabilityGraph/State pre_4 {
+                    label = "4"
+                }
                 Pre_ReachabilityGraph/Contains (pre_4, pre_3) {
                     label = "5"
                 }

+ 0 - 22
models/pm_req_analyse.mvc

@@ -139,7 +139,6 @@ ProcessModel analyse_requirements {
     Else (found, finish) {}
 
     Consumes (revise_req, req) {
-        name = "requirements"
     }
     Produces (revise_req, req) {
     }
@@ -158,35 +157,25 @@ ProcessModel analyse_requirements {
     }
 
     Consumes (revise_plant, req) {
-        name = "requirements"
     }
     Consumes (revise_environment, req) {
-        name = "requirements"
     }
     Consumes (revise_control, req) {
-        name = "requirements"
     }
     Consumes (revise_query, req) {
-        name = "requirements"
     }
     Consumes (revise_architecture, req) {
-        name = "requirements"
     }
 
     Consumes (revise_plant, plant_model) {
-        name = "plant"
     }
     Consumes (revise_environment, environment_model) {
-        name = "environment"
     }
     Consumes (revise_control, control_model) {
-        name = "control"
     }
     Consumes (revise_query, query) {
-        name = "query"
     }
     Consumes (revise_architecture, architecture) {
-        name = "architecture"
     }
     Produces (revise_plant, plant_model) {
     }
@@ -200,52 +189,41 @@ ProcessModel analyse_requirements {
     }
 
     Consumes (plant_to_EPN, plant_model) {
-        name = "plant_model"
     }
     Produces (plant_to_EPN, plant_EPN) {
     }
     Consumes (environment_to_EPN, environment_model) {
-        name = "environment_model"
     }
     Produces (environment_to_EPN, environment_EPN) {
     }
     Consumes (control_to_EPN, control_model) {
-        name = "control_model"
     }
     Produces (control_to_EPN, control_EPN) {
     }
 
     Consumes (combine_EPN, plant_EPN) {
-        name = "epn_1"
     }
     Consumes (combine_EPN, environment_EPN) {
-        name = "epn_2"
     }
     Consumes (combine_EPN, control_EPN) {
-        name = "epn_3"
     }
     Consumes (combine_EPN, architecture) {
-        name = "architecture"
     }
     Produces (combine_EPN, pn) {
     }
 
     Consumes (analyse, pn) {
-        name = "pn"
     }
     Produces (analyse, reachability_graph) {
     }
 
     Consumes (match, reachability_graph) {
-        name = "reachability_graph"
     }
     Consumes (match, query) {
-        name = "query"
     }
     Produces (match, reachability_graph) {
     }
 
     Consumes (bfs, reachability_graph) {
-        name = "reachability_graph"
     }
 }

+ 0 - 26
models/pm_req_analyse_debug.mvc

@@ -156,7 +156,6 @@ ProcessModel analyse_requirements {
     Else (found, finish) {}
 
     Consumes (revise_req, req) {
-        name = "requirements"
     }
     Produces (revise_req, req) {
     }
@@ -175,35 +174,25 @@ ProcessModel analyse_requirements {
     }
 
     Consumes (revise_plant, req) {
-        name = "requirements"
     }
     Consumes (revise_environment, req) {
-        name = "requirements"
     }
     Consumes (revise_control, req) {
-        name = "requirements"
     }
     Consumes (revise_query, req) {
-        name = "requirements"
     }
     Consumes (revise_architecture, req) {
-        name = "requirements"
     }
 
     Consumes (revise_plant, plant_model) {
-        name = "plant"
     }
     Consumes (revise_environment, environment_model) {
-        name = "environment"
     }
     Consumes (revise_control, control_model) {
-        name = "control"
     }
     Consumes (revise_query, query) {
-        name = "query"
     }
     Consumes (revise_architecture, architecture) {
-        name = "architecture"
     }
     Produces (revise_plant, plant_model) {
     }
@@ -217,66 +206,51 @@ ProcessModel analyse_requirements {
     }
 
     Consumes (plant_to_EPN, plant_model) {
-        name = "plant_model"
     }
     Produces (plant_to_EPN, plant_EPN) {
     }
     Consumes (environment_to_EPN, environment_model) {
-        name = "environment_model"
     }
     Produces (environment_to_EPN, environment_EPN) {
     }
     Consumes (control_to_EPN, control_model) {
-        name = "control_model"
     }
     Produces (control_to_EPN, control_EPN) {
     }
 
     Consumes (combine_EPN, plant_EPN) {
-        name = "epn_1"
     }
     Consumes (combine_EPN, environment_EPN) {
-        name = "epn_2"
     }
     Consumes (combine_EPN, control_EPN) {
-        name = "epn_3"
     }
     Consumes (combine_EPN, architecture) {
-        name = "architecture"
     }
     Produces (combine_EPN, pn) {
     }
 
     Consumes (analyse, pn) {
-        name = "pn"
     }
     Produces (analyse, reachability_graph) {
     }
 
     Consumes (match, reachability_graph) {
-        name = "reachability_graph"
     }
     Consumes (match, query) {
-        name = "query"
     }
     Produces (match, reachability_graph) {
     }
 
     Consumes (bfs, reachability_graph) {
-        name = "reachability_graph"
     }
 
     Consumes (print_pn, pn) {
-        name = "pn"
     }
 
     Consumes (print_plant_EPN, plant_EPN){
-        name = "epn"
     }
     Consumes (print_control_EPN, control_EPN){
-        name = "epn"
     }
     Consumes (print_env_EPN, environment_EPN){
-        name = "epn"
     }
 }

+ 6 - 9
models/pn_print.alc

@@ -2,10 +2,7 @@ include "primitives.alh"
 include "modelling.alh"
 include "object_operations.alh"
 
-Element function pn_print(params : Element, output_mms : Element):
-	Element model
-	model = params["pn"]
-
+Boolean function pn_print(model : Element):
 	Element all_places
 	String place
 	String name
@@ -14,7 +11,7 @@ Element function pn_print(params : Element, output_mms : Element):
 	Element all_t
 
 	log("Places:")
-	all_places = allInstances(model, "Place")
+	all_places = allInstances(model, "PetriNet/Place")
 	while (read_nr_out(all_places) > 0):
 		place = set_pop(all_places)
 		name = read_attribute(model, place, "name")
@@ -23,21 +20,21 @@ Element function pn_print(params : Element, output_mms : Element):
 		log((("  " + name) + ": ") + cast_v2s(tokens))
 
 	log("Transitions:")
-	all_places = allInstances(model, "Transition")
+	all_places = allInstances(model, "PetriNet/Transition")
 	while (read_nr_out(all_places) > 0):
 		place = set_pop(all_places)
 		name = read_attribute(model, place, "name")
 
 		log("  " + name)
 
-		all_t = allIncomingAssociationInstances(model, place, "P2T")
+		all_t = allIncomingAssociationInstances(model, place, "PetriNet/P2T")
 		while (read_nr_out(all_t) > 0):
 			t = set_pop(all_t)
 			log("    <-- " + cast_v2s(read_attribute(model, readAssociationSource(model, t), "name")))
 
-		all_t = allOutgoingAssociationInstances(model, place, "T2P")
+		all_t = allOutgoingAssociationInstances(model, place, "PetriNet/T2P")
 		while (read_nr_out(all_t) > 0):
 			t = set_pop(all_t)
 			log("    --> " + cast_v2s(read_attribute(model, readAssociationDestination(model, t), "name")))
 
-	return create_node()!
+	return True!

+ 29 - 38
models/reachability.alc

@@ -2,12 +2,8 @@ include "primitives.alh"
 include "modelling.alh"
 include "object_operations.alh"
 
-Element function reachability_graph(params : Element, output_mms : Element):
-	Element result
-	Element model
+Boolean function reachability_graph(model : Element):
 	Element workset
-	Element out_model
-	Element in_model
 	Element transition_vectors_produce
 	Element transition_vectors_consume
 	Element all_transitions
@@ -37,44 +33,40 @@ Element function reachability_graph(params : Element, output_mms : Element):
 	Element cache
 	cache = create_node()
 
-	result = create_node()
-	out_model = instantiate_model(output_mms["ReachabilityGraph"])
-	in_model = params["pn"]
-
 	// Create a dictionary representation for each transition
 	transition_vectors_produce = create_node()
 	transition_vectors_consume = create_node()
-	all_transitions = allInstances(in_model, "Transition")
+	all_transitions = allInstances(model, "PetriNet/Transition")
 	while (read_nr_out(all_transitions) > 0):
 		transition = set_pop(all_transitions)
 
 		tv = create_node()
-		links = allIncomingAssociationInstances(in_model, transition, "P2T")
+		links = allIncomingAssociationInstances(model, transition, "PetriNet/P2T")
 		while (read_nr_out(links) > 0):
 			link = set_pop(links)
-			name = reverseKeyLookup(in_model["model"], read_edge_src(in_model["model"][link]))
-			link_weight = read_attribute(in_model, link, "weight")
+			name = reverseKeyLookup(model["model"], read_edge_src(model["model"][link]))
+			link_weight = read_attribute(model, link, "weight")
 			dict_add_fast(tv, name, link_weight)
 		dict_add_fast(transition_vectors_consume, transition, tv)
 
 		tv = create_node()
-		links = allOutgoingAssociationInstances(in_model, transition, "T2P")
+		links = allOutgoingAssociationInstances(model, transition, "PetriNet/T2P")
 		while (read_nr_out(links) > 0):
 			link = set_pop(links)
-			name = reverseKeyLookup(in_model["model"], read_edge_dst(in_model["model"][link]))
-			link_weight = read_attribute(in_model, link, "weight")
+			name = reverseKeyLookup(model["model"], read_edge_dst(model["model"][link]))
+			link_weight = read_attribute(model, link, "weight")
 			dict_add_fast(tv, name, link_weight)
 		dict_add_fast(transition_vectors_produce, transition, tv)
 
 	workset = create_node()
 
-	all_places = allInstances(in_model, "Place")
+	all_places = allInstances(model, "PetriNet/Place")
 	dict_repr = create_node()
 	while (read_nr_out(all_places) > 0):
 		place = set_pop(all_places)
-		dict_add_fast(dict_repr, place, read_attribute(in_model, place, "tokens"))
+		dict_add_fast(dict_repr, place, read_attribute(model, place, "tokens"))
 
-	all_transitions_original = allInstances(in_model, "Transition")
+	all_transitions_original = allInstances(model, "PetriNet/Transition")
 
 	mappings = create_node()
 	state_id = 0
@@ -85,16 +77,16 @@ Element function reachability_graph(params : Element, output_mms : Element):
 	set_add(workset, state_id)
 
 	// And add in the model itself
-	state = instantiate_node(out_model, "InitialState", cast_i2s(state_id))
-	instantiate_attribute(out_model, state, "name", cast_i2s(state_id))
-	instantiate_attribute(out_model, state, "error", False)
+	state = instantiate_node(model, "ReachabilityGraph/InitialState", cast_i2s(state_id))
+	instantiate_attribute(model, state, "name", cast_i2s(state_id))
+	instantiate_attribute(model, state, "error", False)
 	keys = dict_keys(dict_repr)
 	while (read_nr_out(keys) > 0):
 		key = set_pop(keys)
-		place = instantiate_node(out_model, "Place", "")
-		instantiate_attribute(out_model, place, "name", read_attribute(in_model, key, "name"))
-		instantiate_attribute(out_model, place, "tokens", dict_repr[key])
-		instantiate_link(out_model, "Contains", "", state, place)
+		place = instantiate_node(model, "ReachabilityGraph/Place", "")
+		instantiate_attribute(model, place, "name", read_attribute(model, key, "name"))
+		instantiate_attribute(model, place, "tokens", dict_repr[key])
+		instantiate_link(model, "ReachabilityGraph/Contains", "", state, place)
 
 	while (read_nr_out(workset) > 0):
 		state_id = set_pop(workset)
@@ -156,35 +148,34 @@ Element function reachability_graph(params : Element, output_mms : Element):
 					set_add(workset, target_id)
 
 					// And add in the model itself
-					state = instantiate_node(out_model, "State", cast_i2s(target_id))
-					instantiate_attribute(out_model, state, "name", cast_i2s(target_id))
-					instantiate_attribute(out_model, state, "error", False)
+					state = instantiate_node(model, "ReachabilityGraph/State", cast_i2s(target_id))
+					instantiate_attribute(model, state, "name", cast_i2s(target_id))
+					instantiate_attribute(model, state, "error", False)
 
 					keys = dict_keys(new_dict_repr)
 					Element sub
 					String name
 					while (read_nr_out(keys) > 0):
 						key = set_pop(keys)
-						name = read_attribute(in_model, key, "name")
+						name = read_attribute(model, key, "name")
 						if (bool_not(dict_in(cache, name))):
 							dict_add_fast(cache, name, create_node())
 						sub = cache[name]
 						if (bool_not(dict_in(sub, new_dict_repr[key]))):
-							place = instantiate_node(out_model, "Place", "")
-							instantiate_attribute(out_model, place, "name", name)
-							instantiate_attribute(out_model, place, "tokens", new_dict_repr[key])
+							place = instantiate_node(model, "ReachabilityGraph/Place", "")
+							instantiate_attribute(model, place, "name", name)
+							instantiate_attribute(model, place, "tokens", new_dict_repr[key])
 							dict_add_fast(sub, new_dict_repr[key], place)
 						else:
 							place = sub[new_dict_repr[key]]
-						instantiate_link(out_model, "Contains", "", state, place)
+						instantiate_link(model, "ReachabilityGraph/Contains", "", state, place)
 
 				// Anyway, we have found a transition, which we should store
 				dict_add_fast(mappings[state_id], transition, target_id)
 
 				// And also store it in the model itself
-				new_transition = instantiate_link(out_model, "Transition", "", cast_i2s(state_id), cast_i2s(target_id))
-				instantiate_attribute(out_model, new_transition, "name", read_attribute(in_model, transition, "name"))
+				new_transition = instantiate_link(model, "ReachabilityGraph/Transition", "", cast_i2s(state_id), cast_i2s(target_id))
+				instantiate_attribute(model, new_transition, "name", read_attribute(model, transition, "name"))
 
 	log("# reachable states: " + cast_v2s(next_id))
-	dict_add_fast(result, "ReachabilityGraph", out_model)
-	return result!
+	return True!

+ 1 - 0
scripts/run_local_modelverse.py

@@ -11,4 +11,5 @@ else:
     # Also, specifying a kernel here breaks the performance tests.
 
     subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:], cwd="hybrid_server")
+    #subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:] + ["--kernel=baseline-jit"], cwd="hybrid_server")
     #subprocess.call([sys.executable, "-m", "cProfile", "-s", "tottime", "run_mvk_server.py"] + sys.argv[1:], cwd="hybrid_server", stdout=open("/tmp/stdout", 'w'), stderr=open("/tmp/stderr", "w"))