Exemplo n.º 1
0
        public static void run_algorithm(int num_entities, double min_support, int maximal_gap, string file_path)
        {
            Constants.FILE_NAME = file_path + ".csv";
            bool closed = true;

            Constants.OUT_FILE = file_path + "-support-" + min_support + "-maxgap-" + maximal_gap + ".txt";
            double dsp = (num_entities * (min_support / 100.0));

            Constants.MINSUP = (int)dsp == dsp ? (int)dsp : (int)dsp + 1;
            Console.WriteLine(Constants.MINSUP);
            Constants.MAX_GAP = maximal_gap;
            long dt1 = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            //Create the Temporal DB
            TemporalDB tdb = new TemporalDB(Constants.FILE_NAME);
            //Run the main Algorithm
            CTP  ctp  = CCMiner.ccMiner(tdb, closed);
            long dt2  = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            long diff = dt2 - dt1;

            Console.WriteLine("Finished Running: support - " + min_support + " gap - " + maximal_gap);
            Console.WriteLine(diff);
            Thread.Sleep(2000);
            string[] to_write = new string[1];
            to_write[0] = diff + "";
            File.WriteAllLines(Constants.OUT_FILE + "-stats.txt", to_write);
            //outputConverter(Constants.OUT_FILE);
        }
Exemplo n.º 2
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);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        //The CCMiner main algorithm
        public static CTP ccMiner(TemporalDB DB, bool closed)
        {
            CTP ctp = new CTP();

            mainDB = DB;
            //Transforms the db into cincidence representation
            TransformedDB tdb = DB.transformDB();
            //all frequent slices
            Dictionary <string, int> tp1 = tdb.slicesFreq();
            //backward extension slices
            List <string> BS = null;
            //int tasks = 0;
            int count = 0;

            foreach (KeyValuePair <string, int> entry in tp1)
            {
                count++;
                Console.WriteLine(count + "/" + tp1.Count + "/" + entry.Key);
                //For each frequent starting slice
                if (entry.Value >= Constants.MINSUP && entry.Key.IndexOf(Constants.MEET_REP) < 0 &&
                    entry.Key.IndexOf(Constants.ST_REP) > 0)
                {
                    BS = new List <string>();
                    TransformedDB projDB = tdb.projectDB(entry.Key, null, false);
                    if (!closed || !tdb.CBackScan(BS, entry.Key))
                    {
                        if (closed)
                        {
                            BS.AddRange(tdb.backwardExtensionCheck(entry.Key));
                        }
                        CBIDE(projDB, entry.Key, projDB.sup, projDB.trans_db.Count, BS, ref ctp, closed);
                    }
                }
            }
            return(ctp);
        }