//Look for a match between some start be-tiep to a corresponding finish tiep projector public bool checkStFinMatch(List <BETiep> sts, TiepProjector fin) { foreach (BETiep st in sts) { if (checkStFinMatch(st, fin)) { return(true); } } return(false); }
//Look for a match between a start be-tiep to a corresponding finish tiep projector public bool checkStFinMatch(BETiep st, TiepProjector fin) { List <string> ents = new List <string>(); foreach (KeyValuePair <int, int> sp_entry in fin.co_starts) { if (st.indexes.ContainsKey(sp_entry.Key) && checkStFinMatch(st.indexes[sp_entry.Key], sp_entry.Value)) { ents.Add(trans_db[sp_entry.Key].Item1.entity); } } bool closed = sup == ents.Count; return(closed); }
//Project the DB after the first time public SequenceDB projectDB(string alpha, TiepProjector tiep_instances) { CoincidenceSequence proj; //New db records List <Tuple <CoincidenceSequence, PatternInstance> > projDB = new List <Tuple <CoincidenceSequence, PatternInstance> >(); List <int> proj_indexes = new List <int>(); //New Pattern Instance PatternInstance newpi = null; //Corresponding Master Slice string temp_alpha = alpha; bool is_meet = false, is_co = false; if (temp_alpha[0] == Constants.MEET_REP) { is_meet = true; temp_alpha = temp_alpha.Substring(1); } else if (temp_alpha[0] == Constants.CO_REP) { is_co = true; temp_alpha = temp_alpha.Substring(1); } MasterTiep ms = TiepsHandler.master_tieps[temp_alpha]; //For each co sequence in db bool st = temp_alpha[temp_alpha.Length - 1] == Constants.ST_REP; Tiep occ; List <string> sup_ents = new List <string>(); foreach (KeyValuePair <int, int> sp_entry in tiep_instances.co_starts) { Tuple <CoincidenceSequence, PatternInstance> entry = trans_db[sp_entry.Key]; string ent_id = entry.Item1.entity; List <Tiep> ms_entity = ms.tiep_occurrences[ent_id]; int last_time = entry.Item2.last; for (int i = sp_entry.Value; i < ms_entity.Count; i++) { if (ms_entity[i].time > entry.Item2.ptime) { continue; } if (st && !maxGapHolds(last_time, ms_entity[i])) { break; } occ = ms_entity[i]; proj = projectBy(occ, alpha, entry.Item1, occ.c, entry.Item2, is_meet); if (proj != null) { if (!sup_ents.Contains(ent_id)) { sup_ents.Add(ent_id); } newpi = new PatternInstance(); newpi.copyPatternToExtend(entry.Item2); newpi.extendPatternInstance(occ, proj.coes); int updated = getUpdatedEndTime(last_time, occ); newpi.last = updated; projDB.Add(new Tuple <CoincidenceSequence, PatternInstance>(proj, newpi)); proj_indexes.Add(sp_entry.Key); } if (is_co || is_meet || !st) { break; } } } List <string> prem = new List <string>(pre_matched); if (temp_alpha[temp_alpha.Length - 1] == Constants.ST_REP) { prem.Add(temp_alpha.Replace(Constants.ST_REP, Constants.FIN_REP)); } else { prem.Remove(temp_alpha); } return(new SequenceDB(projDB, proj_indexes, sup_ents.Count, prem)); }