Przeglądaj źródła

Remove unused files

Yentl Van Tendeloo 8 lat temu
rodzic
commit
6e39d57529

+ 0 - 256
integration/code/fsa_semantics.alc

@@ -1,256 +0,0 @@
-include "primitives.alh"
-include "modelling.alh"
-include "object_operations.alh"
-include "library.alh"
-include "conformance_scd.alh"
-include "io.alh"
-include "metamodels.alh"
-include "compilation_manager.alh"
-
-Element function retype_to_runtime(design_model : Element):
-	Element runtime_model
-	Element all_states
-	Element all_links
-	String mm_type_name
-	String element_name
-	String attr_name
-	String attr_value
-	String attribute
-	String src
-	String dst
-	String time
-
-	runtime_model = instantiate_model(import_node("models/FiniteStateAutomata_Runtime"))
-
-	log("Retyping")
-	all_states = allInstances(design_model, "State")
-	while (list_len(all_states) > 0):
-		element_name = set_pop(all_states)
-		mm_type_name = reverseKeyLookup(design_model["metamodel"]["model"], dict_read_node(design_model["type_mapping"], design_model["model"][element_name]))
-		element_name = instantiate_node(runtime_model, mm_type_name, element_name)
-		instantiate_attribute(runtime_model, element_name, "name", read_attribute(design_model, element_name, "name"))
-
-	// Don't merge this together with the block conversion, as the destination block might not exist yet!
-	all_links = allInstances(design_model, "Transition")
-	while (read_nr_out(all_links) > 0):
-		element_name = set_pop(all_links)
-		src = reverseKeyLookup(design_model["model"], read_edge_src(design_model["model"][element_name]))
-		dst = reverseKeyLookup(design_model["model"], read_edge_dst(design_model["model"][element_name]))
-		instantiate_link(runtime_model, "Transition", element_name, src, dst)
-		instantiate_attribute(runtime_model, element_name, "event", read_attribute(design_model, element_name, "event"))
-
-		if (element_neq(read_attribute(design_model, element_name, "raise"), read_root())):
-			// There is a raise attribute
-			instantiate_attribute(runtime_model, element_name, "raise", read_attribute(design_model, element_name, "raise"))
-
-	log("DONE")
-	return runtime_model!
-
-Element function sanitize(new_runtime_model : Element, old_runtime_model : Element, auto : Boolean):
-	String cstate
-	String cstate_obj
-	log("Start sanitize")
-
-	cstate_obj = instantiate_node(new_runtime_model, "CurrentState", "")
-
-	if (read_nr_out(allInstances(old_runtime_model, "CurrentStateLink")) > 0):
-		cstate = readAssociationDestination(old_runtime_model, set_pop(allInstances(old_runtime_model, "CurrentStateLink")))
-		if (bool_not(dict_in(new_runtime_model["model"], cstate))):
-			// Current state removed, so fix
-			log("Removed current state")
-			if (auto):
-				log("Auto-fixing the problem")
-				cstate = set_pop(allInstances(new_runtime_model, "InitialState"))
-			else:
-				log("Please give new state")
-				while (bool_not(dict_in(new_runtime_model["model"], cstate))):
-					output("REQUEST_CURRENT_STATE")
-					cstate = input()
-	else:
-		// Initialize for the first time
-		cstate = set_pop(allInstances(new_runtime_model, "InitialState"))
-	
-	instantiate_link(new_runtime_model, "CurrentStateLink", "", cstate_obj, cstate)
-
-	log("Sanitize OK")
-	return new_runtime_model!
-
-Void function do_transition(model : Element, start_time : Float, event : String):
-	// Read out current state
-	String cstate_link
-	String cstate_obj
-	String cstate
-	String transition
-	String new_state
-	String raise
-
-	log("Transition executing")
-	cstate_link = set_pop(allInstances(model, "CurrentStateLink"))
-	cstate = readAssociationDestination(model, cstate_link)
-	cstate_obj = readAssociationSource(model, cstate_link)
-
-	// Read out all outgoing transitions
-	Element all_transitions
-	all_transitions = allOutgoingAssociationInstances(model, cstate, "Transition")
-
-	output("SIM_TIME " + cast_v2s(time() - start_time))
-	output("SIM_EVENT " + cast_v2s(event))
-
-	while (read_nr_out(all_transitions) > 0):
-		transition = set_pop(all_transitions)
-		if (value_eq(read_attribute(model, transition, "event"), event)):
-			// Found a match
-			new_state = readAssociationDestination(model, transition)
-			log("Transition to " + new_state)
-
-			// Delete current state
-			model_delete_element(model, cstate_link)
-
-			// Set destination of state
-			instantiate_link(model, "CurrentStateLink", "", cstate_obj, new_state)
-
-			log("Do state change")
-			output("SIM_STATE " + cast_v2s(read_attribute(model, new_state, "name")))
-
-			// Raise "raise" attribute of transition
-			raise = read_attribute(model, transition, "raise")
-			if (element_neq(raise, read_root())):
-				// Raise the event
-				output("SIM_RAISE " + cast_v2s(raise))
-
-			return !
-
-	return!
-
-Void function execute_fsa(design_model : Element):
-	String verify_result
-	Element runtime_model
-	Element old_runtime_model
-	String cmd
-	Boolean running
-	String conforming
-	Float simulation_time
-	Float start_time
-	Boolean automatic_sanitization
-
-	automatic_sanitization = True
-	start_time = time()
-	simulation_time = 0.0
-	old_runtime_model = instantiate_model(import_node("models/FiniteStateAutomata_Runtime"))
-	runtime_model = retype_to_runtime(design_model)
-
-	conforming = conformance_scd(design_model)
-	log("Conformance: " + conforming)
-	if (conforming == "OK"):
-		output("CONFORMANCE_OK")
-	else:
-		output("CONFORMANCE_FAIL")
-
-	while (True):
-		cmd = input()
-		log("Do: " + cmd)
-
-		if (cmd == "pause"):
-			// Pausing merely stops a running simulation
-			if (running):
-				simulation_time = time() - start_time
-				running = False
-				output("PAUSED")
-
-		elif (cmd == "simulate"):
-			// Continue simulation, so reset the value
-			if (bool_not(running)):
-				start_time = time() - simulation_time
-				running = True
-				output("CONTINUE")
-			
-		elif (cmd == "auto_sanitize"):
-			automatic_sanitization = input()
-
-		elif (cmd == "event"):
-			log("Got event")
-			do_transition(runtime_model, start_time, input())
-
-		elif (cmd == "read_available_attributes"):
-			// Returns a list of all available attributes
-			Element attr_list
-			Element attrs
-			Element attr
-			attr_list = getAttributeList(design_model, input())
-			attrs = dict_keys(attr_list)
-			while (0 < read_nr_out(attrs)):
-				attr = set_pop(attrs)
-				output("AVAILABLE_ATTR_VALUE " + cast_v2s(attr))
-				output("AVAILABLE_ATTR_TYPE " + cast_v2s(dict_read(attr_list, attr)))
-			output("AVAILABLE_ATTR_END")
-
-		elif (cmd == "read_attribute"):
-			// Returns the value of an attribute
-			output("ATTR_VALUE " + cast_v2s(read_attribute(design_model, input(), input())))
-
-		elif (bool_or(cmd == "switch_initial", bool_or(bool_or(cmd == "set_attribute", cmd == "instantiate_node"), bool_or(cmd == "delete_element", cmd == "instantiate_association")))):
-			// Modify the structure
-			if (cmd == "set_attribute"):
-				// Setting an attribute
-				String element_name
-				String attribute_name
-				element_name = input()
-				attribute_name = input()
-
-				// Delete it if it exists already
-				if (bool_not(element_eq(read_attribute(design_model, element_name, attribute_name), read_root()))):
-					unset_attribute(design_model, element_name, attribute_name)
-
-				// And finally set it
-				instantiate_attribute(design_model, element_name, attribute_name, input())
-
-			elif (cmd == "instantiate_node"):
-				// Instantiate a node
-				instantiate_node(design_model, input(), input())
-
-			elif (cmd == "instantiate_association"):
-				// Instantiate an association
-				instantiate_link(design_model, input(), input(), input(), input())
-
-			elif (cmd == "delete_element"):
-				// Delete the provided element
-				model_delete_element(design_model, input())
-
-			elif (cmd == "switch_initial"):
-				// Switch the initial state
-				if (read_nr_out(allInstances(design_model, "InitialState")) > 0):
-					retype(design_model, set_pop(allInstances(design_model, "InitialState")), "State")
-
-				retype(design_model, input(), "InitialState")
-
-			// After changes, we check whether or not the design model conforms
-			if (conforming == "OK"):
-				// Was correct, so store just to make sure
-				simulation_time = time() - start_time
-			conforming = conformance_scd(design_model)
-			if (conforming == "OK"):
-				// Conforming, so do the retyping and sanitization step
-				runtime_model = retype_to_runtime(design_model)
-				runtime_model = sanitize(runtime_model, old_runtime_model, automatic_sanitization)
-				old_runtime_model = runtime_model
-				start_time = time() - simulation_time
-				output("CONFORMANCE_OK")
-				log("Conformance became OK")
-			else:
-				// Not conforming, so stop simulation and block for input (preferably a modify to make everything consistent again)
-				output("CONFORMANCE_FAIL " + conforming)
-		else:
-			log("Did not understand command: " + cmd)
-
-		if (bool_and(conforming == "OK", running)):
-			output("SIM_TIME " + cast_v2s(time() - start_time))
-			output("SIM_STATE " + cast_v2s(read_attribute(runtime_model, readAssociationDestination(runtime_model, set_pop(allInstances(runtime_model, "CurrentStateLink"))), "name")))
-
-Void function main():
-	Element model
-	String verify_result
-
-	while (True):
-		execute_fsa(instantiate_model(import_node("models/FiniteStateAutomata_Design")))
-
-	return!

