Kaynağa Gözat

implemented arule semantics

tpinna 10 yıl önce
ebeveyn
işleme
78cfcc6eaa
1 değiştirilmiş dosya ile 14 ekleme ve 1 silme
  1. 14 1
      integration/code/pn_interface.alc

+ 14 - 1
integration/code/pn_interface.alc

@@ -573,10 +573,16 @@ Integer function modulo(a:Integer,b:Integer):
 
 Integer RandomNumberState
 Integer function getRandomNumber(min:Integer, max:Integer):
+	//returns a random integer in min and max range, never max
+	if(min==max):
+		return min
 	if( bool_not(is_physical_int(RandomNumberState))):
 		RandomNumberState = 4 // xkcd.com/221/
 	RandomNumberState = modulo((8121*RandomNumberState) + 28411, 134456)
-	return modulo(RandomNumberState , (max-min)+1)+min
+	return modulo(RandomNumberState , (max-min))+min
+
+Element function list_select_random(list:Element):
+	return list_read(list, getRandomNumber(0,read_nr_out(list)))
 
 
 Element function tf_executeARule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element, pivots : Element):
@@ -609,6 +615,13 @@ Element function tf_executeARule(tf_er_transformation: Element,tf_er_rule: Eleme
 	Element final_matches
 	final_matches = mergeLHSNAC(tf_er_lhs, tf_er_nac)
 	
+	//select only one match
+	Element selected 
+	selected = list_select_random(final_matches)
+	final_matches = create_node()
+	list_append(final_matches, selected)
+	
+	
 	//extract pivots from the matches
 	extractPivots(final_matches, pivots, tf_er_transformation, tf_er_model)