Jelajahi Sumber

Several fixes to conformance finding for a type mapping

Yentl Van Tendeloo 7 tahun lalu
induk
melakukan
eb18d88d9b

+ 8 - 8
bootstrap/conformance_finding.alc

@@ -89,19 +89,19 @@ Boolean function find_type_mapping(model : Element):
 		while (set_len(elems) > 0):
 		while (set_len(elems) > 0):
 			elem = set_pop(elems)
 			elem = set_pop(elems)
 
 
-			if (is_edge(model["model"][elem])):
+			if (bool_and(is_edge(model["model"][elem]), read_nr_out(model["model"][elem]) == 0)):
 				// An edge, and there is always exactly one, so type
 				// An edge, and there is always exactly one, so type
 				retype(model, elem, edge_element)
 				retype(model, elem, edge_element)
+				log("Type " + elem + " as " + edge_element)
+
+				// The source and target are ALWAYS typed as well!
+				retype(model, readAssociationSource(model, elem), node_source_element)
+				log("Type " + readAssociationSource(model, elem) + " as " + node_source_element)
+				retype(model, readAssociationDestination(model, elem), node_target_element)
+				log("Type " + readAssociationDestination(model, elem) + " as " + node_target_element)
 			elif (node_source_element == node_target_element):
 			elif (node_source_element == node_target_element):
 				// A node, and we are sure that there is only one
 				// A node, and we are sure that there is only one
 				retype(model, elem, node_source_element)
 				retype(model, elem, node_source_element)
-			else:
-				// We have an element and know that there is an edge connecting them
-				// If there is an outgoing link, we make it "node_target_element", otherwise "node_source_element"
-				if (read_nr_out(model["model"][elem]) > 0):
-					retype(model, elem, node_source_element)
-				else:
-					retype(model, elem, node_target_element)
 
 
 	// 3) (optional) verify that the mapping is correct with conformance checking
 	// 3) (optional) verify that the mapping is correct with conformance checking
 	// TODO
 	// TODO

+ 19 - 23
models/Conformance/AToMPM.alc

@@ -10,10 +10,6 @@ Boolean function main(model : Element):
 	// Thus only the check for multiple inheritance is being done, which checks for attributes.
 	// Thus only the check for multiple inheritance is being done, which checks for attributes.
 	// A full example is given in the Modelverse's internal conformance relation.
 	// A full example is given in the Modelverse's internal conformance relation.
 
 
-	// TODO should the incoming "model" be typed by conformance bottom all the time, as otherwise the mapping is already done beforehand?
-	// TODO similarly for the metamodel: we can't be sure what comes out here
-	// TODO only thing we are sure about is the type mapping
-
 	log("Performing conformance check!")
 	log("Performing conformance check!")
 
 
 	// Find all instances of classes
 	// Find all instances of classes
@@ -22,33 +18,33 @@ Boolean function main(model : Element):
 	classes = allInstances(model, "metamodel/Class")
 	classes = allInstances(model, "metamodel/Class")
 	log("Got classes: " + set_to_string(classes))
 	log("Got classes: " + set_to_string(classes))
 
 
-	// TODO maybe make the type mapping links resemble a traceability link more, such that it is automatically merged in?
-	// TODO now the type_mapping is completely different and no relation can be inferred...
-	// TODO other option: make the type mapping refer to names/IDs instead of identifiers, although this is problematic in case we connect to ourselves (self-conformance!)
 	Element links
 	Element links
 	String link
 	String link
 	Element type_mapping
 	Element type_mapping
 	type_mapping = dict_create()
 	type_mapping = dict_create()
 
 
-	links = allInstances(model, "type_mapping/TypeLink")
-	while (set_len(links) > 0):
-		link = set_pop(links)
-		log("Association connects: " + readAssociationSource(model, link) + " --> " + readAssociationDestination(model, link))
-		dict_add(type_mapping, "model/" + string_replace(readAssociationSource(model, link), "type_mapping/instance_", ""), "metamodel/" + string_replace(readAssociationDestination(model, link), "type_mapping/type_", ""))
-	
-	log("Found type mapping: " + dict_to_string(type_mapping))
-
-	String class
 	Element instances
 	Element instances
 	String instance
 	String instance
-	while (set_len(classes) > 0):
-		class = set_pop(classes)
-		instances = allAssociationOrigins(model, class, "type_mapping/TypeLink")
-		log("Got instances: " + set_to_string(instances))
-
-		while (set_len(instances) > 0):
-			instance = set_pop(instances)
+	instances = allInstances(model, "type_mapping/Instance")
+	while (set_len(instances) > 0):
+		instance = set_pop(instances)
+		log("Found instance: " + instance)
+		log("   Connects to: " + cast_string(set_pop(allAssociationDestinations(model, instance, "type_mapping/TypeLink"))))
+		log("Association connects: " + instance + " --> " + cast_string(set_pop(allAssociationDestinations(model, instance, "type_mapping/TypeLink"))))
+		//dict_add(type_mapping, "model/" + string_replace(readAssociationSource(model, link), "type_mapping/instance_", ""), "metamodel/" + string_replace(readAssociationDestination(model, link), "type_mapping/type_", ""))
+	
+	log("Found type mapping: " + dict_to_string(type_mapping))
 
 
 	// Check if each attribute is there, and satisfies the constraints
 	// Check if each attribute is there, and satisfies the constraints
+	instances = dict_keys(type_mapping)
+	while (set_len(instances) > 0):
+		instance = set_pop(instances)
+		log("Found type: " + read_type(model, type_mapping[instance]))
+		if (read_type(model, type_mapping[instance]) == "metamodel/Class"):
+			// Got an instance of a Class
+			log("Got a class instance: " + instance)
+
+			// Fetch a list of attributes that should be defined
+			// TODO
 
 
 	return True!
 	return True!

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
 
-Date:   Fri May 25 12:42:46 2018
+Date:   Fri May 25 13:34:41 2018
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server