+ 0 - 13
integration/code/my_petrinet.mvc

@@ -1,13 +0,0 @@
-Place p1 {
-    tokens = 1
-}
-Place p2 {
-    tokens = 3
-}
-Transition t1 {}
-P2T (p1, t1) {
-    weight = 1
-}
-T2P (t1, p2) {
-    weight = 2
-}

+ 0 - 31
integration/code/petrinets_constraints.mvc

@@ -1,31 +0,0 @@
-include "primitives.alh"
-
-SimpleAttribute Natural {
-    constraint =
-        $
-        String function constraint_Natural(model : Element, name : String):
-            Element self
-            self = model["model"][name]
-            if (is_physical_int(self)):
-                if (integer_gte(self, 0)):
-                    return "OK"!
-                else:
-                    return "Natural number not larger than or equal to zero"!
-            else:
-                return "Natural number not larger than or equal to zero"!
-        $
-}
-
-Class Place{
-    tokens : Natural
-}
-
-Class Transition{}
-
-Association P2T (Place, Transition) {
-    weight : Natural
-}
-
-Association T2P (Transition, Place) {
-    weight : Natural
-}

+ 0 - 14
integration/code/pn_critical_section.mvc

@@ -1,14 +0,0 @@
-Place crit_1{
-    name = "CS1"
-    tokens = 0
-}
-
-Place crit_2{
-    name = "CS2"
-    tokens = 0
-}
-
-Place available{
-    name = "available"
-    tokens = 1
-}

