Browse Source

Added constraints on AL, but commented it out for performance reasons

Yentl Van Tendeloo 9 years ago
parent
commit
4d9edaec6c

+ 374 - 167
bootstrap/metamodels.alc

@@ -19,174 +19,381 @@ Element function constraint_string(model : Element, name : String):
 	else:
 		return "String has non-string instance"
 
+Element function constraint_if(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "if"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_while(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "while"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_break(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "break"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_continue(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "continue"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_assign(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "assign"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_return(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "return"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_output(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "output"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_input(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "input"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_declare(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "declare"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_global(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "global"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_access(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "access"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_constant(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "constant"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_resolve(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "resolve"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function constraint_call(model : Element, name : String):
+	if (is_physical_action(model["model"][name])):
+		if (cast_a2s(model["model"][name]) == "call"):
+			return "OK"
+		else:
+			return "Got wrong action primitive: " + cast_a2s(model["model"][name])
+	else:
+		return "Expected physical action value"
+
+Element function initialize_SCD(location : String):
+	Element scd
+	scd = instantiate_bottom()
+
+	// Initial model, typed using LTM_bottom
+	model_add_node(scd, "Class")
+	model_add_node(scd, "Any")
+	model_add_node(scd, "String")
+	model_add_value(scd, "name", "name")
+	model_add_edge(scd, "Association", "Class", "Any")
+	model_add_edge(scd, "Inheritance", "Class", "Class")
+	model_add_edge(scd, "Association_attribute", "Association", "String")
+	model_add_edge(scd, "Association_name", "Association_attribute", "name")
+	model_add_edge(scd, "assoc_inh_class", "Association", "Class")
+	model_add_edge(scd, "class_inh_any", "Class", "Any")
+	model_add_edge(scd, "string_inh_any", "String", "Any")
+
+	// Retype to a "real" LTM, which happens to be itself
+	retype_model(scd, scd)
+	define_inheritance(scd, "Inheritance")
+	retype(scd, "Class", "Class")
+	retype(scd, "Any", "Class")
+	retype(scd, "String", "Class")
+	retype(scd, "name", "String")
+	retype(scd, "Association", "Association")
+	retype(scd, "Inheritance", "Association")
+	retype(scd, "Association_attribute", "Association")
+	retype(scd, "Association_name", "Association_attribute")
+	retype(scd, "assoc_inh_class", "Inheritance")
+	retype(scd, "class_inh_any", "Inheritance")
+	retype(scd, "string_inh_any", "Inheritance")
+
+	// Add some attributes, now that it is an ordinary model
+	instantiate_node(scd, "Class", "Natural")
+	instantiate_link(scd, "Association", "lc", "Class", "Natural")
+	instantiate_attribute(scd, "lc", "name", "lower_cardinality")
+	instantiate_link(scd, "Association", "uc", "Class", "Natural")
+	instantiate_attribute(scd, "uc", "name", "upper_cardinality")
+	instantiate_link(scd, "Association", "slc", "Association", "Natural")
+	instantiate_attribute(scd, "slc", "name", "source_lower_cardinality")
+	instantiate_link(scd, "Association", "suc", "Association", "Natural")
+	instantiate_attribute(scd, "suc", "name", "source_upper_cardinality")
+	instantiate_link(scd, "Association", "tlc", "Association", "Natural")
+	instantiate_attribute(scd, "tlc", "name", "target_lower_cardinality")
+	instantiate_link(scd, "Association", "tuc", "Association", "Natural")
+	instantiate_attribute(scd, "tuc", "name", "target_upper_cardinality")
+
+	// Add in the Action Language metamodel
+	instantiate_node(scd, "Class", "Action")
+	instantiate_node(scd, "Class", "Statement")
+	instantiate_node(scd, "Class", "Expression")
+	instantiate_node(scd, "Class", "funcdef")
+	instantiate_node(scd, "Class", "param")
+	instantiate_node(scd, "Class", "if")
+	instantiate_node(scd, "Class", "break")
+	instantiate_node(scd, "Class", "while")
+	instantiate_node(scd, "Class", "continue")
+	instantiate_node(scd, "Class", "assign")
+	instantiate_node(scd, "Class", "return")
+	instantiate_node(scd, "Class", "output")
+	instantiate_node(scd, "Class", "declare")
+	instantiate_node(scd, "Class", "global")
+	instantiate_node(scd, "Class", "access")
+	instantiate_node(scd, "Class", "constant")
+	instantiate_node(scd, "Class", "input")
+	instantiate_node(scd, "Class", "resolve")
+	instantiate_node(scd, "Class", "call")
+	instantiate_link(scd, "Association", "dict_link", "Action", "Any")
+	instantiate_link(scd, "Association", "to_str", "dict_link", "String")
+	instantiate_attribute(scd, "to_str", "name", "name")
+	instantiate_link(scd, "Inheritance", "", "Action", "Any")
+	instantiate_link(scd, "Inheritance", "", "funcdef", "Action")
+	instantiate_link(scd, "Inheritance", "", "param", "Action")
+	instantiate_link(scd, "Inheritance", "", "Statement", "Action")
+	instantiate_link(scd, "Inheritance", "", "Expression", "Action")
+	instantiate_link(scd, "Inheritance", "", "resolve", "Statement")
+	instantiate_link(scd, "Inheritance", "", "if", "Statement")
+	instantiate_link(scd, "Inheritance", "", "break", "Statement")
+	instantiate_link(scd, "Inheritance", "", "continue", "Statement")
+	instantiate_link(scd, "Inheritance", "", "global", "Statement")
+	instantiate_link(scd, "Inheritance", "", "while", "Statement")
+	instantiate_link(scd, "Inheritance", "", "assign", "Statement")
+	instantiate_link(scd, "Inheritance", "", "return", "Statement")
+	instantiate_link(scd, "Inheritance", "", "call", "Statement")
+	instantiate_link(scd, "Inheritance", "", "declare", "Statement")
+	instantiate_link(scd, "Inheritance", "", "call", "Expression")
+	instantiate_link(scd, "Inheritance", "", "access", "Expression")
+	instantiate_link(scd, "Inheritance", "", "constant", "Expression")
+	instantiate_link(scd, "Inheritance", "", "input", "Expression")
+	instantiate_link(scd, "Association", "statement_next", "Statement", "Statement")
+	instantiate_link(scd, "Association", "if_cond", "if", "Expression")
+	instantiate_link(scd, "Association", "if_true", "if", "Statement")
+	instantiate_link(scd, "Association", "if_false", "if", "Statement")
+	instantiate_link(scd, "Association", "while_cond", "while", "Expression")
+	instantiate_link(scd, "Association", "while_body", "while", "Statement")
+	instantiate_link(scd, "Association", "assign_var", "assign", "Any")
+	instantiate_link(scd, "Association", "assign_value", "assign", "Expression")
+	instantiate_link(scd, "Association", "break_while", "break", "while")
+	instantiate_link(scd, "Association", "continue_while", "continue", "while")
+	instantiate_link(scd, "Association", "return_value", "return", "Expression")
+	instantiate_link(scd, "Association", "resolve_var", "resolve", "Any")
+	instantiate_link(scd, "Association", "access_var", "access", "Any")
+	instantiate_link(scd, "Association", "constant_node", "constant", "Any")
+	instantiate_link(scd, "Association", "output_node", "output", "Expression")
+	instantiate_link(scd, "Association", "global_var", "global", "String")
+	instantiate_link(scd, "Association", "param_name", "param", "String")
+	instantiate_link(scd, "Association", "param_value", "param", "Expression")
+	instantiate_link(scd, "Association", "param_next_param", "param", "param")
+	instantiate_link(scd, "Association", "funcdef_body", "funcdef", "Statement")
+	instantiate_link(scd, "Association", "call_func", "call", "Expression")
+	instantiate_link(scd, "Association", "call_params", "call", "param")
+	instantiate_link(scd, "Association", "call_last_param", "call", "param")
+
+	// Add cardinalities on how many connections are allowed: one of each
+	//instantiate_attribute(scd, "statement_next", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "if_cond", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "if_cond", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "if_true", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "if_true", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "if_false", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "while_cond", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "while_cond", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "while_body", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "while_body", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "assign_var", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "assign_var", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "assign_value", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "assign_value", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "break_while", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "break_while", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "continue_while", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "continue_while", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "return_value", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "resolve_var", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "resolve_var", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "access_var", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "access_var", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "constant_node", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "constant_node", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "output_node", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "output_node", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "global_var", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "global_var", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "param_name", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "param_name", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "param_value", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "param_value", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "param_next_param", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "funcdef_body", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "funcdef_body", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "call_func", "target_lower_cardinality", 1)
+	//instantiate_attribute(scd, "call_func", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "call_params", "target_upper_cardinality", 1)
+	//instantiate_attribute(scd, "call_last_param", "target_upper_cardinality", 1)
+
+	// Add constraints to all primitive classes
+	//add_constraint(scd, "if", constraint_if)
+	//add_constraint(scd, "while", constraint_while)
+	//add_constraint(scd, "break", constraint_break)
+	//add_constraint(scd, "continue", constraint_continue)
+	//add_constraint(scd, "assign", constraint_assign)
+	//add_constraint(scd, "return", constraint_return)
+	//add_constraint(scd, "output", constraint_output)
+	//add_constraint(scd, "input", constraint_input)
+	//add_constraint(scd, "declare", constraint_declare)
+	//add_constraint(scd, "global", constraint_global)
+	//add_constraint(scd, "access", constraint_access)
+	//add_constraint(scd, "constant", constraint_constant)
+	//add_constraint(scd, "resolve", constraint_resolve)
+	//add_constraint(scd, "call", constraint_call)
+
+	// Now still allow for constraints on classes
+	instantiate_link(scd, "Association", "constraint", "Class", "funcdef")
+	instantiate_attribute(scd, "constraint", "name", "constraint")
+
+	// And add some, to enforce correct physical types
+	add_constraint(scd, "Natural", constraint_natural)
+	add_constraint(scd, "String", constraint_string)
+
+	// Finally done, so export!
+	export_node(location, scd)
+	return scd
+
+Element function initialize_PN(location_SCD : String, location_PN : String):
+	Element pn
+	Element scd
+
+	scd = import_node(location_SCD)
+
+	pn = instantiate_model(scd)
+	define_inheritance(pn, "Inheritance")
+	instantiate_node(pn, "Class", "Place")
+	instantiate_node(pn, "Class", "Transition")
+	instantiate_node(pn, "Class", "Natural")
+	instantiate_link(pn, "Association", "P2T", "Place", "Transition")
+	instantiate_link(pn, "Association", "T2P", "Transition", "Place")
+	instantiate_link(pn, "Association", "Place_tokens", "Place", "Natural")
+	instantiate_attribute(pn, "Place_tokens", "name", "tokens")
+	instantiate_attribute(pn, "Place_tokens", "target_lower_cardinality", 1)
+	instantiate_attribute(pn, "Place_tokens", "target_upper_cardinality", 1)
+	instantiate_link(pn, "Association", "P2T_weight", "P2T", "Natural")
+	instantiate_attribute(pn, "P2T_weight", "name", "weight")
+	instantiate_attribute(pn, "P2T_weight", "target_lower_cardinality", 1)
+	instantiate_attribute(pn, "P2T_weight", "target_upper_cardinality", 1)
+	instantiate_link(pn, "Association", "T2P_weight", "T2P", "Natural")
+	instantiate_attribute(pn, "T2P_weight", "name", "weight")
+	instantiate_attribute(pn, "T2P_weight", "target_lower_cardinality", 1)
+	instantiate_attribute(pn, "T2P_weight", "target_upper_cardinality", 1)
+
+	// Add constraint on the Natural
+	add_constraint(pn, "Natural", constraint_natural)
+
+	// Add global constraints
+	//set_model_constraints(pn, petrinet_constraints)
+	export_node(location_PN, pn)
+
+	return pn
+
+Element function initialize_bottom(location_bottom : String):
+	Element ltm_bottom
+	ltm_bottom = instantiate_bottom()
+	model_add_node(ltm_bottom, "Node")
+	model_add_edge(ltm_bottom, "Edge", "Node", "Node")
+	model_add_edge(ltm_bottom, "inheritance", "Node", "Node")
+	model_add_edge(ltm_bottom, "__inh", "Edge", "Node")
+
+	retype_model(ltm_bottom, ltm_bottom)
+	define_inheritance(ltm_bottom, "inheritance")
+	retype(ltm_bottom, "Node", "Node")
+	retype(ltm_bottom, "Edge", "Edge")
+	retype(ltm_bottom, "inheritance", "Edge")
+	retype(ltm_bottom, "__inh", "inheritance")
+
+	export_node(location_bottom, ltm_bottom)
+
+	return ltm_bottom
+
 Element function create_metamodels():
 	if (bool_not(dict_in(dict_read(read_root(), "__hierarchy"), "models"))):
-		Element scd
-		scd = instantiate_bottom()
-
-		// Initial model, typed using LTM_bottom
-		model_add_node(scd, "Class")
-		model_add_node(scd, "Any")
-		model_add_node(scd, "String")
-		model_add_value(scd, "name", "name")
-		model_add_edge(scd, "Association", "Class", "Any")
-		model_add_edge(scd, "Inheritance", "Class", "Class")
-		model_add_edge(scd, "Association_attribute", "Association", "String")
-		model_add_edge(scd, "Association_name", "Association_attribute", "name")
-		model_add_edge(scd, "assoc_inh_class", "Association", "Class")
-		model_add_edge(scd, "class_inh_any", "Class", "Any")
-		model_add_edge(scd, "string_inh_any", "String", "Any")
-
-		// Retype to a "real" LTM, which happens to be itself
-		retype_model(scd, scd)
-		define_inheritance(scd, "Inheritance")
-		retype(scd, "Class", "Class")
-		retype(scd, "Any", "Class")
-		retype(scd, "String", "Class")
-		retype(scd, "name", "String")
-		retype(scd, "Association", "Association")
-		retype(scd, "Inheritance", "Association")
-		retype(scd, "Association_attribute", "Association")
-		retype(scd, "Association_name", "Association_attribute")
-		retype(scd, "assoc_inh_class", "Inheritance")
-		retype(scd, "class_inh_any", "Inheritance")
-		retype(scd, "string_inh_any", "Inheritance")
-
-		// Add some attributes, now that it is an ordinary model
-		instantiate_node(scd, "Class", "Natural")
-		instantiate_link(scd, "Association", "lc", "Class", "Natural")
-		instantiate_attribute(scd, "lc", "name", "lower_cardinality")
-		instantiate_link(scd, "Association", "uc", "Class", "Natural")
-		instantiate_attribute(scd, "uc", "name", "upper_cardinality")
-		instantiate_link(scd, "Association", "slc", "Association", "Natural")
-		instantiate_attribute(scd, "slc", "name", "source_lower_cardinality")
-		instantiate_link(scd, "Association", "suc", "Association", "Natural")
-		instantiate_attribute(scd, "suc", "name", "source_upper_cardinality")
-		instantiate_link(scd, "Association", "tlc", "Association", "Natural")
-		instantiate_attribute(scd, "tlc", "name", "target_lower_cardinality")
-		instantiate_link(scd, "Association", "tuc", "Association", "Natural")
-		instantiate_attribute(scd, "tuc", "name", "target_upper_cardinality")
-
-		// Add in the Action Language metamodel
-		instantiate_node(scd, "Class", "Action")
-		instantiate_node(scd, "Class", "Statement")
-		instantiate_node(scd, "Class", "Expression")
-		instantiate_node(scd, "Class", "funcdef")
-		instantiate_node(scd, "Class", "param")
-		instantiate_node(scd, "Class", "if")
-		instantiate_node(scd, "Class", "break")
-		instantiate_node(scd, "Class", "while")
-		instantiate_node(scd, "Class", "continue")
-		instantiate_node(scd, "Class", "assign")
-		instantiate_node(scd, "Class", "return")
-		instantiate_node(scd, "Class", "output")
-		instantiate_node(scd, "Class", "declare")
-		instantiate_node(scd, "Class", "global")
-		instantiate_node(scd, "Class", "access")
-		instantiate_node(scd, "Class", "constant")
-		instantiate_node(scd, "Class", "input")
-		instantiate_node(scd, "Class", "resolve")
-		instantiate_node(scd, "Class", "call")
-		instantiate_link(scd, "Association", "dict_link", "Action", "Any")
-		instantiate_link(scd, "Association", "to_str", "dict_link", "String")
-		instantiate_attribute(scd, "to_str", "name", "name")
-		instantiate_link(scd, "Inheritance", "", "Action", "Any")
-		instantiate_link(scd, "Inheritance", "", "funcdef", "Action")
-		instantiate_link(scd, "Inheritance", "", "param", "Action")
-		instantiate_link(scd, "Inheritance", "", "Statement", "Action")
-		instantiate_link(scd, "Inheritance", "", "Expression", "Action")
-		instantiate_link(scd, "Inheritance", "", "resolve", "Statement")
-		instantiate_link(scd, "Inheritance", "", "if", "Statement")
-		instantiate_link(scd, "Inheritance", "", "break", "Statement")
-		instantiate_link(scd, "Inheritance", "", "continue", "Statement")
-		instantiate_link(scd, "Inheritance", "", "global", "Statement")
-		instantiate_link(scd, "Inheritance", "", "while", "Statement")
-		instantiate_link(scd, "Inheritance", "", "assign", "Statement")
-		instantiate_link(scd, "Inheritance", "", "return", "Statement")
-		instantiate_link(scd, "Inheritance", "", "call", "Statement")
-		instantiate_link(scd, "Inheritance", "", "declare", "Statement")
-		instantiate_link(scd, "Inheritance", "", "call", "Expression")
-		instantiate_link(scd, "Inheritance", "", "access", "Expression")
-		instantiate_link(scd, "Inheritance", "", "constant", "Expression")
-		instantiate_link(scd, "Inheritance", "", "input", "Expression")
-		instantiate_link(scd, "Association", "statement_next", "Statement", "Statement")
-		instantiate_link(scd, "Association", "if_cond", "if", "Expression")
-		instantiate_link(scd, "Association", "if_true", "if", "Statement")
-		instantiate_link(scd, "Association", "if_false", "if", "Statement")
-		instantiate_link(scd, "Association", "while_cond", "while", "Expression")
-		instantiate_link(scd, "Association", "while_body", "while", "Statement")
-		instantiate_link(scd, "Association", "assign_var", "assign", "Any")
-		instantiate_link(scd, "Association", "assign_value", "assign", "Expression")
-		instantiate_link(scd, "Association", "break_while", "break", "while")
-		instantiate_link(scd, "Association", "continue_while", "continue", "while")
-		instantiate_link(scd, "Association", "return_value", "return", "Expression")
-		instantiate_link(scd, "Association", "resolve_var", "resolve", "Any")
-		instantiate_link(scd, "Association", "access_var", "access", "Any")
-		instantiate_link(scd, "Association", "constant_node", "constant", "Any")
-		instantiate_link(scd, "Association", "output_node", "output", "Expression")
-		instantiate_link(scd, "Association", "global_var", "global", "String")
-		instantiate_link(scd, "Association", "param_name", "param", "String")
-		instantiate_link(scd, "Association", "param_value", "param", "Expression")
-		instantiate_link(scd, "Association", "param_next_param", "param", "param")
-		instantiate_link(scd, "Association", "funcdef_body", "funcdef", "Statement")
-		instantiate_link(scd, "Association", "call_func", "call", "Expression")
-		instantiate_link(scd, "Association", "call_params", "call", "param")
-		instantiate_link(scd, "Association", "call_last_param", "call", "param")
-
-		// Now still allow for constraints on classes
-		instantiate_link(scd, "Association", "constraint", "Class", "funcdef")
-		instantiate_attribute(scd, "constraint", "name", "constraint")
-
-		// And add some, to enforce correct physical types
-		add_constraint(scd, "Natural", constraint_natural)
-		add_constraint(scd, "String", constraint_string)
-
-		// Finally done, so export!
-		export_node("models/SimpleClassDiagrams", scd)
-
-		// Now for some examples: a PetriNet
-		Element pn
-		pn = instantiate_model(scd)
-		define_inheritance(pn, "Inheritance")
-		instantiate_node(pn, "Class", "Place")
-		instantiate_node(pn, "Class", "Transition")
-		instantiate_node(pn, "Class", "Natural")
-		instantiate_link(pn, "Association", "P2T", "Place", "Transition")
-		instantiate_link(pn, "Association", "T2P", "Transition", "Place")
-		instantiate_link(pn, "Association", "Place_tokens", "Place", "Natural")
-		instantiate_attribute(pn, "Place_tokens", "name", "tokens")
-		instantiate_attribute(pn, "Place_tokens", "target_lower_cardinality", 1)
-		instantiate_attribute(pn, "Place_tokens", "target_upper_cardinality", 1)
-		instantiate_link(pn, "Association", "P2T_weight", "P2T", "Natural")
-		instantiate_attribute(pn, "P2T_weight", "name", "weight")
-		instantiate_attribute(pn, "P2T_weight", "target_lower_cardinality", 1)
-		instantiate_attribute(pn, "P2T_weight", "target_upper_cardinality", 1)
-		instantiate_link(pn, "Association", "T2P_weight", "T2P", "Natural")
-		instantiate_attribute(pn, "T2P_weight", "name", "weight")
-		instantiate_attribute(pn, "T2P_weight", "target_lower_cardinality", 1)
-		instantiate_attribute(pn, "T2P_weight", "target_upper_cardinality", 1)
-
-		// Add constraint on the Natural
-		add_constraint(pn, "Natural", constraint_natural)
-
-		// Add global constraints
-		//set_model_constraints(pn, petrinet_constraints)
-		export_node("models/PetriNets", pn)
-
-		Element ltm_bottom
-		ltm_bottom = instantiate_bottom()
-		model_add_node(ltm_bottom, "Node")
-		model_add_edge(ltm_bottom, "Edge", "Node", "Node")
-		model_add_edge(ltm_bottom, "inheritance", "Node", "Node")
-		model_add_edge(ltm_bottom, "__inh", "Edge", "Node")
-
-		retype_model(ltm_bottom, ltm_bottom)
-		define_inheritance(ltm_bottom, "inheritance")
-		retype(ltm_bottom, "Node", "Node")
-		retype(ltm_bottom, "Edge", "Edge")
-		retype(ltm_bottom, "inheritance", "Edge")
-		retype(ltm_bottom, "__inh", "inheritance")
-
-		export_node("models/LTM_bottom", ltm_bottom)
+		String location_SCD
+		String location_PN
+		String location_bottom
+
+		location_SCD = "models/SimpleClassDiagrams"
+		location_PN = "models/PetriNets"
+		location_bottom = "models/LTM_bottom"
+
+		initialize_SCD(location_SCD)
+		initialize_PN(location_SCD, location_PN)
+		initialize_bottom(location_bottom)
 
 	return dict_read(dict_read(read_root(), "__hierarchy"), "models")

+ 9 - 8
bootstrap/modelling.alc

@@ -2,6 +2,7 @@ include "primitives.alh"
 include "io.alh"
 include "object_operations.alh"
 include "constructors.alh"
+include "metamodels.alh"
 
 String function instantiated_name(element : Element, original : String):
 	if (original == ""):
@@ -195,8 +196,6 @@ Void function define_inheritance(model : Element, inheritance_name : String):
 Void function model_delete_element(model : Element, name : String):
 	// Remove the link
 	// 1) from the type mapping
-	log("Delete element with name " + name)
-	log("  ==> " + cast_e2s(model["model"][name]))
 	dict_delete(model["type_mapping"], model["model"][name])
 
 	// 2) from the model
@@ -250,18 +249,18 @@ Void function add_AL_links(model : Element, list : Element, element : Element, l
 	link = dict_read_edge(element, linkname)
 
 	// The link
-	dict_add(model["model"], "LNK__" + cast_id2s(link), link)
+	dict_add(model["model"], "__" + cast_id2s(link), link)
 	dict_add(model["type_mapping"], link, model["metamodel"]["model"]["dict_link"])
 
 	// The name link
 	link = read_out(link, 0)
-	dict_add(model["model"], "NLNK__" + cast_id2s(link), link)
+	dict_add(model["model"], "__" + cast_id2s(link), link)
 	dict_add(model["type_mapping"], link, model["metamodel"]["model"]["to_str"])
 
 	// The name node
 	link = read_edge_dst(link)
 	if (bool_not(set_in_node(model["model"], link))):
-		dict_add(model["model"], "NAME__" + cast_id2s(link), link)
+		dict_add(model["model"], "__" + cast_id2s(link), link)
 		dict_add(model["type_mapping"], link, model["metamodel"]["model"]["String"])
 
 	// Now add the destination to the worker list
@@ -300,7 +299,7 @@ String function add_AL(model : Element, element : Element):
 					type = "Any"
 
 			// Add the node itself
-			dict_add(model["model"], (type + "__") + cast_id2s(elem), elem)
+			dict_add(model["model"], "__" + cast_id2s(elem), elem)
 			dict_add(model["type_mapping"], elem, model["metamodel"]["model"][type])
 
 			// Now add its edges
@@ -347,8 +346,6 @@ String function add_AL(model : Element, element : Element):
 				add_AL_links(model, todo, elem, "params", "param")
 				add_AL_links(model, todo, elem, "last_param", "param")
 				add_AL_links(model, todo, elem, "next", "")
-			else:
-				log("Unknown type found in AL parser: " + type)
 
 	return reverseKeyLookup(model["model"], element)
 
@@ -394,5 +391,9 @@ Void function construct_model():
 			define_inheritance(input(), input())
 		elif (command == "add_constraint"):
 			add_constraint(input(), input(), construct_function())
+		elif (command == "initialize_SCD"):
+			initialize_SCD(input())
+		elif (command == "initialize_bottom"):
+			initialize_bottom(input())
 		else:
 			log("Modelling error: did not understand command " + command)

+ 1 - 1
integration/code/pn_interface.alc

@@ -268,8 +268,8 @@ Element function model_loaded(model : Element):
 			while (read_nr_out(keys_m) > 0):
 				v_m = set_pop(keys_m)
 				// Filter out anonymous objects
-				typename = reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], model["model"][v_m]))
 				if (bool_not(string_startswith(v_m, "__"))):
+					typename = reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], model["model"][v_m]))
 					output((("  " + v_m) + " : ") + typename)
 		elif (cmd == "read"):
 			output("Element to read?")

+ 2 - 2
integration/utils.py

@@ -157,7 +157,7 @@ def run_file(files, parameters, expected, mode):
         for e in expected:
             c = len(e) if isinstance(e, set) else 1
             for _ in range(c):
-                val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=30).read()
+                val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=120).read()
 
                 if proc.returncode is not None:
                     # Modelverse has already terminated, which isn't a good sign!
@@ -274,7 +274,7 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
                         # Modelverse has already terminated, which isn't a good sign!
                         return False
 
-                    val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=120 if not timeout else 20).read()
+                    val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=240 if not timeout else 20).read()
                 except:
                     if timeout:
                         return True

+ 3 - 0
interface/HUTN/includes/metamodels.alh

@@ -1 +1,4 @@
 Element function create_metamodels()
+Element function initialize_SCD(location : String)
+Element function initialize_PN(location_SCD : String, location_PN : String)
+Element function initialize_bottom(location : String)