Exemplo n.º 1
0
        //constructor for karma
        public Karma(int setEpsilon, int setMaxGap, double setMinVerSup, string dsFilePath, bool setHS1, int entitieSizeLimit = KLC.NUM_OF_ENTITIES)
        {
            //set variables
            epsilon = setEpsilon;
            max_gap = setMaxGap;
            HS1     = setHS1;

            //read input
            KLC.read_tids_file(dsFilePath, ref entityTISs, ref Symbols);

            entitieSize = entityTISs.Count;
            min_ver_sup = ((double)setMinVerSup / 100) * entitieSize;
            entitiesVec = new int[entitieSize];
            for (int eIdx = 0; eIdx < entitieSize; eIdx++)
            {
                entitiesVec[eIdx] = entityTISs.Keys.ElementAt(eIdx);
            }
            karma = new Tindex(entitieSize, relations_style);
            //load transition table
            KLC.LoadTransitionTableALLEN7(ref transition);
            RunKarma(entitieSizeLimit);
        }
Exemplo n.º 2
0
        // For KarmaLego
        public Dharma(int setMaxTirpSize, bool setFulleDics, int dharmaIndexType, bool runKarma, int setForBackWards, int setRelationStyle, int setEpsilon, int setMaxGap, double setMinVerSup, string dsFilePath, bool seTrans, bool setHS1, int setPrint, ref string runTime, int entitieSizeLimit = KLC.NUM_OF_ENTITIES)
        {
            DateTime starTime = DateTime.Now;
            string   timings  = "";

            mxAccsCounter   = 0;
            forBackWards    = setForBackWards;
            relations_style = setRelationStyle;
            epsilon         = setEpsilon;
            max_gap         = setMaxGap;
            HS1             = setHS1;
            maxTirpSize     = setMaxTirpSize;

            KLC.read_tids_file(dsFilePath, ref entityTISs, ref toncepts);

            entitieSize = entityTISs.Count;
            min_ver_sup = ((double)setMinVerSup / 100) * entitieSize;
            entitiesVec = new int[entitieSize];
            for (int eIdx = 0; eIdx < entitieSize; eIdx++)
            {
                entitiesVec[eIdx] = entityTISs.Keys.ElementAt(eIdx);
            }

            //twoSizedTIRPsMatrix = new twoSizedTIRPsMATRIXEntry[KLC.NUM_OF_SYMBOLS][]; //initialize keys vector
            //for (int i = 0; i < KLC.NUM_OF_SYMBOLS; i++)
            //    twoSizedTIRPsMatrix[i] = new twoSizedTIRPsMATRIXEntry[KLC.NUM_OF_SYMBOLS]; // initialize val vector

            //twoSizedTIRPsMatrixWithPsik = new twoSizedTIRPsMATRIXEntry[KLC.NUM_OF_SYMBOLS, KLC.NUM_OF_SYMBOLS];

            //karma = new tindex(entitieSize, relations_style);
            dharmaIdx = new dharmaIndex(dharmaIndexType, entitieSize, relations_style); //, setFulleDics);

            print = setPrint;
            trans = seTrans;
            if (trans)
            {
                KLC.LoadTransitionTableALLEN7(ref transition);//load transition table
            }

            if (forBackWards == KLC.backwardsMining)
            {
                logiRelsIndxs          = new int[KLC.MAX_TIRP_TONCEPTS_SIZE][];
                logiRelsIndxs[0 /*3*/] = new int[1]  {
                    0
                };
                logiRelsIndxs[1 /*3*/] = new int[3]  {
                    2, 1, 0
                };
                logiRelsIndxs[2 /*4*/] = new int[6]  {
                    5, 4, 2, 3, 1, 0
                };
                logiRelsIndxs[3 /*5*/] = new int[10] {
                    9, 8, 5, 7, 4, 2, 6, 3, 1, 0
                };
                logiRelsIndxs[4 /*6*/] = new int[15] {
                    14, 13, 9, 12, 8, 5, 11, 7, 4, 2, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[5 /*7*/] = new int[21] {
                    20, 19, 14, 18, 13, 9, 17, 12, 8, 5, 16, 11, 7, 4, 2, 15, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[6 /*8*/] = new int[28] {
                    27, 26, 20, 25, 19, 14, 24, 18, 13, 9, 23, 17, 12, 8, 5, 22, 16, 11, 7, 4, 2, 21, 15, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[7 /*9*/] = new int[36] {
                    35, 34, 27, 33, 26, 20, 32, 25, 19, 14, 31, 24, 18, 13, 9, 30, 23, 17, 12, 8, 5, 29, 22, 16, 11, 7, 4, 2, 28, 21, 15, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[8 /*9*/] = new int[45] {
                    44, 43, 35, 42, 34, 27, 41, 33, 26, 20, 40, 32, 25, 19, 14, 39, 31, 24, 18, 13, 9, 38, 30, 23, 17, 12, 8, 5, 37, 29, 22, 16, 11, 7, 4, 2, 36, 28, 21, 15, 10, 6, 3, 1, 0
                };
            }

            if (runKarma == true)
            {
                RunKarmaRun(null, 0, entitieSizeLimit);
            }

            DateTime endTime = DateTime.Now;

            runTime = endTime.Subtract(starTime).TotalMilliseconds.ToString(); // ((endTime - starTime).Minutes * 60 + (endTime - starTime).Seconds) + "," + (endTime - starTime).Minutes + ":" + (endTime - starTime).Seconds;
        }
Exemplo n.º 3
0
        // For Single KarmaLego
        public Dharma(int setMaxTirpSize, bool setFullDics, int dharmaIndexType, int frstEntIdx, int lstEntIdx, int setForBackWards, int setRelationStyle, int setEpsilon, int setMaxGap, string dsFilePath, bool runKarma, List <int> tonceptIds)
        {
            mxAccsCounter   = 0;
            forBackWards    = setForBackWards;
            relations_style = setRelationStyle;
            epsilon         = setEpsilon;
            max_gap         = setMaxGap;
            HS1             = false;
            maxTirpSize     = setMaxTirpSize;

            KLC.read_tids_file(dsFilePath, ref entityTISs, ref toncepts);

            entitieSize = entityTISs.Count;
            min_ver_sup = 0; // ((double)setMinVerSup / 100) * entitieSize;
            entitiesVec = new int[entitieSize];
            for (int eIdx = 0; eIdx < entitieSize; eIdx++)
            {
                entitiesVec[eIdx] = entityTISs.Keys.ElementAt(eIdx);
            }

            ////twoSizedTIRPsMatrix = new twoSizedTIRPsMATRIXEntry[KLC.NUM_OF_SYMBOLS][]; //initialize keys vector
            ////for (int i = 0; i < KLC.NUM_OF_SYMBOLS; i++)
            ////    twoSizedTIRPsMatrix[i] = new twoSizedTIRPsMATRIXEntry[KLC.NUM_OF_SYMBOLS]; // initialize val vector
            //karma = new tindex(entitieSize, relations_style);
            dharmaIdx = new dharmaIndex(dharmaIndexType, entitieSize, relations_style);//, setFullDics);
            //print = setPrint;
            //trans = seTrans;
            if (trans)
            {
                KLC.LoadTransitionTableALLEN7(ref transition);//load transition table
            }

            if (forBackWards == KLC.backwardsMining)
            {
                logiRelsIndxs          = new int[KLC.MAX_TIRP_TONCEPTS_SIZE][];
                logiRelsIndxs[0 /*3*/] = new int[1] {
                    0
                };
                logiRelsIndxs[1 /*3*/] = new int[3] {
                    2, 1, 0
                };
                logiRelsIndxs[2 /*4*/] = new int[6] {
                    5, 4, 2, 3, 1, 0
                };
                logiRelsIndxs[3 /*5*/] = new int[10] {
                    9, 8, 5, 7, 4, 2, 6, 3, 1, 0
                };
                logiRelsIndxs[4 /*6*/] = new int[15] {
                    14, 13, 9, 12, 8, 5, 11, 7, 4, 2, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[5 /*7*/] = new int[21] {
                    20, 19, 14, 18, 13, 9, 17, 12, 8, 5, 16, 11, 7, 4, 2, 15, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[6 /*8*/] = new int[28] {
                    27, 26, 20, 25, 19, 14, 24, 18, 13, 9, 23, 17, 12, 8, 5, 22, 16, 11, 7, 4, 2, 21, 15, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[7 /*9*/] = new int[36] {
                    35, 34, 27, 33, 26, 20, 32, 25, 19, 14, 31, 24, 18, 13, 9, 30, 23, 17, 12, 8, 5, 29, 22, 16, 11, 7, 4, 2, 28, 21, 15, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[8 /*9*/] = new int[45] {
                    44, 43, 35, 42, 34, 27, 41, 33, 26, 20, 40, 32, 25, 19, 14, 39, 31, 24, 18, 13, 9, 38, 30, 23, 17, 12, 8, 5, 37, 29, 22, 16, 11, 7, 4, 2, 36, 28, 21, 15, 10, 6, 3, 1, 0
                };
            }

            if (runKarma == true)
            {
                RunKarmaRun(tonceptIds, frstEntIdx, lstEntIdx);
            }
        }
Exemplo n.º 4
0
        /*
         * public static void runKLD(int legologi, int rels, int epsilon, int maxGap, int minSup, string klFile, bool seTrans, string mXprntD, string outFolder, string outFile, ref string karmaDTime, ref string legoDTime)
         * {
         *  DateTime starTime = DateTime.Now;
         *  KarmaLegoLib.KarmaD kD = new KarmaD(legologi, KLC.RELSTYLE_ALLEN7, epsilon, maxGap, minSup, klFile, seTrans);
         *  kD.RunKarmaRun();
         *  if(mXprntD != "")
         *      kD.printMatrixEntries(mXprntD);
         *  karmaDTime = (DateTime.Now - starTime).Minutes + ":" + (DateTime.Now - starTime).Seconds;
         *  starTime = DateTime.Now;
         *  kD.RunLegoALL(outFolder, seTrans, KLC.KL_PRINT_YES, outFile);
         *  legoDTime = (DateTime.Now - starTime).Minutes + ":" + (DateTime.Now - starTime).Seconds;
         *  starTime = DateTime.Now;
         *  kD = null;
         * }*/

        //public KarmaD(int setKarmaLegoLogi, int setRelationStyle, int setEpsilon, int setMaxGap, int setMinVerSup, string dsFilePath, bool seTrans)
        public KarmE(int setForBackWards, int setRelationStyle, int setEpsilon, int setMaxGap, double setMinVerSup, double setMinHrzSup, string dsFilePath, bool seTrans, bool setHS1, int setPrint, bool setParallel, ref string runTime, int setMaxTIRPSize, int eLast = KLC.NUM_OF_ENTITIES, int eFrst = 0)
        {
            parallel = setParallel;
            //karmalegologi = setKarmaLegoLogi;
            DateTime starTime = DateTime.Now;

            forBackWards    = setForBackWards;
            relations_style = setRelationStyle;
            epsilon         = setEpsilon;
            max_gap         = setMaxGap;
            maxTirpSize     = setMaxTIRPSize;
            //read_tids_file(0, KLC.NUM_OF_ENTITIES, dsFilePath, ref entityTISs, ref toncepts);
            read_tids_file(eFrst, eLast, dsFilePath, ref entityTISs, ref toncepts);
            entitieSize      = entityTISs.Count;
            min_ver_sup      = ((double)setMinVerSup / 100) * entitieSize;
            min_hrz_sup      = setMinHrzSup;
            entitiesKarmaVec = new entityKarma[entitieSize];
            int eIdx = 0;

            foreach (int eKey in entityTISs.Keys)
            {
                entitiesKarmaVec[eIdx++] = new entityKarma(eKey);
            }

            //glblMxRelsVerSupport = new int[KLC.NUM_OF_SYMBOLS][][];
            //glblMxRelsHrzSupport = new int[KLC.NUM_OF_SYMBOLS][][];
            //for (int i = 0; i < KLC.NUM_OF_SYMBOLS; i++)
            //{
            //    glblMxRelsVerSupport[i] = new int[KLC.NUM_OF_SYMBOLS][];
            //    glblMxRelsHrzSupport[i] = new int[KLC.NUM_OF_SYMBOLS][];
            //    for (int j = 0; j < KLC.NUM_OF_SYMBOLS; j++)
            //    {
            //        glblMxRelsVerSupport[i][j] = new int[relations_style];
            //        glblMxRelsHrzSupport[i][j] = new int[relations_style];
            //    }
            //}

            print = setPrint;
            string tesTrans;

            if (seTrans)
            {
                KLC.LoadTransitionTableALLEN7(ref transition);//load transition table
                transition = null;
            }

            if (forBackWards == KLC.backwardsMining)
            {
                logiRelsIndxs          = new int[KLC.MAX_TIRP_TONCEPTS_SIZE][];
                logiRelsIndxs[0 /*2*/] = new int[1]  {
                    0
                };
                logiRelsIndxs[1 /*3*/] = new int[3]  {
                    2, 1, 0
                };
                logiRelsIndxs[2 /*4*/] = new int[6]  {
                    5, 4, 2, 3, 1, 0
                };
                logiRelsIndxs[3 /*5*/] = new int[10] {
                    9, 8, 5, 7, 4, 2, 6, 3, 1, 0
                };
                logiRelsIndxs[4 /*6*/] = new int[15] {
                    14, 13, 9, 12, 8, 5, 11, 7, 4, 2, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[5 /*7*/] = new int[21] {
                    20, 19, 14, 18, 13, 9, 17, 12, 8, 5, 16, 11, 7, 4, 2, 15, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[6 /*8*/] = new int[28] {
                    27, 26, 20, 25, 19, 14, 24, 18, 13, 9, 23, 17, 12, 8, 5, 22, 16, 11, 7, 4, 2, 21, 15, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[7 /*9*/] = new int[36] {
                    35, 34, 27, 33, 26, 20, 32, 25, 19, 14, 31, 24, 18, 13, 9, 30, 23, 17, 12, 8, 5, 29, 22, 16, 11, 7, 4, 2, 28, 21, 15, 10, 6, 3, 1, 0
                };
                logiRelsIndxs[8 /*10*/] = new int[45] {
                    44, 43, 35, 42, 34, 27, 41, 33, 26, 20, 40, 32, 25, 19, 14, 39, 31, 24, 18, 13, 9, 38, 30, 23, 17, 12, 8, 5, 37, 29, 22, 16, 11, 7, 4, 2, 36, 28, 21, 15, 10, 6, 3, 1, 0
                };
            }

            if (runTime != "")
            {
                RunKarmaRun();
            }

            DateTime endTime = DateTime.Now;

            runTime = endTime.Subtract(starTime).TotalMilliseconds.ToString();
        }