+ 0 - 57
integration/code/pn_design_model_larger.mvc

@@ -1,57 +0,0 @@
-Place critical_section_1 {
-    tokens = 0
-    name = "critical_section_1"
-}
-Place critical_section_2 {
-    tokens = 0
-    name = "critical_section_2"
-}
-Place lock_available {
-    tokens = 1
-    name = "lock_available"
-}
-
-Transition release_section_1 {
-    name = "release_section_1"
-}
-Transition release_section_2 {
-    name = "release_section_2"
-}
-Transition acquire_section_1 {
-    name = "acquire_section_1"
-}
-Transition acquire_section_2 {
-    name = "acquire_section_2"
-}
-
-P2T (critical_section_1, release_section_1) {
-    weight = 1
-}
-
-P2T (critical_section_2, release_section_2) {
-    weight = 1
-}
-
-P2T (lock_available, acquire_section_1) {
-    weight = 1
-}
-
-P2T (lock_available, acquire_section_2) {
-    weight = 1
-}
-
-T2P (release_section_1, lock_available) {
-    weight = 1
-}
-
-T2P (release_section_2, lock_available) {
-    weight = 1
-}
-
-T2P (acquire_section_1, critical_section_1) {
-    weight = 1
-}
-
-T2P (acquire_section_2, critical_section_2) {
-    weight = 1
-}

+ 0 - 153
integration/code/pn_semantics.alc

