Browse Source

Merge branch 'live_modelling' into formalisms

Yentl Van Tendeloo 3 years ago
parent
commit
a15ec692a4

+ 4 - 0
bootstrap/model_management.alc

@@ -215,6 +215,8 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
 			src_name = read_attribute(tracability_model, readAssociationSource(tracability_model, tracability_link), "name")
 			dst_name = read_attribute(tracability_model, readAssociationDestination(tracability_model, tracability_link), "name")
 
+			log("Found TLINK from " + src_name + " to " + dst_name)
+
 			type = read_attribute(tracability_model, tracability_link, "type")
 
 			// Now try to find all possible combinations
@@ -233,9 +235,11 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
 						if (dict_in(new_model["model"], dst_model + dst_name)):
 							// Found a match for source and target, so create a link
 							new_name = instantiate_link(new_model, type, "", src_model + src_name, dst_model + dst_name)
+							log("Created!")
 
 							if (new_name == ""):
 								log("ERROR: could not create a tracability link; ignoring")
+		log("Finished all trace links")
 	return new_model!
 	
 Element function model_split(merged_model : Element, models : Element, tracability : Boolean):

+ 1 - 0
bootstrap/ramify.alc

@@ -85,6 +85,7 @@ Element function ramify(model : Element):
 	instantiate_node(new_model, "Class", "PostElement")
 	model_define_attribute(new_model, "PostElement", "label", False, "String")
 	model_define_attribute(new_model, "PostElement", "action", True, "ActionLanguage")
+	model_define_attribute(new_model, "PostElement", "__id__", True, "ActionLanguage")
 
 	// Association RHS_contains (RHS, PostElement) {}
 	instantiate_link(new_model, "Association", "RHS_contains", "RHS", "PostElement")

+ 20 - 6
bootstrap/transform.alc

@@ -299,7 +299,7 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
 	set_add_node(mappings, initial_mapping)
 	while (list_len(schedule) > 0):
 		current_element = list_pop(schedule, list_len(schedule) - 1)
-		//log("Binding element with label " + cast_value(read_attribute(schedule_model, current_element, "label")))
+		log("Binding element with label " + cast_value(read_attribute(schedule_model, current_element, "label")))
 		new_mappings = dict_create()
 
 		while (set_len(mappings) > 0):
@@ -313,7 +313,7 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
 				set_add_node(new_mappings, new_map)
 
 		mappings = new_mappings
-		//log("Remaining options: " + cast_value(set_len(mappings)))
+		log("Remaining options: " + cast_value(set_len(mappings)))
 
 		if (set_len(mappings) == 0):
 			// Stop because we have no more options remaining!
@@ -359,6 +359,8 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 	String value
 	String action
 	Element original_RHS_labels
+	String new_identifier
+	Element func
 
 	Element reverse
 	reverse = make_reverse_dictionary(schedule_model["model"])
@@ -389,6 +391,14 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 	while (list_len(labels_to_add) > 0):
 		// Add the elements linked to these labels
 		label = list_pop(labels_to_add, list_len(labels_to_add) - 1)
+
+		// Check if we have any requirement for the ID
+		if (element_eq(read_attribute(schedule_model, RHS_map[label], "__id__"), read_root())):
+			new_identifier = ""
+		else:
+			func = get_func_AL_model(import_node(read_attribute(schedule_model, RHS_map[label], "__id__")))
+			new_identifier = func(host_model, mapping)
+
 		if (is_edge(schedule_model["model"][RHS_map[label]])):
 			// Edge
 			src = read_attribute(schedule_model, reverse[cast_id(read_edge_src(schedule_model["model"][RHS_map[label]]))], "label")
@@ -399,7 +409,7 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 				// Both are present, so we can make the link
 				typename = read_type(schedule_model, RHS_map[label])
 				original_typename = string_substr(typename, 5, string_len(typename))
-				new_name = instantiate_link(host_model, original_typename, "", new_mapping[src], new_mapping[dst])
+				new_name = instantiate_link(host_model, original_typename, new_identifier, new_mapping[src], new_mapping[dst])
 				dict_add_fast(new_mapping, label, new_name)
 			else:
 				// Delay this a bit, until all are bound
@@ -409,13 +419,12 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 			// Create the node and add it
 			typename = read_type(schedule_model, RHS_map[label])
 			original_typename = string_substr(typename, 5, string_len(typename))
-			new_name = instantiate_node(host_model, original_typename, "")
+			new_name = instantiate_node(host_model, original_typename, new_identifier)
 			dict_add_fast(new_mapping, label, new_name)
 
 	Element attributes
 	String attribute
 	Element result
-	Element func
 
 	while (set_len(original_RHS_labels) > 0):
 		// Perform actions
