Browse Source

Fixed bug in allInstances

Yentl Van Tendeloo 9 years ago
parent
commit
c9c0a37520
3 changed files with 23 additions and 2 deletions
  1. 7 0
      bootstrap/conformance_scd.alc
  2. 12 1
      bootstrap/metamodels.alc
  3. 4 1
      bootstrap/object_operations.alc

+ 7 - 0
bootstrap/conformance_scd.alc

@@ -132,6 +132,7 @@ String function conformance_scd(model : Element):
 		keys = dict_keys(model["model"])
 		while (0 < list_len(keys)):
 			model_name = set_pop(keys)
+			log("Check element " + model_name)
 			element = model["model"][model_name]
 
 			if (bool_not(dict_in_node(typing, element))):
@@ -165,8 +166,11 @@ String function conformance_scd(model : Element):
 			Integer upper_val
 			Integer instances
 
+			log("Check cardinalities")
 			check_list = selectPossibleOutgoing(model, model_name, dict_keys(cardinalities))
+			log("Got outgoing")
 			while (0 < list_len(check_list)):
+				log("Loop")
 				check_type = set_pop(check_list)
 				if (dict_in(cardinalities, check_type)):
 					// Cardinalities defined for this association, so check them
@@ -184,7 +188,9 @@ String function conformance_scd(model : Element):
 
 			// Identical, but for outgoing, and thus for A in the figure
 			check_list = selectPossibleIncoming(model, model_name, dict_keys(cardinalities))
+			log("Got incoming")
 			while (0 < list_len(check_list)):
+				log("Loop")
 				check_type = set_pop(check_list)
 				if (dict_in(cardinalities, check_type)):
 					// Cardinalities defined for this association, so check them
@@ -200,6 +206,7 @@ String function conformance_scd(model : Element):
 						if (integer_lt(cardinalities[check_type]["suc"], instances)):
 							return "Upper cardinality violation for incoming edge at " + model_name
 
+	log("Finished, check multiplicities")
 	// Check multiplicities, if they are defined (optional)
 	Element metamodel_keys
 	String metamodel_element

+ 12 - 1
bootstrap/metamodels.alc

@@ -109,23 +109,34 @@ String function petrinet_constraints(model : Element):
 	Element all_elems
 	String elem_constraint
 	
+	log("Check constraints")
 	all_elems = allInstances(model, "Place")
-	while (0 < read_nr_out(all_elems)):
+	log("Got all instances")
+	log("Length " + cast_i2s(list_len(all_elems)))
+	log("First element: " + cast_e2s(all_elems[0]))
+	while (0 < list_len(all_elems)):
 		elem_constraint = set_pop(all_elems)
+		log("Check Place " + elem_constraint)
 		if (integer_lt(read_attribute(model, elem_constraint, "tokens"), 0)):
 			return "Negative number of tokens in Place " + elem_constraint
 
 	// Check P2T transitions to have positive weight
+	log("Check constraints 2")
 	all_elems = allInstances(model, "P2T")
+	log("Got all instances")
 	while (0 < read_nr_out(all_elems)):
 		elem_constraint = set_pop(all_elems)
+		log("Check P2T " + elem_constraint)
 		if (integer_lt(read_attribute(model, elem_constraint, "weight"), 0)):
 			return "Negative weight in arc " + elem_constraint
 
 	// Check T2P transitions to have positive weight
+	log("Check constraints 3")
 	all_elems = allInstances(model, "T2P")
+	log("Got all instances")
 	while (0 < read_nr_out(all_elems)):
 		elem_constraint = set_pop(all_elems)
+		log("Check T2P " + elem_constraint)
 		if (integer_lt(read_attribute(model, elem_constraint, "weight"), 0)):
 			return "Negative weight in arc " + elem_constraint
 

+ 4 - 1
bootstrap/object_operations.alc

@@ -11,9 +11,12 @@ Element function allInstances(model : Element, type_name : String):
 	Element keys
 
 	keys = dict_keys(model["model"])
+	type = model["metamodel"]["model"][type_name]
+	result = create_node()
+
 	while (0 < list_len(keys)):
 		key = set_pop(keys)
-		if (is_nominal_instance(model, key, type_name)):
+		if (is_nominal_instance(model, model["model"][key], type)):
 			set_add(result, key)
 
 	return result