Browse Source

Add matching algorithm

Yentl Van Tendeloo 8 years ago
parent
commit
0ddd634b89
2 changed files with 52 additions and 3 deletions
  1. 0 3
      core/core_algorithm.alc
  2. 52 0
      models/match.mvc

+ 0 - 3
core/core_algorithm.alc

@@ -645,12 +645,9 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			Element output_keys
 
 			input_keys = dict_keys(inputs)
-			log("Commence merge")
 			while (read_nr_out(input_keys) > 0):
 				key = set_pop(input_keys)
-				log("Key: " + key)
 				model_join(merged_model, get_full_model(get_model_id(inputs[key])), string_join(types[key], "/"))
-			log("Merge OK")
 
 			// 3) Transform
 

+ 52 - 0
models/match.mvc

@@ -0,0 +1,52 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+
+A B {
+    Composite schedule {
+        {Contains} Failure failure {}
+        {Contains} Success success {}
+        {Contains} Query match {
+            LHS {
+                Pre_Query/State {
+                    label = "0"
+                }
+                Pre_ReachabilityGraph/State {
+                    label = "1"
+                }
+            }
+            NAC {
+                Pre_Query/State pre_0 {
+                    label = "0"
+                }
+                Pre_ReachabilityGraph/State pre_1 {
+                    label = "1"
+                }
+                Pre_Query/Place pre_2 {
+                    label = "2"
+                }
+                Pre_ReachabilityGraph/Place pre_3 {
+                    label = "3"
+                }
+                Pre_Query/Contains (pre_0, pre_2) {
+                    label = "4"
+                }
+                Pre_Reachability/Contains (pre_1, pre_3) {
+                    label = "5"
+                }
+
+                constraint = $
+                    Boolean function constraint(host_model : Element, mapping : Element):
+                        Boolean names_match
+                        Boolean tokens_mismatch
+                        names_match = value_eq(read_attribute(host_model, mapping["2"], "name"), read_attribute(host_model, mapping["3"], "name"))
+                        tokens_mismatch = value_neq(read_attribute(host_model, mapping["2"], "tokens"), read_attribute(host_model, mapping["3"], "tokens"))
+                        return bool_and(names_match, tokens_mismatch)!
+                    $
+            }
+        }
+    }
+    Initial (schedule, match) {}
+    OnSuccess (match, success) {}
+    OnFailure (match, failure) {}
+}