@@ -535,6 +544,9 @@ Boolean function transform_atomic(host_model : Element, schedule_model : Element
 	// Execute the atomic transformation
 	Element mappings
 	Element mapping
+
+	log("Executing rule: " + current)
+
 	mappings = full_match(host_model, schedule_model, current, True)
 
 	log("Executing rule: " + current)
@@ -545,8 +557,10 @@ Boolean function transform_atomic(host_model : Element, schedule_model : Element
 		String RHS
 		RHS = set_pop(allAssociationDestinations(schedule_model, current, "RHSLink"))
 		rewrite(host_model, schedule_model, RHS, mapping)
+		log("Rewrite OK")
 		return True!
 	else:
+		log("Rewrite failed")
 		return False!
 
 Boolean function transform_forall(host_model : Element, schedule_model : Element, current : String):
@@ -565,7 +579,7 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
 	else:
 		result = False
 
-	//log("Matches in forall: " + cast_string(set_len(mappings)))
+	log("Matches in forall: " + cast_string(set_len(mappings)))
 	while (set_len(mappings) > 0):
 		mapping = set_pop(mappings)
 		RHS = set_pop(allAssociationDestinations(schedule_model, current, "RHSLink"))

+ 9 - 4
bootstrap/typing.alc

@@ -54,15 +54,20 @@ Void function set_type_mapping(model : Element, type_mapping_model : Element):
 
 Element function elements_typed_by(model : Element, type_name : String):
 	Element result
-	result = reverseKeyLookupMulti(get_type_mapping_as_dict(model), type_name)
+	Element temp_result
+	String temp
+
+	result = set_create()
+	temp_result = reverseKeyLookupMulti(get_type_mapping_as_dict(model), type_name)
+	while (set_len(temp_result) > 0):
+		temp = set_pop(temp_result)
+		if (dict_in(model["model"], temp)):
+			set_add(result, temp)
 	return result!
 
 Element function get_type_mapping_as_dict(model : Element):
 	return model["type_mapping"]!
 
-Element function get_elements_typed_by(model : Element, type : String):
-	return reverseKeyLookupMulti(model["type_mapping"], type)!
-
 String function read_type(model : Element, name : String):
 	String result
 	Element tm

+ 2 - 0
bootstrap/utils.alc

@@ -19,7 +19,9 @@ String function JSON_print(model : Element):
 
 	while (set_len(keys_m) > 0):
 		v_m = set_pop(keys_m)
+		log("Check " + v_m)
 		type = read_type(model["metamodel"], read_type(model, v_m))
+		log("Type: " + type)
 
 		if (bool_or(type == "Class", type == "Association")):
 			if (bool_not(first)):

+ 16 - 1
interface/simple_plot/main.py

@@ -26,6 +26,7 @@ maps = {}
 if time <= old_time:
     # Overwrites current values, so flush
     d = {}
+    plt.legend()
 else:
     for key in d:
         maps[key], = plt.plot(d[key][0], d[key][1])
@@ -48,7 +49,12 @@ while 1:
         continue
     time, key, value = l.split(" ")
     time = float(time)
-    value = float(value)
+    try:
+        value = float(value)
+    except:
+        # Value is not a number, so we work with discrete states, just ignore!
+        pass
+        value = value.strip()
 
     if key not in maps:
         maps[key], = plt.plot([], [])
@@ -60,6 +66,15 @@ while 1:
 
     d[key][0].append(time)
     d[key][1].append(value)
+
+    if isinstance(value, str) and value not in d[key][1][:-1]:
+        for key in d:
+            prev_color = maps[key].get_color()
+            maps[key].remove()
+            maps[key], = plt.plot(d[key][0], d[key][1], c=prev_color)
+            maps[key].set_label(key)
+        plt.legend()
+
     maps[key].set_xdata(d[key][0])
     maps[key].set_ydata(d[key][1])
     plt.gca().set_xlim([min(d[key][0]), max(d[key][0])])

+ 0 - 143
models/CBD/PM_live_modelling.mvc

@@ -1,143 +0,0 @@
-Start start {}
-
-Exec toRuntime_0 {
-    name = "models/CBD/toRuntime"
-}
-
-Exec merge_0 {
-    name = "models/CBD/merge"
-}
-
-Exec edit {
-    name = "models/CBD/edit"
-}
-
-Exec toRuntime {
-    name = "models/CBD/toRuntime"
-}
-
-Exec restartSim {
-    name = "models/CBD/restartSim"
-}
-
-Exec simulate {
-    name = "models/CBD/simulate"
-}
-
-Exec merge {
-    name = "models/CBD/merge"
-}
-
-Fork fork1 {}
-Fork fork2 {}
-
-Data traceability_D2P {
-    name = "traceability_D2P"
-    type = "formalisms/Tracability"
-}
-Data traceability_P2F {
-    name = "traceability_P2F"
-    type = "formalisms/Tracability"
-}
-
-Data design_model {
-    name = "design_model"
-    type = "formalisms/CBD/Design_MM"
-}
-
-Data partial_runtime_model {
-    name = "partial_runtime_model"
-    type = "formalisms/CBD/PartialRuntime_MM"
-}
-
-Data full_runtime_model {
-    name = "full_runtime_model"
-    type = "formalisms/CBD/FullRuntime_MM"
-}
-
-Next (start, toRuntime_0) {}
-Next (toRuntime_0, merge_0) {}
-Next (merge_0, fork1) {}
-Next (fork1, edit) {}
-Next (fork1, simulate) {}
-Next (edit, toRuntime) {}
-Next (toRuntime, fork2) {}
-Next (fork2, edit) {}
-Next (fork2, restartSim) {}
-Next (simulate, merge) {}
-Next (merge, simulate) {}
-
-Consumes (edit, design_model) {
-    name = "Design"
-}
-Produces (edit, design_model) {
-    name = "Design"
-}
-
-Consumes (toRuntime, design_model) {
-    name = "Design"
-}
-Consumes (toRuntime, partial_runtime_model) {
-    name = "PartialRuntime"
-}
-Consumes (toRuntime, traceability_D2P) {
-    name = "__traceability"
-}
-Produces (toRuntime, traceability_D2P) {
-    name = "__traceability"
-}
-Produces (toRuntime, partial_runtime_model) {
-    name = "PartialRuntime"
-}
-
-Consumes (toRuntime_0, design_model) {
-    name = "Design"
-}
-Consumes (toRuntime_0, traceability_D2P) {
-    name = "__traceability"
-}
-Produces (toRuntime_0, traceability_D2P) {
-    name = "__traceability"
-}
-Produces (toRuntime_0, partial_runtime_model) {
-    name = "PartialRuntime"
-}
-
-Consumes (merge, partial_runtime_model) {
-    name = "PartialRuntime"
-}
-Consumes (merge, full_runtime_model) {
-    name = "FullRuntime"
-}
-Consumes (merge, traceability_P2F) {
-    name = "__traceability"
-}
-Produces (merge, traceability_P2F) {
-    name = "__traceability"
-}
-Produces (merge, full_runtime_model) {
-    name = "NewFullRuntime"
-}
-
-Consumes (merge_0, partial_runtime_model) {
-    name = "PartialRuntime"
-}
-Consumes (merge_0, full_runtime_model) {
-    name = "FullRuntime"
-}
-Consumes (merge_0, traceability_P2F) {
-    name = "__traceability"
-}
-Produces (merge_0, traceability_P2F) {
-    name = "__traceability"
-}
-Produces (merge_0, full_runtime_model) {
-    name = "NewFullRuntime"
-}
-
-Consumes (simulate, full_runtime_model) {
-    name = "FullRuntime"
-}
-Produces (simulate, full_runtime_model) {
-    name = "FullRuntime"
-}

+ 0 - 50
models/CBD/metamodels/CBD_MM.mvc

@@ -1,50 +0,0 @@
-include "primitives.alh"
-
-SimpleAttribute Float {}
-SimpleAttribute String {}
-
-Class Block{}
-Class ICBlock : Block {}
-
-Class ConstantBlock : Block {
-    name = "Constant"
-    value : Float {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-}
-
-Class AdditionBlock : Block {
-    name = "Addition"
-}
-Class NegatorBlock : Block{
-    name = "Negator"
-}
-Class MultiplyBlock : Block {
-    name = "Multiply"
-}
-Class InverseBlock : Block {
-    name = "Inverse"
-}
-Class DelayBlock : ICBlock {
-    name = "Delay"
-}
-Class IntegratorBlock : ICBlock {
-    name = "Integrator"
-}
-Class DerivatorBlock : ICBlock {
-    name = "Derivator"
-}
-Class ProbeBlock : Block {
-    name = "Probe"
-    name : String {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-}
-
-Association Link(Block, Block){}
-Association InitialCondition(Block, ICBlock){
-    source_lower_cardinality = 1
-    source_upper_cardinality = 1
-}

+ 0 - 65
models/CBD/metamodels/CBD_MM_partial_runtime.mvc

@@ -1,65 +0,0 @@
-include "primitives.alh"
-
-SimpleAttribute Float {}
-SimpleAttribute String {}
-
-Class Block{
-    signal : Float {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-}
-Class ICBlock : Block {
-    last_in : Float {
-        target_lower_cardinality = 0
-        target_upper_cardinality = 1
-    }
-}
-
-Class ConstantBlock : Block {
-    value : Float {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-}
-
-Class ProbeBlock : Block {
-    name : String {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-}
-
-Class AdditionBlock : Block {}
-Class NegatorBlock : Block {}
-Class MultiplyBlock : Block {}
-Class InverseBlock : Block {}
-Class DelayBlock : ICBlock {}
-Class IntegratorBlock : ICBlock {
-    last_out : Float {
-        target_lower_cardinality = 0
-        target_upper_cardinality = 1
-    }
-}
-
-Class DerivatorBlock : ICBlock {}
-Class Time{
-    lower_cardinality = 1
-    upper_cardinality = 1
-
-    start_time : Float {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-
-    current_time : Float {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-}
-
-Association Link(Block, Block){}
-Association InitialCondition(Block, ICBlock){
-    source_lower_cardinality = 0
-    source_upper_cardinality = 1
-}

+ 0 - 65
models/CBD/metamodels/CBD_MM_runtime.mvc

@@ -1,65 +0,0 @@
-include "primitives.alh"
-
-SimpleAttribute Float {}
-SimpleAttribute String {}
-
-Class Block{
-    signal : Float {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-}
-Class ICBlock : Block {
-    last_in : Float {
-        target_lower_cardinality = 0
-        target_upper_cardinality = 1
-    }
-}
-
-Class ConstantBlock : Block {
-    value : Float {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-}
-
-Class ProbeBlock : Block {
-    name : String {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-}
-
-Class AdditionBlock : Block {}
-Class NegatorBlock : Block {}
-Class MultiplyBlock : Block {}
-Class InverseBlock : Block {}
-Class DelayBlock : ICBlock {}
-Class IntegratorBlock : ICBlock {
-    last_out : Float {
-        target_lower_cardinality = 0
-        target_upper_cardinality = 1
-    }
-}
-
-Class DerivatorBlock : ICBlock {}
-Class Time{
-    lower_cardinality = 1
-    upper_cardinality = 1
-
-    start_time : Float {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-
-    current_time : Float {
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
-}
-
-Association Link(Block, Block){}
-Association InitialCondition(Block, ICBlock){
-    source_lower_cardinality = 0
-    source_upper_cardinality = 1
-}

+ 0 - 54
models/CBD/models/cbd_spring.mvc

@@ -1,54 +0,0 @@
-ConstantBlock cte_k {
-    value = 1
-}
-
-ConstantBlock cte_g {
-    value = 10
-}
-
-ConstantBlock cte_m {
-    value = 1
-}
-
-ConstantBlock cte_v0 {
-    value = 1
-}
-
-ConstantBlock cte_y0 {
-    value = 20
-}
-
-MultiplyBlock m0 {}
-MultiplyBlock m1 {}
-MultiplyBlock m2 {}
-NegatorBlock n0 {}
-InverseBlock i0 {}
-AdditionBlock a0 {}
-IntegratorBlock int0 {}
-IntegratorBlock int1 {}
-
-ProbeBlock pv {
-    name = "velocity"
-}
-ProbeBlock py {
-    name = "displacement"
-}
-
-Link (cte_k, m0) {}
-Link (int1, m0) {}
-Link (cte_g, m1) {}
-Link (cte_m, m1) {}
-Link (cte_m, i0) {}
-Link (m0, n0) {}
-Link (n0, a0) {}
-Link (m1, a0) {}
-Link (i0, m2) {}
-Link (a0, m2) {}
-Link (m2, int0) {}
-Link (int0, int1) {}
-
-InitialCondition (cte_v0, int0) {}
-InitialCondition (cte_y0, int1) {}
-
-Link (int0, pv) {}
-Link (int1, py) {}

+ 0 - 61
models/CBD/transformations/merge.alc

@@ -1,61 +0,0 @@
-include "primitives.alh"
-include "modelling.alh"
-include "object_operations.alh"
-include "conformance_scd.alh"
-include "utils.alh"
-include "typing.alh"
-include "mini_modify.alh"
-
-String function map_P2F(model : Element, name : String):
-	Element destinations
-	String pick
-
-	destinations = allAssociationDestinations(model, name, "P2F_block")
-
-	pick = name
-	while (pick == name):
-		pick = set_pop(destinations)
-
-	return pick!
-
-Boolean function main(model : Element):
-	Element all_blocks
-	String element_name
-	Float current_time
-	String time_block
-
-	all_blocks = allInstances(model, "PartialRuntime/Block")
-	while (set_len(all_blocks) > 0):
-		element_name = set_pop(all_blocks)
-		if (set_len(allOutgoingAssociationInstances(model, element_name, "P2F_block")) > 0):
-			// Element already exists in full, so copy existing attributes
-            if (is_nominal_instance(model, element_name, "PartialRuntime/ICBlock")):
-                instantiate_attribute(model, element_name, "last_in", read_attribute(model, map_P2F(model, element_name), "last_in"))
-            if (is_nominal_instance(model, element_name, "PartialRuntime/IntegratorBlock")):
-                instantiate_attribute(model, element_name, "last_out", read_attribute(model, map_P2F(model, element_name), "last_out"))
-            instantiate_attribute(model, element_name, "signal", read_attribute(model, map_P2F(model, element_name), "signal"))
-		else:
-			// Element doesn't exist, so initialize with 0.0
-            instantiate_attribute(model, element_name, "signal", 0.0)
-			instantiate_link(model, "P2F_block", "", element_name, element_name)
-
-	if (set_len(allInstances(model, "FullRuntime/Time")) > 0):
-		// Time already exists, so copy the value
-		current_time = read_attribute(model, set_pop(allInstances(model, "FullRuntime/Time")), "current_time")
-	else:
-		// No time yet, so initialize
-		current_time = 0.0
-
-	time_block = instantiate_node(model, "PartialRuntime/Time", "")
-	instantiate_attribute(model, time_block, "start_time", current_time)
-	instantiate_attribute(model, time_block, "current_time", current_time)
-
-	Element all_elements
-	String elem
-	all_elements = dict_keys(model["model"])
-	while (set_len(all_elements) > 0):
-		elem = set_pop(all_elements)
-		if (string_startswith(read_type(model, elem), "PartialRuntime/")):
-			retype(model, elem, "NewFullRuntime/" + cast_string(list_read(string_split_nr(read_type(model, elem), "/", 1), 1)))
-
-	return True!

+ 0 - 180
models/CBD/transformations/render.alc

@@ -1,180 +0,0 @@
-include "primitives.alh"
-include "modelling.alh"
-include "object_operations.alh"
-include "utils.alh"
-
-Boolean function main(model : Element):
-	Element elements
-	String class
-	Element attrs
-	Element attr_keys
-	String attr_key
-	String group
-	String elem
-	Integer loc
-	Integer text_loc
-	Element related_groups
-	loc = 10
-
-	Element groups
-	groups = dict_create()
-
-	elements = allInstances(model, "rendered/Group")
-	while (set_len(elements) > 0):
-		group = set_pop(elements)
-		if (set_len(allIncomingAssociationInstances(model, group, "TracabilityClass")) == 0):
-			Element to_remove
-			String elem_to_remove
-			to_remove = allAssociationDestinations(model, group, "rendered/contains")
-			while (set_len(to_remove) > 0):
-				elem_to_remove = set_pop(to_remove)
-				if (read_type(model, elem_to_remove) == "rendered/Group"):
-					set_add(to_remove, elem_to_remove)
-				else:
-					model_delete_element(model, elem_to_remove)
-			model_delete_element(model, group)
-
-	elements = allInstances(model, "abstract/Block")
-	while (set_len(elements) > 0):
-		class = set_pop(elements)
-		
-		Integer x
-		Integer y
-		x = loc
-		y = 10
-
-		// Check if there is already an associated element
-		if (set_len(allOutgoingAssociationInstances(model, class, "TracabilityClass")) > 0):
-			// Yes, but is it still clean?
-			Boolean dirty
-			dirty = False
-
-			related_groups = allAssociationDestinations(model, class, "TracabilityClass")
-			while (set_len(related_groups) > 0):
-				group = set_pop(related_groups)
-				if (value_eq(read_attribute(model, group, "dirty"), True)):
-					// No, so mark all as dirty
-					dirty = True
-					break!
-				else:
-					// Yes, so just ignore this!
-					continue!
-
-			if (bool_not(dirty)):
-				dict_add(groups, class, group)
-				continue!
-			else:
-				related_groups = allAssociationDestinations(model, class, "TracabilityClass")
-				Element to_remove
-				String elem_to_remove
-				while (set_len(related_groups) > 0):
-					group = set_pop(related_groups)
-					to_remove = allAssociationDestinations(model, group, "rendered/contains")
-					x = create_value(read_attribute(model, group, "x"))
-					y = create_value(read_attribute(model, group, "y"))
-					while (set_len(to_remove) > 0):
-						elem_to_remove = set_pop(to_remove)
-						if (read_type(model, elem_to_remove) == "rendered/Group"):
-							set_add(to_remove, elem_to_remove)
-						else:
-							model_delete_element(model, elem_to_remove)
-					model_delete_element(model, group)
-
-		attr_keys = dict_keys(getAttributeList(model, class))
-		text_loc = 5
-
-		group = instantiate_node(model, "rendered/Group", "")
-		instantiate_attribute(model, group, "x", x)
-		instantiate_attribute(model, group, "y", y)
-		instantiate_attribute(model, group, "__asid", list_read(string_split_nr(class, "/", 1), 1))
-		instantiate_attribute(model, group, "layer", 0)
-		dict_add(groups, class, group)
-		loc = loc + 100
-
-		elem = instantiate_node(model, "rendered/Rectangle", "")
-		instantiate_attribute(model, elem, "x", 0)
-		instantiate_attribute(model, elem, "y", 0)
-		instantiate_attribute(model, elem, "height", 50)
-		instantiate_attribute(model, elem, "width", 50)
-		instantiate_attribute(model, elem, "lineWidth", 4) 
-		instantiate_attribute(model, elem, "lineColour", "black")
-		instantiate_attribute(model, elem, "fillColour", "white")
-		instantiate_attribute(model, elem, "layer", 1)
-		instantiate_link(model, "rendered/contains", "", group, elem)
-
-		elem = instantiate_node(model, "rendered/Text", "")
-		instantiate_attribute(model, elem, "x", 20)
-		instantiate_attribute(model, elem, "y", 20)
-		instantiate_attribute(model, elem, "lineWidth", 1)
-		instantiate_attribute(model, elem, "lineColour", "black")
-		
-		String type
-		type = read_type(model, class)
-		if (type == "abstract/ConstantBlock"):
-			if (element_neq(read_attribute(model, class, "value"), read_root())):
-				instantiate_attribute(model, elem, "text", cast_string(read_attribute(model, class, "value")))
-			else:
-				instantiate_attribute(model, elem, "text", "?")
-		elif (type == "abstract/AdditionBlock"):
-			instantiate_attribute(model, elem, "text", "+")
-		elif (type == "abstract/NegatorBlock"):
-			instantiate_attribute(model, elem, "text", "-")
-		elif (type == "abstract/MultiplyBlock"):
-			instantiate_attribute(model, elem, "text", "X")
-		elif (type == "abstract/InverseBlock"):
-			instantiate_attribute(model, elem, "text", "1/x")
-		elif (type == "abstract/DelayBlock"):
-			instantiate_attribute(model, elem, "text", "DELAY")
-		elif (type == "abstract/IntegratorBlock"):
-			instantiate_attribute(model, elem, "text", "1/s")
-		elif (type == "abstract/DerivatorBlock"):
-			instantiate_attribute(model, elem, "text", "dx")
-		elif (type == "abstract/ProbeBlock"):
-			instantiate_attribute(model, elem, "text", "PROBE")
-
-		instantiate_attribute(model, elem, "layer", 2)
-		instantiate_link(model, "rendered/contains", "", group, elem)
-
-		instantiate_link(model, "TracabilityClass", "", class, group)
-
-	// Flush all associations
-	elements = allInstances(model, "rendered/ConnectingLine")
-	while (set_len(elements) > 0):
-		class = set_pop(elements)
-		model_delete_element(model, class)
-
-	// Rerender associations
-	elements = allInstances(model, "abstract/Link")
-	while (set_len(elements) > 0):
-		class = set_pop(elements)
-
-		elem = instantiate_link(model, "rendered/ConnectingLine", "", groups[readAssociationSource(model, class)], groups[readAssociationDestination(model, class)])
-		instantiate_attribute(model, elem, "offsetSourceX", 25)
-		instantiate_attribute(model, elem, "offsetSourceY", 25)
-		instantiate_attribute(model, elem, "offsetTargetX", 25)
-		instantiate_attribute(model, elem, "offsetTargetY", 25)
-		instantiate_attribute(model, elem, "lineWidth", 1)
-		instantiate_attribute(model, elem, "lineColour", "black")
-		instantiate_attribute(model, elem, "arrow", True)
-		instantiate_attribute(model, elem, "__asid", list_read(string_split_nr(class, "/", 1), 1))
-		instantiate_attribute(model, elem, "layer", 0)
-		instantiate_link(model, "rendered/contains", "", group, elem)
-
-	// Rerender initial conditions
-	elements = allInstances(model, "abstract/InitialCondition")
-	while (set_len(elements) > 0):
-		class = set_pop(elements)
-
-		elem = instantiate_link(model, "rendered/ConnectingLine", "", groups[readAssociationSource(model, class)], groups[readAssociationDestination(model, class)])
-		instantiate_attribute(model, elem, "offsetSourceX", 25)
-		instantiate_attribute(model, elem, "offsetSourceY", 25)
-		instantiate_attribute(model, elem, "offsetTargetX", 25)
-		instantiate_attribute(model, elem, "offsetTargetY", 25)
-		instantiate_attribute(model, elem, "lineWidth", 1)
-		instantiate_attribute(model, elem, "lineColour", "red")
-		instantiate_attribute(model, elem, "arrow", True)
-		instantiate_attribute(model, elem, "__asid", list_read(string_split_nr(class, "/", 1), 1))
-		instantiate_attribute(model, elem, "layer", 0)
-		instantiate_link(model, "rendered/contains", "", group, elem)
-
-	return True!

+ 0 - 297
models/CBD/transformations/render.mvc

@@ -1,297 +0,0 @@
-include "primitives.alh"
-include "modelling.alh"
-include "object_operations.alh"
-
-Composite schedule {
-    {Contains} Success success {}
-    {Contains} Failure failure {}
-
-    {Contains} ForAll update_blocks {
-        LHS {
-            Pre_abstract/Block pre_update_0 {
-                label = "0"
-            }
-            Pre_rendered/Group pre_update_1 {
-                label = "1"
-            }
-            Pre_TracabilityLink (pre_update_0, pre_update_1){
-                label = "2"
-            }
-        }
-        RHS {
-            Post_abstract/Block post_update_0 {
-                label = "0"
-            }
-            Post_rendered/Group post_update_1 {
-                label = "1"
-                value___asid = $
-                    String function value(model : Element, name : String, mapping : Element):
-                        // Update the mapping!
-                        if (read_nr_out(string_split(mapping["0"], "/")) > 1):
-                            return list_read(string_split(mapping["0"], "/"), 1)!
-                        else:
-                            return mapping["0"]!
-                    $
-                value_x = $
-                    Integer function value(model : Element, name : String, mapping : Element):
-                        return read_attribute(model, name, "x")!
-                    $
-                value_y = $
-                    Integer function value(model : Element, name : String, mapping : Element):
-                        return read_attribute(model, name, "y")!
-                    $
-            }
-            Post_TracabilityLink (post_update_0, post_update_1){
-                label = "2"
-            }
-        }
-    }
-
-    {Contains} ForAll render_blocks {
-        LHS {
-            Pre_abstract/Block pre_block_0 {
-                label = "0"
-            }
-
-            constraint = $
-                Boolean function constraint(model : Element, mapping : Element):
-                    Element trace_links
-                    trace_links = allOutgoingAssociationInstances(model, mapping["0"], "TracabilityLink")
-                    if (read_nr_out(trace_links) > 0):
-                        log("Block already connected; ignoring!")
-                        return False!
-                    else:
-                        return True!
-                $
-        }
-        RHS {
-            Post_abstract/Block post_block_0 {
-                label = "0"
-            }
-            Post_rendered/Group post_block_1 {
-                label = "1"
-                value___asid = $
-                    String function value(model : Element, name : String, mapping : Element):
-                        if (list_len(string_split(mapping["0"], "/")) > 1):
-                            return list_read(string_split(mapping["0"], "/"), 1)!
-                        else:
-                            return mapping["0"]!
-                    $
-                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_rendered/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 30!
-                    $
-                value_height = $
-                    Integer function value(model : Element, name : String, mapping : Element):
-                        return 30!
-                    $
-                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_rendered/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 == "abstract/AdditionBlock"):
-                            return "+"!
-                        elif (type == "abstract/NegatorBlock"):
-                            return "-"!
-                        elif (type == "abstract/ConstantBlock"):
-                            return "c"!
-                        elif (type == "abstract/MultiplyBlock"):
-                            return "*"!
-                        elif (type == "abstract/InverseBlock"):
-                            return "/"!
-                        elif (type == "abstract/DerivatorBlock"):
-                            return "d/dx"!
-                        elif (type == "abstract/IntegratorBlock"):
-                            return "1/s"!
-                        elif (type == "abstract/DelayBlock"):
-                            return "DELAY"!
-                        elif (type == "abstract/ProbeBlock"):
-                            return "PROBE"!
-                        else:
-                            return ("Unknown type: " + type)!
-                    $
-            }
-            Post_rendered/contains (post_block_1, post_block_2) {
-                label = "4"
-            }
-            Post_rendered/contains (post_block_1, post_block_3) {
-                label = "5"
-            }
-
-            Post_TracabilityLink (post_block_0, post_block_1) {
-                label = "6"
-            }
-        }
-    }
-
-    {Contains} ForAll remove_connections {
-        LHS {
-            Pre_rendered/Line {
-                label = "0"
-            }
-        }
-        RHS {
-        }
-    }
-
-    {Contains} ForAll render_connections {
-        LHS {
-            Pre_abstract/Block pre_conn_0 {
-                label = "0"
-            }
-
-            Pre_abstract/Block pre_conn_1 {
-                label = "1"
-            }
-
-            Pre_abstract/Link (pre_conn_0, pre_conn_1){
-                label = "2"
-            }
-
-            Pre_rendered/Group pre_conn_3 {
-                label = "3"
-            }
-
-            Pre_rendered/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_abstract/Block post_conn_0 {
-                label = "0"
-            }
-
-            Post_abstract/Block post_conn_1 {
-                label = "1"
-            }
-
-            Post_abstract/Link (post_conn_0, post_conn_1){
-                label = "2"
-            }
-
-            Post_rendered/Group post_conn_3 {
-                label = "3"
-            }
-
-            Post_rendered/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_rendered/Line {
-                label = "7"
-                value___asid = $
-                    String function value(model : Element, name : String, mapping : Element):
-                        if (list_len(string_split(mapping["2"], "/")) > 1):
-                            return list_read(string_split(mapping["2"], "/"), 1)!
-                        else:
-                            return mapping["2"]!
-                    $
-                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, update_blocks) {}
-
-OnSuccess (update_blocks, render_blocks) {}
-OnFailure (update_blocks, render_blocks) {}
-
-OnSuccess (render_blocks, remove_connections) {}
-OnFailure (render_blocks, remove_connections) {}
-
-OnSuccess (remove_connections, render_connections) {}
-OnFailure (remove_connections, render_connections) {}
-
-OnSuccess (render_connections, success) {}
-OnFailure (render_connections, success) {}

+ 0 - 467
models/CBD/transformations/simulate.alc

@@ -1,467 +0,0 @@
-include "primitives.alh"
-include "modelling.alh"
-include "object_operations.alh"
-include "conformance_scd.alh"
-include "io.alh"
-include "metamodels.alh"
-include "mini_modify.alh"
-
-Boolean function main(model : Element):
-	String cmd
-	Boolean running
-	Element schedule_init
-	Element schedule_run
-	Element schedule
-	Float current_time
-
-	String time
-	time = set_pop(allInstances(model, "FullRuntime/Time"))
-	current_time = read_attribute(model, time, "current_time")
-
-	schedule_init = create_schedule(model)
-	schedule_run = read_root()
-
-	Element nodes
-	Element inputs
-	String node
-	nodes = allInstances(model, "FullRuntime/Block")
-	inputs = dict_create()
-	while (set_len(nodes) > 0):
-		node = set_pop(nodes)
-		dict_add(inputs, node, allAssociationOrigins(model, node, "FullRuntime/Link"))
-
-	while (bool_not(has_input())):
-		if (read_attribute(model, time, "start_time") == read_attribute(model, time, "current_time")):
-			schedule = schedule_init
-		else:
-			if (element_eq(schedule_run, read_root())):
-				schedule_run = create_schedule(model)
-			schedule = schedule_run
-		current_time = step_simulation(model, schedule, current_time, inputs)
-
-	instantiate_attribute(model, time, "current_time", current_time)
-	output("CLOSE")
-	return True!
-
-Element function create_schedule(model : Element):
-	// Create nice graph first
-	Element nodes
-	Element successors
-	Element predecessors
-	String element_name
-	Element incoming_links
-	Element all_blocks
-
-	nodes = allInstances(model, "FullRuntime/Block")
-	successors = dict_create()
-	predecessors = dict_create()
-	while (set_len(nodes) > 0):
-		element_name = set_pop(nodes)
-		if (bool_not(dict_in(successors, element_name))):
-			dict_add(successors, element_name, create_node())
-		if (bool_not(dict_in(predecessors, element_name))):
-			dict_add(predecessors, element_name, create_node())
-
-		if (is_nominal_instance(model, element_name, "FullRuntime/ICBlock")):
-			if (bool_not(is_physical_float(read_attribute(model, element_name, "last_in")))):
-				incoming_links = allIncomingAssociationInstances(model, element_name, "FullRuntime/InitialCondition")
-			else:
-				incoming_links = create_node()
-			if (is_nominal_instance(model, element_name, "FullRuntime/DerivatorBlock")):
-				Element new_incoming_links
-				new_incoming_links = allIncomingAssociationInstances(model, element_name, "FullRuntime/Link")
-				while (read_nr_out(new_incoming_links) > 0):
-					list_append(incoming_links, set_pop(new_incoming_links))
-		else:
-			incoming_links = allIncomingAssociationInstances(model, element_name, "FullRuntime/Link")
-
-		while (set_len(incoming_links) > 0):
-			String source
-			source = readAssociationSource(model, set_pop(incoming_links))
-			if (bool_not(dict_in(successors, source))):
-				dict_add(successors, source, create_node())
-			set_add(successors[source], element_name)
-			set_add(predecessors[element_name], source)
-	
-	Element values
-	values = create_node()
-	dict_add(values, "model", model)
-	dict_add(values, "S", create_node())
-	dict_add(values, "index", 0)
-	dict_add(values, "indices", create_node())
-	dict_add(values, "lowlink", create_node())
-	dict_add(values, "onStack", create_node())
-	dict_add(values, "successors", successors)
-	dict_add(values, "predecessors", predecessors)
-	dict_add(values, "SCC", create_node())
-
-	nodes = get_topolist(values)
-	while (list_len(nodes) > 0):
-		strongconnect(list_pop_final(nodes), values)
-
-	return values["SCC"]!
-
-Element function get_topolist(values : Element):
-	Element result
-	Element predecessors
-	Element remaining
-	String current_element
-	Element cur_predecessors
-
-	result = list_create()
-	predecessors = dict_copy(values["predecessors"])
-
-	while (dict_len(predecessors) > 0):
-		remaining = dict_keys(predecessors)
-		while (set_len(remaining) > 0):
-			current_element = set_pop(remaining)
-			cur_predecessors = predecessors[current_element]
-			if (set_len(set_overlap(list_to_set(result), cur_predecessors)) == set_len(cur_predecessors)):
-				// All predecessors of this node have already been visited
-				dict_delete(predecessors, current_element)
-				remaining = dict_keys(predecessors)
-				list_append(result, current_element)
-
-	return result!
-
-Integer function min(a : Integer, b : Integer):
-	if (a < b):
-		return a!
-	else:
-		return b!
-
-Void function strongconnect(v : String, values : Element):
-	if (dict_in(values["indices"], v)):
-		return!
-
-	dict_overwrite(values["indices"], v, values["index"])
-	dict_overwrite(values["lowlink"], v, values["index"])
-	dict_overwrite(values, "index", cast_integer(values["index"]) + 1)
-
-	list_append(values["S"], v)
-	dict_overwrite(values["onStack"], v, True)
-	
-	Element successors
-	String w
-	successors = values["successors"][v]
-	while (set_len(successors) > 0):
-		w = set_pop(successors)
-		if (bool_not(dict_in(values["indices"], w))):
-			strongconnect(w, values)
-			dict_overwrite(values["lowlink"], v, min(values["lowlink"][v], values["lowlink"][w]))
-		elif (dict_in(values["onStack"], w)):
-			if (values["onStack"][w]):
-				dict_overwrite(values["lowlink"], v, min(values["lowlink"][v], values["indices"][w]))
-	
-	if (value_eq(values["lowlink"][v], values["indices"][v])):
-		Element scc
-		scc = create_node()
-		// It will always differ now
-		w = list_pop_final(values["S"])
-		list_append(scc, w)
-		dict_overwrite(values["onStack"], w, False)
-		while (w != v):
-			w = list_pop_final(values["S"])
-			list_append(scc, w)
-			dict_overwrite(values["onStack"], w, False)
-		list_insert(values["SCC"], scc, 0)
-
-	return!
-
-Boolean function solve_scc(model : Element, scc : Element):
-	Element m
-	Integer i
-	Integer j
-	String block
-	String blocktype
-	Element incoming
-	String selected
-	Float constant
-	Element t
-
-	// Construct the matrix first, with as many rows as there are variables
-	// Number of columns is 1 higher
-	i = 0
-	m = create_node()
-	while (i < read_nr_out(scc)):
-		j = 0
-		t = create_node()
-		while (j < (read_nr_out(scc) + 1)):
-			list_append(t, 0.0)
-			j = j + 1
-		list_append(m, t)
-		i = i + 1
-
-	// Matrix initialized to 0.0
-	i = 0
-	while (i < read_nr_out(scc)):
-		// First element of scc
-		block = scc[i]
-		blocktype = read_type(model, block)
-
-		// First write 1 in the current block
-		dict_overwrite(m[i], i, 1.0)
-
-		// Now check all blocks that are incoming
-		if (blocktype == "FullRuntime/AdditionBlock"):
-			constant = 0.0
-		elif (blocktype == "FullRuntime/MultiplyBlock"):
-			constant = 1.0
-
-		incoming = allIncomingAssociationInstances(model, block, "Link")
-
-		Integer index_to_write_constant
-		index_to_write_constant = -1
-		while (read_nr_out(incoming) > 0):
-			selected = readAssociationSource(model, set_pop(incoming))
-
-			if (set_in(scc, selected)):
-				// Part of the loop, so in the index of selected in scc
-				// Five options:
-				if (blocktype == "FullRuntime/AdditionBlock"):
-					// 1) AdditionBlock
-					// Add the negative of this signal, which is as of yet unknown
-					// x = y + z --> x - y - z = 0
-					dict_overwrite(m[i], list_index_of(scc, selected), -1.0)
-				elif (blocktype == "FullRuntime/MultiplyBlock"):
-					// 2) MultiplyBlock
-					if (index_to_write_constant != -1):
-						return False!
-					index_to_write_constant = list_index_of(scc, selected)
-				elif (blocktype == "FullRuntime/NegatorBlock"):
-					// 3) NegatorBlock
-					// Add the positive of the signal, which is as of yet unknown
-					dict_overwrite(m[i], list_index_of(scc, selected), 1.0)
-				elif (blocktype == "FullRuntime/DelayBlock"):
-					// 5) DelayBlock
-					// Just copies a single value
-					dict_overwrite(m[i], list_index_of(scc, selected), -1.0)
-				else:
-					// Block that cannot be handled
-					return False!
-			else:
-				// A constant, which we can assume is already computed and thus usable
-				if (blocktype == "FullRuntime/AdditionBlock"):
-					constant = constant + cast_float(read_attribute(model, selected, "signal"))
-					dict_overwrite(m[i], read_nr_out(scc), constant)
-				elif (blocktype == "FullRuntime/MultiplyBlock"):
-					constant = constant * cast_float(read_attribute(model, selected, "signal"))
-					// Not written to constant part, as multiplies a variable
-
-				// Any other block is impossible:
-				// * Constant would never be part of a SCC
-				// * Delay would never get an incoming constant
-				// * Negation and Inverse only get 1 input, which is a variable in a loop
-				// * Integrator and Derivator never get an incoming constant
-
-		if (index_to_write_constant != -1):
-			dict_overwrite(m[i], index_to_write_constant, -constant)
-
-		i = i + 1
-
-	// Constructed a complete matrix, so we can start!
-	log(matrix2string(m))
-
-	// Solve matrix now
-	eliminateGaussJordan(m)
-
-	// Now go over m and set signals for each element
-	// Assume that everything worked out...
-	i = 0
-	while (i < read_nr_out(m)):
-		block = scc[i]
-		instantiate_attribute(model, block, "signal", m[i][read_nr_out(scc)])
-		log((("Solved " + block) + " to ") + cast_string(m[i][read_nr_out(scc)]))
-		i = i + 1
-
-	return True!
-
-Integer function list_index_of(lst : Element, elem : Element):
-	Integer i
-	i = 0
-	while (i < read_nr_out(lst)):
-		if (value_eq(list_read(lst, i), elem)):
-			return i!
-		else:
-			i = i + 1
-	return -1!
-
-Float function step_simulation(model : Element, schedule : Element, time : Float, inputs : Element):
-	Float signal
-	Element incoming
-	String selected
-	String block
-	String elem
-	String blocktype
-	Element memory_blocks
-	Integer i
-	Float delta_t
-	Element scc
-
-	delta_t = 0.1
-
-	memory_blocks = set_create()
-	i = 0
-	while (i < list_len(schedule)):
-		scc = list_read(schedule, i)
-		i = i + 1
-
-		if (list_len(scc) > 1):
-			if (bool_not(solve_scc(model, scc))):
-				output("ALGEBRAIC_LOOP")
-				return time!
-		else:
-			block = list_read(scc, 0)
-
-			// Execute "block"
-			blocktype = read_type(model, block)
-			incoming = set_copy(inputs[block])
-			if (blocktype == "FullRuntime/ConstantBlock"):
-				signal = read_attribute(model, block, "value")
-			elif (blocktype == "FullRuntime/AdditionBlock"):
-				signal = 0.0
-				while (set_len(incoming) > 0):
-					selected = set_pop(incoming)
-					signal = signal + cast_float(read_attribute(model, selected, "signal"))
-			elif (blocktype == "FullRuntime/MultiplyBlock"):
-				signal = 1.0
-				while (set_len(incoming) > 0):
-					selected = set_pop(incoming)
-					signal = signal * cast_float(read_attribute(model, selected, "signal"))
-			elif (blocktype == "FullRuntime/NegatorBlock"):
-				signal = 0.0
-				while (set_len(incoming) > 0):
-					selected = set_pop(incoming)
-					signal = float_neg(cast_float(read_attribute(model, selected, "signal")))
-			elif (blocktype == "FullRuntime/InverseBlock"):
-				signal = 0.0
-				while (set_len(incoming) > 0):
-					selected = set_pop(incoming)
-					signal = float_division(1.0, cast_float(read_attribute(model, selected, "signal")))
-			elif (blocktype == "FullRuntime/DelayBlock"):
-				signal = 0.0
-				if (bool_not(is_physical_float(read_attribute(model, block, "last_in")))):
-					// No memory yet, so use initial condition
-					incoming = allAssociationOrigins(model, block, "FullRuntime/InitialCondition")
-					while (set_len(incoming) > 0):
-						selected = set_pop(incoming)
-						signal = cast_float(read_attribute(model, selected, "signal"))
-				else:
-					signal = read_attribute(model, block, "last_in")
-				set_add(memory_blocks, block)
-			elif (blocktype == "FullRuntime/IntegratorBlock"):
-				if (bool_not(is_physical_float(read_attribute(model, block, "last_in")))):
-					// No history yet, so use initial values
-					incoming = allAssociationOrigins(model, block, "FullRuntime/InitialCondition")
-					while (set_len(incoming) > 0):
-						selected = set_pop(incoming)
-						signal = cast_float(read_attribute(model, selected, "signal"))
-				else:
-					signal = cast_float(read_attribute(model, block, "last_out")) + (delta_t * cast_float(read_attribute(model, block, "last_in")))
-				instantiate_attribute(model, block, "last_out", signal)
-				set_add(memory_blocks, block)
-			elif (blocktype == "FullRuntime/DerivatorBlock"):
-				if (bool_not(is_physical_float(read_attribute(model, block, "last_in")))):
-					// No history yet, so use initial values
-					incoming = allAssociationOrigins(model, block, "FullRuntime/InitialCondition")
-					while (set_len(incoming) > 0):
-						selected = set_pop(incoming)
-						signal = cast_float(read_attribute(model, selected, "signal"))
-				else:
-					while (set_len(incoming) > 0):
-						selected = set_pop(incoming)
-						signal = (cast_float(read_attribute(model, selected, "signal")) - cast_float(read_attribute(model, block, "last_in"))) / delta_t
-				set_add(memory_blocks, block)
-			elif (blocktype == "FullRuntime/ProbeBlock"):
-				while (set_len(incoming) > 0):
-					signal = cast_float(read_attribute(model, set_pop(incoming), "signal"))
-					output(cast_string(time) + " " + cast_string(read_attribute(model, block, "name")) + " " + cast_string(signal))
-
-			instantiate_attribute(model, block, "signal", signal)
-	
-	while (set_len(memory_blocks) > 0):
-		block = set_pop(memory_blocks)
-		// Update memory
-		incoming = set_copy(inputs[block])
-		while (set_len(incoming) > 0):
-			selected = set_pop(incoming)
-			instantiate_attribute(model, block, "last_in", cast_float(read_attribute(model, selected, "signal")))
-
-	// Increase simulation time
-	return time + delta_t!
-
-Void function eliminateGaussJordan(m : Element):
-	Integer i
-	Integer j
-	Integer f
-	Integer g
-	Boolean searching
-	Element t
-	Float divisor
-
-	i = 0
-	j = 0
-
-	while (i < read_nr_out(m)):
-		// Make sure pivot m[i][j] != 0, swapping if necessary
-		while (cast_float(m[i][j]) == 0.0):
-			// Is zero, so find row which is not zero
-			f = i + 1
-			searching = True
-			while (searching):
-				if (f >= read_nr_out(m)):
-					// No longer any rows left, so just increase column counter
-					searching = False
-					j = j + 1
-				else:
-					if (cast_float(m[f][j]) == 0.0):
-						// Also zero, so continue
-						f = f + 1
-					else:
-						// Found non-zero, so swap row
-						t = cast_float(m[f])
-						dict_overwrite(m, f, cast_float(m[i]))
-						dict_overwrite(m, i, t)
-						searching = False
-			// If we have increased j, we will just start the loop again (possibly), as m[i][j] might be zero again
-
-		// Pivot in m[i][j] guaranteed to not be 0
-		// Now divide complete row by value of m[i][j] to make it equal 1
-		f = j
-		divisor = cast_float(m[i][j])
-		while (f < read_nr_out(m[i])):
-			dict_overwrite(m[i], f, float_division(cast_float(m[i][f]), divisor))
-			f = f + 1
-
-		// Eliminate all rows in the j-th column, except the i-th row
-		f = 0
-		while (f < read_nr_out(m)):
-			if (bool_not(f == i)):
-				g = j
-				divisor = cast_float(m[f][j])
-				while (g < read_nr_out(m[f])):
-					dict_overwrite(m[f], g, cast_float(m[f][g]) - (divisor * cast_float(m[i][g])))
-					g = g + 1
-			f = f + 1
-
-		// Increase row and column
-		i = i + 1
-		j = j + 1
-
-	return !
-
-String function matrix2string(m : Element):
-	Integer i
-	Integer j
-	String result
-
-	result = ""
-	i = 0
-	while (i < read_nr_out(m)):
-		j = 0
-		while (j < read_nr_out(m[i])):
-			result = result + cast_string(m[i][j]) + ", "
-			j = j + 1
-		i = i + 1
-		result = result + "\n"
-	return result!

+ 0 - 69
models/CBD/transformations/to_runtime.alc

@@ -1,69 +0,0 @@
-include "primitives.alh"
-include "modelling.alh"
-include "object_operations.alh"
-
-String function map_D2P(model : Element, name : String):
-	Element destinations
-	String pick
-
-	destinations = allAssociationDestinations(model, name, "D2P_block")
-
-	pick = name
-	while (pick == name):
-		pick = set_pop(destinations)
-
-	return pick!
-
-Boolean function main(model : Element):
-	Element all_blocks
-	String element_name
-	String new_element_name
-	String mm_type_name
-	Element all_links
-
-	all_blocks = allInstances(model, "Design/Block")
-	while (set_len(all_blocks) > 0):
-		element_name = set_pop(all_blocks)
-		mm_type_name = "PartialRuntime/" + cast_string(list_read(string_split(read_type(model, element_name), "/"), 1))
-
-		if (set_len(allOutgoingAssociationInstances(model, element_name, "D2P_block")) == 0):
-			// New design element, so create in partial runtime model as well
-			new_element_name = instantiate_node(model, mm_type_name, "")
-			instantiate_link(model, "D2P_block", "", element_name, new_element_name)
-
-		// Always update the value of attributes of PartialRuntime
-		new_element_name = map_D2P(model, element_name)
-		if (mm_type_name == "PartialRuntime/ConstantBlock"):
-            instantiate_attribute(model, new_element_name, "value", read_attribute(model, element_name, "value"))
-		elif (mm_type_name == "PartialRuntime/ProbeBlock"):
-            instantiate_attribute(model, new_element_name, "name", read_attribute(model, element_name, "name"))
-
-	all_blocks = allInstances(model, "PartialRuntime/Block")
-	while (set_len(all_blocks) > 0):
-		element_name = set_pop(all_blocks)
-		if (set_len(allIncomingAssociationInstances(model, element_name, "D2P_block")) == 0):
-			// Old partial runtime element, so remove
-			model_delete_element(model, element_name)
-
-	// Delete all existing links
-	all_links = allInstances(model, "PartialRuntime/Link")
-	while (set_len(all_links) > 0):
-		model_delete_element(model, set_pop(all_links))
-
-	all_links = allInstances(model, "PartialRuntime/InitialCondition")
-	while (set_len(all_links) > 0):
-		model_delete_element(model, set_pop(all_links))
-
-	// Recreate all of them
-    all_links = allInstances(model, "Design/Link")
-    while (set_len(all_links) > 0):
-        element_name = set_pop(all_links)
-        instantiate_link(model, "PartialRuntime/Link", "", map_D2P(model, readAssociationSource(model, element_name)), map_D2P(model, readAssociationDestination(model, element_name)))
-
-    all_links = allInstances(model, "Design/InitialCondition")
-    while (set_len(all_links) > 0):
-        element_name = set_pop(all_links)
-        instantiate_link(model, "PartialRuntime/InitialCondition", "", map_D2P(model, readAssociationSource(model, element_name)), map_D2P(model, readAssociationDestination(model, element_name)))
-
-
-	return True!

+ 1 - 1
models/generic/restart_simulation.alc

@@ -8,5 +8,5 @@ Boolean function main(model : Element):
 	root = read_root()
 	tasknames = set_copy(root[get_taskname()]["globals"]["pm_tasks"]["value"]["simulate"])
 	while (set_len(tasknames) > 0):
-		give_input_to_other(set_pop(tasknames), "")
+		give_input_to_other(set_pop(tasknames), "__EXIT__")
 	return True!

+ 1 - 1
models/old/upload_models.py

@@ -14,7 +14,6 @@ def add_trace_trace(model):
     instantiate(model, "Association", ("abstract/Signal", "rendered/Dataset"), ID="TracabilityLink")
 
 transformation_add_MT({"abstract": "formalisms/Trace", "rendered": "formalisms/MM_render/plot"}, {"rendered": "formalisms/MM_render/plot"}, "models/trace_mapper", open("models/trace_mapper.mvc", 'r').read(), add_trace_trace)
-"""
 
 model_add("formalisms/MM_render/graphical", "formalisms/SimpleClassDiagrams", open("models/MM_render.mvc", 'r').read())
 
@@ -23,6 +22,7 @@ def scd_tracability(model):
     instantiate(model, "Association", ("abstract/Association", "rendered/ConnectingLine"), ID="TracabilityAssociation")
 
 transformation_add_AL({"rendered": "formalisms/MM_render/graphical", "abstract": "formalisms/SimpleClassDiagrams"}, {"rendered": "formalisms/MM_render/graphical"}, "models/render_SCD", open("models/render_SCD.alc", 'r').read(), callback=scd_tracability)
+"""
 
 model_add("formalisms/CBD/Design_MM", "formalisms/SimpleClassDiagrams", open("models/cbd_design.mvc", 'r').read())
 model_add("formalisms/CBD/PartialRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/cbd_partial_runtime.mvc", 'r').read())

+ 2 - 2
wrappers/classes/modelverse.xml

@@ -1229,7 +1229,7 @@
 
                         <transition cond="self.expect_response_partial('Success: ', pop=False)" target="../../wait_for_action/history">
                             <raise event="result">
-                                <parameter expr="self.split_response(self.responses.pop(0))"/>
+                                <parameter expr="self.split_response(self.responses.pop(0))[0]"/>
                             </raise>
                         </transition>
                     </state>
@@ -1243,7 +1243,7 @@
 
                         <transition cond="self.expect_response_partial('Success: ', pop=False)" target="../../wait_for_action/history">
                             <raise event="result">
-                                <parameter expr="self.split_response(self.responses.pop(0))"/>
+                                <parameter expr="self.split_response(self.responses.pop(0))[0]"/>
                             </raise>
                         </transition>
                     </state>

+ 1 - 1
wrappers/modelverse.py

@@ -471,7 +471,7 @@ def all_instances(model_name, type_name, context=None):
     INPUT("all_instances", context, [model_name, type_name])
     return OUTPUT()
 
-def process_execute(process_name, model_mapping, callbacks=None):
+def process_execute(process_name, model_mapping, callbacks={}):
     # for all callbacks to SCs, start up the output port already
     sc_ports = {}
     for k, v in callbacks.items():