@@ -1,153 +0,0 @@
-include "primitives.alh"
-include "modelling.alh"
-include "object_operations.alh"
-include "library.alh"
-include "conformance_scd.alh"
-
-Void function petrinet_enabled(model : Element):
-	Element set_enabled
-	set_enabled = petrinet_enabled_set(model)
-	output("Enabled transitions:")
-	while (0 < read_nr_out(set_enabled)):
-		output(set_pop(set_enabled))
-	return!
-
-Element function petrinet_enabled_set(model : Element):
-	Element all_transitions
-	Element enabled_transitions
-	String under_study
-	Element in_arcs
-	String arc_under_study
-	Boolean enabled
-
-	all_transitions = allInstances(model, "Transition")
-	enabled_transitions = create_node()
-
-	while (0 < read_nr_out(all_transitions)):
-		under_study = set_pop(all_transitions)
-		enabled = True
-
-		// Find all incoming transitions
-		in_arcs = allIncomingAssociationInstances(model, under_study, "P2T")
-
-		while (0 < read_nr_out(in_arcs)):
-			arc_under_study = set_pop(in_arcs)
-
-			Integer present_tokens
-			Integer required_tokens
-			required_tokens = read_attribute(model, arc_under_study, "weight")
-			log("Weight: " + cast_i2s(required_tokens))
-			present_tokens = read_attribute(model, reverseKeyLookup(model["model"], read_edge_src(model["model"][arc_under_study])), "tokens")
-			log("Tokens: " + cast_i2s(present_tokens))
-			if (present_tokens < required_tokens):
-				// Less tokens than required, so disable the transition completely
-				enabled = False
-
-		if (enabled):
-			set_add(enabled_transitions, under_study)
-
-	log("Got all enabled transitions!")
-	return enabled_transitions!
-
-Void function petrinet_fire(model : Element):
-	output("Transition to fire?")
-	String transition
-	transition = input()
-	if (dict_in(model["model"], transition)):
-		if (set_in(petrinet_enabled_set(model), transition)):
-			Element workset
-			String working_place
-			String working_arc
-			Integer new_value
-
-			// Consume tokens
-			workset = allIncomingAssociationInstances(model, transition, "P2T")
-			while (0 < read_nr_out(workset)):
-				working_arc = set_pop(workset)
-				working_place = reverseKeyLookup(model["model"], read_edge_src(model["model"][working_arc]))
-				new_value = integer_subtraction(read_attribute(model, working_place, "tokens"), read_attribute(model, working_arc, "weight"))
-				unset_attribute(model, working_place, "tokens")
-				instantiate_attribute(model, working_place, "tokens", new_value)
-				output((("  " + working_place) + ": ") + cast_i2s(read_attribute(model, working_place, "tokens")))
-
-			// Add tokens
-			workset = allOutgoingAssociationInstances(model, transition, "T2P")
-			while (0 < read_nr_out(workset)):
-				working_arc = set_pop(workset)
-				working_place = reverseKeyLookup(model["model"], read_edge_dst(model["model"][working_arc]))
-				new_value = integer_addition(read_attribute(model, working_place, "tokens"), read_attribute(model, working_arc, "weight"))
-				unset_attribute(model, working_place, "tokens")
-				instantiate_attribute(model, working_place, "tokens", new_value)
-				output((("  " + working_place) + ": ") + cast_i2s(read_attribute(model, working_place, "tokens")))
-			output("Transition fired!")
-		else:
-			output("Cannot fire if not enabled; aborting")
-	else:
-		output("Unknown transition; aborting")
-	return!
-
-Void function petrinet_list(model : Element):
-	Element keys 
-	Element typemap
-	Element place
-	String name
-
-	keys = dict_keys(model["model"])
-	typemap = model["type_mapping"]
-	place = model["metamodel"]["model"]["Place"]
-
-	while (list_len(keys) > 0):
-		name = set_pop(keys)
-		if (element_eq(dict_read_node(typemap, model["model"][name]), place)):
-			// Found a place
-			output((name + ": ") + cast_i2s(read_attribute(model, name, "tokens")))
-	return!
-
-Void function main():
-	Element model
-	String verify_result
-
-	while (True):
-		output("Which model do you want to execute with petri net semantics?")
-		model = import_node(input())
-
-		if (element_eq(model, read_root())):
-			output("Could not find model; aborting")
-		elif (element_neq(model["metamodel"], import_node("models/PetriNets"))):
-			output("Not a PetriNets model; aborting")
-		else:
-			verify_result = conformance_scd(model)
-			if (verify_result == "OK"):
-				output("Model OK!")
-				execute_petrinet(model)
-			else:
-				output("Non-conforming model: " + verify_result)
-
-	return!
-
-Void function execute_petrinet(model : Element):
-	String cmd
-	while (True):
-		output("Which operation do you want to execute?")
-		cmd = input()
-
-		if (cmd == "help"):
-			output("Supported operations:")
-			output("  help    -- this information")
-			output("  enabled -- list the enabled transitions")
-			output("  fire    -- fire a transition")
-			output("  list    -- list the state of the petrinet")
-			output("  exit    -- select another model")
-		elif (cmd == "enabled"):
-			petrinet_enabled(model)
-		elif (cmd == "fire"):
-			petrinet_fire(model)
-		elif (cmd == "list"):
-			petrinet_list(model)
-		elif (cmd == "exit"):
-			return!
-		else:
-			output("Did not understand command!")
-			output("Use 'help' for a list of available options")
-
-	return!

