Beispiel #1
0
        //Sets the inervals
        private void setIntervalsAndRelations()
        {
            relations = new Dictionary <int, Dictionary <int, string> >();
            TemporalDB db = CCMiner.mainDB;

            sequences = new List <EventSequence>();
            for (int k = 0; k < actual_ids.Count; k++)
            {
                string t_id = TransformedDB.getID(actual_ids[k]);
                ids.Add(k, t_id);
                string        id       = t_id;
                EventSequence seq      = new EventSequence();
                List <string> seq_syms = CoincidenceManager.
                                         getPatternSymbols(pDB.patterns[actual_ids[k]].Item1);
                foreach (string sym in seq_syms)
                {
                    seq.ints.Add(db.seqs[id].getInterval(sym));
                }
                sequences.Add(seq);
                if (k == 0)
                {
                    for (int i = 0; i < length; i++)
                    {
                        relations.Add(i, new Dictionary <int, string>());
                        for (int j = i + 1; j < length; j++)
                        {
                            EventInterval ei1 = seq.ints[i];
                            EventInterval ei2 = seq.ints[j];
                            string        rel = getRelation(ei1, ei2);
                            relations[i].Add(j, rel);
                        }
                    }
                }
            }
        }
Beispiel #2
0
 //Returns Allen's suitable relation for the two intervals
 private string getRelation(EventInterval ei1, EventInterval ei2)
 {
     if (ei1.fin_time < ei2.st_time)
     {
         return(Constants.ALLEN_BEFORE);
     }
     if (ei1.fin_time == ei2.st_time)
     {
         return(Constants.ALLEN_MEET);
     }
     if (ei1.st_time == ei2.st_time && ei1.fin_time == ei2.fin_time)
     {
         return(Constants.ALLEN_EQUAL);
     }
     if (ei1.st_time < ei2.st_time && ei1.fin_time > ei2.fin_time)
     {
         return(Constants.ALLEN_CONTAIN);
     }
     if (ei1.st_time == ei2.st_time && ei1.fin_time < ei2.fin_time)
     {
         return(Constants.ALLEN_STARTS);
     }
     if (ei1.st_time < ei2.st_time && ei1.fin_time == ei2.fin_time)
     {
         return(Constants.ALLEN_FINISHBY);
     }
     return(Constants.ALLEN_OVERLAP);
 }
Beispiel #3
0
        public static EventInterval getInt(string id, string slc)
        {
            EventSequence es       = CCMiner.mainDB.seqs[id];
            string        tosearch = slc.Substring(0, slc.Length - 1);
            EventInterval ei2      = es.intsdic[tosearch];

            return(ei2);
        }
Beispiel #4
0
        //compares two event intervals
        public int Compare(EventInterval other)
        {
            int st_dif = st_time - other.st_time;

            if (st_dif != 0)
            {
                return(st_dif);
            }
            int fin_dif = fin_time - other.fin_time;

            if (fin_dif != 0)
            {
                return(fin_dif);
            }
            int sym_dif = IncisionStrategy.compareSyms(sym, other.sym);

            return(sym_dif);
        }
Beispiel #5
0
        //Returns true if the max gap constraint holds
        public static bool maxGapHolds(string id, int time, string slc)
        {
            if (time < 0)
            {
                return(true);
            }
            if (slc[0] == Constants.MEET_REP)
            {
                slc = slc.Substring(1);
            }
            EventSequence es = CCMiner.mainDB.seqs[id];

            if (slc[0] == Constants.CO_REP)
            {
                slc = slc.Substring(1);
            }
            string        tosearch = slc.Substring(0, slc.Length - 1);
            EventInterval ei2      = es.intsdic[tosearch];

            return(Constants.MAX_GAP > ei2.st_time - time);
        }
Beispiel #6
0
        //
        private int getUpdatedEndTime(string id, int last_time, string slc)
        {
            EventSequence es = CCMiner.mainDB.seqs[id];

            if (slc[0] == Constants.MEET_REP)
            {
                slc = slc.Substring(1);
            }
            if (slc[0] == Constants.CO_REP)
            {
                slc = slc.Substring(1);
            }
            string        tosearch = slc.Substring(0, slc.Length - 1);
            EventInterval ei2      = es.intsdic[tosearch];
            int           time     = ei2.fin_time;

            if (last_time < 0 || last_time > time)
            {
                return(time);
            }
            return(last_time);
        }
Beispiel #7
0
        //Adds the event interval to the list using binary search
        public void addIntervalBinary(EventInterval ei)
        {
            intsdic.Add(ei.sym, ei);
            int min = 0;
            int max = ints.Count - 1;
            int mid = 0;

            while (min <= max)
            {
                mid = (min + max) / 2;
                if (ei.Compare(ints[mid]) < 0)
                {
                    max = mid - 1;
                }
                else
                {
                    min = mid + 1;
                }
            }
            ints.Insert(min, ei);
            //ints.Add(ei);
        }