Beispiel #1
0
		public double chose_rule(Random rd, out rule r){


			double a0;
			double[] a = get_propensities(out a0);
			if (a0 < EPSILON) {
				r = new b_rule();
				return 0.0;
			}


			double tau = -Math.Log (rd.NextDouble ()) / a0;
			int n = -1, nr = rules.Count;
			double s = 0, rx = rd.NextDouble ();
			while (n < nr-1 && s < rx) {
				n++;
				s += a [n] / a0;		
			}
			r = rules[n];
			return tau;
		}
Beispiel #2
0
		public void add_rule(rule o){
			if (!rules.Contains (o))
				rules.Add (o);			
		}