+ 0 - 87
integration/code/ramified_petrinets.mvc

@@ -1,87 +0,0 @@
-Class LHS{
-    constraint? : Expression
-    upper_cardinality = 1
-    lower_cardinality = 1
-}
-Class NAC{}
-Class Pre_Element{
-    label : String
-    constraint? : Expression
-}
-Association (LHS, Pre_Element)
-Association (NAC, Pre_Element){
-    target_lower_cardinality = 1
-}
-
-Class Pre_Place{}
-Class Pre_Transition{}
-Class Pre_Natural{}
-
-Association Pre_P2T(Pre_Place, Pre_Transition) {}
-Association Pre_T2P(Pre_Transition, Pre_Place) {}
-
-Association Pre_Place_tokens(Pre_Place, Pre_Natural) {
-    name = "Pre_tokens"
-    target_upper_cardinality = 1
-}
-Association Pre_P2T_weight(Pre_P2T, Pre_Natural) {
-    name = "Pre_weight"
-    target_upper_cardinality = 1
-}
-Association Pre_T2P_weight(Pre_T2P, Pre_Natural) {
-    name = "Pre_weight"
-    target_upper_cardinality = 1
-}
-
-Inheritance (Pre_Place, Pre_Element) {}
-Inheritance (Pre_Natural, Pre_Element) {}
-Inheritance (Pre_Transition, Pre_Element) {}
-Inheritance (Pre_P2T, Pre_Element) {}
-Inheritance (Pre_Place_tokens, Pre_Element) {}
-Inheritance (Pre_P2T_weight, Pre_Element) {}
-Inheritance (Pre_T2P_weight, Pre_Element) {}
-
-
-Post_PetriNets{
-// Add AL MM
-
-Class RHS{
-    action : FunctionDefinition
-    upper_cardinality = 1
-    lower_cardinality = 1
-}
-
-Class Post_Element {
-    label : String
-    value? : Expression
-}
-
-Class Post_Place{}
-Class Post_Transitions{}
-Class Post_Natural{}
-
-Association Post_P2T(Post_Place, Post_Transition) {}
-Association Post_T2P(Post_Transition, Post_Place) {}
-
-Association (Post_Place, Post_Natural) {
-    name = "Post_tokens"
-    target_upper_cardinality = 1
-}
-
-Association (Post_P2T, Post_Natural) {
-    name = "Post_weight"
-    target_upper_cardinality = 1
-}
-
-Association (Post_T2P, Post_Natural) {
-    name = "Post_weight"
-    target_upper_cardinality = 1
-}
-
-Inheritance (Post_Place, Post_Element) {}
-Inheritance (Post_Natural, Post_Element) {}
-Inheritance (Post_Transition, Post_Element) {}
-Inheritance (Post_P2T, Post_Element) {}
-Inheritance (Post_Place_tokens, Post_Element) {}
-Inheritance (Post_P2T_weight, Post_Element) {}
-Inheritance (Post_T2P_weight, Post_Element) {}

+ 0 - 27
integration/code/simpleclassdiagrams.mvc

@@ -1,27 +0,0 @@
-SimpleAttribute Natural {}
-SimpleAttribute String {}
-SimpleAttribute Boolean {}
-
-Class Element {}
-Class Class{
-    lower_cardinality? : Natural
-    upper_cardinality? : Natural
-}
-
-Association Association (Element, Element){
-    source_lower_cardinality? : Natural
-    source_upper_cardinality? : Natural
-    target_lower_cardinality? : Natural
-    target_upper_cardinality? : Natural
-}
-
-Association Attribute (Element, AttributeValue) {
-    optional : Boolean
-    name : String
-}
-
-Class AttributeValue {}
-Association Inheritance (Element, Element){}
-Inheritance assoc_inh_class (Association, Class) {}
-Inheritance class_inh_element (Class, Element) {}
-Inheritance attributevalue_inh_element (AttributeValue, Element) {}