瀏覽代碼

Print out the reachability graph before doing the matching

Yentl Van Tendeloo 8 年之前
父節點
當前提交
ff022dea2e

+ 3 - 0
bootstrap/conformance_scd.alc

@@ -21,6 +21,9 @@ Boolean function is_nominal_instance(model : Element, instance : String, type :
 		// doesn't even have a type
 		return False!
 
+	if (value_eq(model["type_mapping"][instance], type)):
+		return True!
+
 	return is_nominal_subtype(model["metamodel"], model["type_mapping"][instance], type)!
 
 Boolean function is_nominal_subtype(metamodel : Element, subclass : String, superclass : String):

+ 5 - 4
bootstrap/primitives.alc

@@ -241,10 +241,11 @@ String function dict_to_string(d : Element):
 	Element key
 
 	result = "{"
-	keys = dict_keys(d)
 
-	while (read_nr_out(keys)):
+	keys = dict_keys(d)
+	while (read_nr_out(keys) > 0):
 		key = set_pop(keys)
+
 		result = result + cast_v2s(key)
 		result = result + ": "
 		result = result + cast_v2s(dict_read_node(d, key))
@@ -314,9 +315,9 @@ Element function dict_copy(d : Element):
 	Element key
 
 	result = create_node()
-	keys = dict_keys(d)
 
-	while (read_nr_out(keys)):
+	keys = dict_keys(d)
+	while (read_nr_out(keys) > 0):
 		key = set_pop(keys)
 		dict_add(result, key, dict_read_node(d, key))
 

+ 0 - 7
integration/code/reachability.alc

@@ -97,11 +97,8 @@ Element function reachability_graph(params : Element, output_mms : Element):
 
 	while (read_nr_out(workset) > 0):
 		state_id = set_pop(workset)
-		log("Work on state ID " + cast_v2s(state_id))
 		log("Reachable states: " + cast_i2s(read_nr_out(reachable_states)))
-		log("Workset: " + cast_i2s(read_nr_out(workset)))
 
-		// TODO check if dict_repr is already in the set of reachable states
 		dict_repr = reachable_states[state_id]
 
 		// Compute how the PN behaves with this specific state
@@ -109,7 +106,6 @@ Element function reachability_graph(params : Element, output_mms : Element):
 		all_transitions = set_copy(all_transitions_original)
 		while (read_nr_out(all_transitions) > 0):
 			transition = set_pop(all_transitions)
-			log("Test " + cast_v2s(read_attribute(in_model, transition, "name")))
 
 			keys = dict_keys(transition_vectors_consume[transition])
 			possible = True
@@ -176,12 +172,9 @@ Element function reachability_graph(params : Element, output_mms : Element):
 							instantiate_attribute(out_model, place, "name", name)
 							instantiate_attribute(out_model, place, "tokens", new_dict_repr[key])
 							dict_add(sub, new_dict_repr[key], place)
-							log("Added to cache")
 						else:
 							place = sub[new_dict_repr[key]]
-							log("Accessed cache!")
 						instantiate_link(out_model, "Contains", "", state, place)
-						log("Total elements in out: " + cast_v2s(read_nr_out(out_model["model"])))
 
 				// Anyway, we have found a transition, which we should store
 				dict_add(mappings[state_id], transition, target_id)

+ 2 - 2
integration/code/reachabilitygraph_print.mvc

@@ -26,7 +26,7 @@ ReachabilityGraph_RAM reachabilitygraph_print {
                             while (read_nr_out(all_values) > 0):
                                 place = set_pop(all_values)
                                 dict_add(dict_values, read_attribute(model, place, "name"), read_attribute(model, place, "tokens"))
-                            output((cast_v2s(read_attribute(model, name, "name")) + ": ") + dict_to_string(dict_values))
+                            log((cast_v2s(read_attribute(model, name, "name")) + ": ") + dict_to_string(dict_values))
                             return!
                         $
                 }
@@ -56,7 +56,7 @@ ReachabilityGraph_RAM reachabilitygraph_print {
                     label = "2"
                     action = $
                         Void function action(model : Element, name : String, mapping : Element):
-                            output((((cast_v2s(read_attribute(model, mapping["0"], "name")) + " --[") + cast_v2s(read_attribute(model, name, "name"))) + "]--> ") + cast_v2s(read_attribute(model, mapping["1"], "name")))
+                            log((((cast_v2s(read_attribute(model, mapping["0"], "name")) + " --[") + cast_v2s(read_attribute(model, name, "name"))) + "]--> ") + cast_v2s(read_attribute(model, mapping["1"], "name")))
                             return!
                         $
                 }

+ 27 - 0
integration/test_powerwindow.py

@@ -202,6 +202,13 @@ class TestPowerWindow(unittest.TestCase):
                     "",
                     "combine_EPN",
                     ] + get_model_constructor_2("models/combine_EPN.mvc") + [
+                "transformation_add_MT",
+                    "All_RAM",
+                    "ReachabilityGraph",
+                    "",
+                    "",
+                    "print_reachability",
+                    ] + get_model_constructor_2("integration/code/reachabilitygraph_print.mvc") + [
                 "transformation_add_AL",
                     "PetriNet",
                     "",
@@ -426,6 +433,25 @@ class TestPowerWindow(unittest.TestCase):
                 "Name of new transformation?",
                 "Waiting for model constructors...",
                 "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNet",
+                     "  Encapsulated_PetriNet",
+                     "  Query",
+                     "  PW_Plant",
+                     "  PW_Environment",
+                     "  Requirements",
+                     "  PW_Control",
+                     "  ReachabilityGraph",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
                 # transformation_add_AL
                 ] + [   "Which metamodels do you want to use as source for the action code (empty string to finish)?",
                         "Model added as source",
@@ -491,6 +517,7 @@ class TestPowerWindow(unittest.TestCase):
                      "  make_initial_models : All_RAM",
                      "  pm_powerwindow : ProcessModel",
                      "  plant_to_EPN : All_RAM",
+                     "  print_reachability : All_RAM",
                      "  combine_EPN : All_RAM",
                      "  environment_to_EPN : All_RAM",
                      "  control_to_EPN : All_RAM",

+ 9 - 1
models/pm_req_analyse.mvc

@@ -61,6 +61,9 @@ ProcessModel analyse_requirements {
     Exec analyse {
         name = "reachability"
     }
+    Exec print_reachability {
+        name = "print_reachability"
+    }
 
     ForkJoin forkjoin3 {}
 
@@ -134,7 +137,8 @@ ProcessModel analyse_requirements {
     Next (forkjoin2, combine_EPN) {}
     Next (combine_EPN, print_pn) {}
     Next (print_pn, analyse) {}
-    Next (analyse, forkjoin3) {}
+    Next (analyse, print_reachability) {}
+    Next (print_reachability, forkjoin3) {}
     Next (refine_query, forkjoin3) {}
     Next (forkjoin3, matches) {}
     Next (matches, found) {}
@@ -221,6 +225,10 @@ ProcessModel analyse_requirements {
     Produces (analyse, reachability_graph) {
     }
 
+    Consumes (print_reachability, reachability_graph) {
+        name = "reachability_graph"
+    }
+
     Consumes (matches, reachability_graph) {
         name = "reachability_graph"
     }