public void initZ(EventInterval s1, EventInterval s2, int ek, string Rnew, string Si, string Rprev, Dictionary <string, Dictionary <string, List <Tuple <List <EventInterval>, int> > > > Ak) { List <int> to_check = new List <int>(); to_check.Add(s2.getLabel()); to_check.Add(ek); List <EventInterval> candidates = this.getZTableSecondTable(to_check, Rnew, Si, s2); if (candidates == null) { return; } foreach (EventInterval s3 in candidates) { if (s3.getStart() - Math.Min(s1.getEnd(), s2.getEnd()) >= this.constraints["gap"]) { continue; } string Rk = Rprev; List <int> pair = new List <int>(); pair.Add(s1.getLabel()); pair.Add(s3.getLabel()); bool foundRelation = false; foreach (string Rcand in this.FL2[2][pair].Keys) { this.comparisoncount += 1; List <EventInterval> relatArr = this.getZTableSecondTable(pair, Rcand, Si, s1); if (relatArr != null && relatArr.Contains(s3)) { Rk += "_" + Rcand; foundRelation = true; break; } } if (foundRelation == false) { continue; } Rk += "_" + Rnew; if (!Ak.ContainsKey(Rk)) { Ak.Add(Rk, new Dictionary <string, List <Tuple <List <EventInterval>, int> > >()); Ak[Rk].Add(Si, new List <Tuple <List <EventInterval>, int> >()); } else if (!Ak[Rk].ContainsKey(Si)) { Ak[Rk].Add(Si, new List <Tuple <List <EventInterval>, int> >()); } List <EventInterval> intervals = new List <EventInterval>(); intervals.Add(s1); intervals.Add(s2); intervals.Add(s3); Tuple <List <EventInterval>, int> z = new Tuple <List <EventInterval>, int>(intervals, Math.Min(Math.Min(s1.getEnd(), s2.getEnd()), s3.getEnd())); Ak[Rk][Si].Add(z); } }
public List <int> processAdding(List <Tuple <int, int, int> > eSeqList) { List <int> eventList = new List <int>(); foreach (Tuple <int, int, int> eve in eSeqList) { EventInterval newInterval = new EventInterval(eve.Item1, eve.Item2, eve.Item3); this.sequences.Add(newInterval); eventList.Add(newInterval.getLabel()); } return(eventList); }
public void extendZ(Tuple <List <EventInterval>, int> z, int ek, string Rnew, string Si, string Rprev, Dictionary <string, Dictionary <string, List <Tuple <List <EventInterval>, int> > > > Ak, int k) { List <int> to_check = new List <int>(); to_check.Add(z.Item1[z.Item1.Count - 1].getLabel()); to_check.Add(ek); List <EventInterval> candidates = this.getZTableSecondTable(to_check, Rnew, Si, z.Item1[z.Item1.Count - 1]); if (candidates == null) { return; } bool foundRelation = false; foreach (EventInterval sk in candidates) { if (sk.getStart() - z.Item2 >= this.constraints["gap"]) { continue; } string[] Rprevst = Rprev.Split("_").TakeLast(k - 2).ToArray(); List <string> Rk = new List <string>(); for (int idx = 0; idx < z.Item1.Count - 1; idx++) { EventInterval si = z.Item1[idx]; foundRelation = false; List <int> sik = new List <int>(); sik.Add(si.getLabel()); sik.Add(sk.getLabel()); if (!this.FL2[2].ContainsKey(sik)) { break; } if (Rprevst[idx] == "<") { Rk.Add("<"); foundRelation = true; continue; } foreach (string Rcand in this.FL2[2][sik].Keys) { this.comparisoncount += 1; List <EventInterval> relatArr = this.getZTableSecondTable(sik, Rcand, Si, si); if (relatArr != null && relatArr.Contains(sk)) { Rk.Add(Rcand); foundRelation = true; break; } } if (foundRelation == false) { break; } } if (foundRelation == false) { continue; } Tuple <List <EventInterval>, int> znew = this.moveFollowsToEarlierIntervals(z, sk, k); string Rk_str = Rprev; foreach (string R in Rk) { Rk_str = Rk_str + "_" + R; } Rk_str = Rk_str + "_" + Rnew; if (!Ak.ContainsKey(Rk_str)) { Ak.Add(Rk_str, new Dictionary <string, List <Tuple <List <EventInterval>, int> > >()); Ak[Rk_str].Add(Si, new List <Tuple <List <EventInterval>, int> >()); } else if (!Ak[Rk_str].ContainsKey(Si)) { Ak[Rk_str].Add(Si, new List <Tuple <List <EventInterval>, int> >()); } Ak[Rk_str][Si].Add(znew); } }