Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        public Tuple <List <EventInterval>, int> moveFollowsToEarlierIntervals(Tuple <List <EventInterval>, int> z,
                                                                               EventInterval sk, int k)
        {
            int fft = Math.Min(sk.getEnd(), z.Item2);
            List <EventInterval> newl = new List <EventInterval>(z.Item1);

            newl.Add(sk);
            Tuple <List <EventInterval>, int> znew = new Tuple <List <EventInterval>, int>(newl, fft);

            return(znew);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public int CompareTo(object obj)
        {
            EventInterval other = (EventInterval)obj;

            if (this.start == other.start)
            {
                if (this.end == other.end)
                {
                    return(smallerThan(this.label, other.label));
                }
                else
                {
                    return(smallerThan(this.end, other.end));
                }
            }
            else
            {
                return(smallerThan(this.start, other.start));
            }
        }
Ejemplo n.º 5
0
        public static string getRelation(EventInterval A, EventInterval B, Dictionary <string, double> constraints)
        {
            string relation = null;
            double epsilon  = constraints["epsilon"];
            double gap      = constraints["gap"];

            if (Math.Abs(B.getStart() - A.getStart()) <= epsilon)
            {
                if (Math.Abs(B.getEnd() - A.getEnd()) <= epsilon)
                {
                    relation = "=";
                }
                else if (B.getEnd() - A.getEnd() > epsilon)
                {
                    relation = "S";
                }
            }
            else if (Math.Abs(B.getEnd() - A.getEnd()) <= epsilon && B.getStart() - A.getStart() > epsilon)
            {
                relation = "fi";
            }
            else if (B.getStart() - A.getStart() > epsilon && A.getEnd() - B.getEnd() > epsilon)
            {
                relation = "c";
            }
            else if (A.getEnd() - B.getStart() > epsilon && B.getStart() - A.getStart() > epsilon)
            {
                relation = "o";
            }
            else if (Math.Abs(B.getStart() - A.getEnd()) <= epsilon)
            {
                relation = "m";
            }
            else if (B.getStart() - A.getEnd() > epsilon && (gap == 0 || B.getStart() - A.getEnd() < gap))
            {
                relation = "<";
            }
            return(relation);
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        public List <EventInterval> getZTableSecondTable(List <int> E, string R, string Si, EventInterval s1)
        {
            if (this.FL2[2].ContainsKey(E) && this.FL2[2][E].ContainsKey(R) && this.FL2[2][E][R].ContainsKey(Si) &&
                this.FL2[2][E][R][Si].ContainsKey(s1))
            {
                return(this.FL2[2][E][R][Si][s1]);
            }
            return(null);

            /*try{
             *  return this.FL2[2][E][R][Si][s1];
             * }
             * catch
             * {
             *  return null;
             * }*/
        }