Пример #1
0
        private void startBtn_Click(object sender, EventArgs e) //QUERY BUTTON
        {
            bool check_untangle = true;

            //listView1.Columns.Add("Models Name", 100);
            //listView1.Clear();
            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();

            if (rp.repository == null)
            {
                MessageBox.Show("Repository not found", "Error");
                return;
            }
            //Initialized
            PQ = new gProAnalyzer.Functionalities.ProcessQuery();
            bool[]   flag_Check   = new bool[8];
            string[] Results_List = new string[rp.nModel];
            int      nResults     = 0;

            //get (X, Y)
            if (textBox2.Text == "" || textBox1.Text == "" || comboBox_BhR.Text == "" || comboBox_BhR.Text == "Select BhR")
            {
                MessageBox.Show("Input Empty", "Warnning");
                //(X, Y) must be ACTIVITY or TASK
                return;
            }
            int x = Int32.Parse(textBox1.Text);
            int y = Int32.Parse(textBox2.Text);

            //get query request (what behavior relation need to check) =>> flag_Check[] = false => get this relation
            flag_Check[0] = true; //totalConcurrency
            flag_Check[1] = true; //existConcurrency
            flag_Check[2] = true; //totalCausal
            flag_Check[3] = true; //existCausal
            //====================
            flag_Check[4] = true; //canConflict
            flag_Check[5] = true; //NOTcanConflict
            flag_Check[6] = true; //canCoocur
            flag_Check[7] = true; //NOTcanCoocur

            if (Convert.ToInt32(comboBox_BhR.Text[0].ToString()) == 0)
            {
                flag_Check[0] = false;
            }
            if (Convert.ToInt32(comboBox_BhR.Text[0].ToString()) == 1)
            {
                flag_Check[1] = false;
            }
            if (Convert.ToInt32(comboBox_BhR.Text[0].ToString()) == 2)
            {
                flag_Check[2] = false;
            }
            if (Convert.ToInt32(comboBox_BhR.Text[0].ToString()) == 3)
            {
                flag_Check[3] = false;
            }
            if (Convert.ToInt32(comboBox_BhR.Text[0].ToString()) == 4)
            {
                flag_Check[4] = false;
            }
            if (Convert.ToInt32(comboBox_BhR.Text[0].ToString()) == 6)
            {
                flag_Check[6] = false;
            }

            //get Scope of the query (FROM *) - how many model need to check.
            //For each MODEL => Perform query
            //retrieve the model from DATABASE (or retrieve in BATH)
            //perform the query technique
            //if MODEL satisfy the query => store in a list RESULTS[]
            DateTime totalTime = new DateTime(); totalTime = DateTime.Now; double Run_Times_total = 0;

            for (int i = 0; i < rp.nModel; i++)
            {
                int currentN = rp.repository[i].graph.finalNet;
                GraphVariables.clsHWLS curr_HWLS = rp.repository[i].clsHWLS;
                int workLoop = rp.repository[i].clsLoop.orgLoop;
                int workSESE = rp.repository[i].clsSESE.finalSESE;
                if (rp.repository[i].graph.check_untangle)
                {
                    currentN  = rp.repository[i].graph.untangleNet;
                    curr_HWLS = rp.repository[i].clsHWLS_Untangle;
                    workLoop  = rp.repository[i].clsLoop.untangleLoop;
                    workSESE  = rp.repository[i].clsSESE.untangleSESE;
                }

                if (check_XY(rp, currentN, i, x, y) == false)
                {
                    //MessageBox.Show("Index illegal", "Warning");
                    continue;
                }
                //check loop //NOT CONSIDER LOOP
                //if (rp.repository[i].clsLoop.Loop[0].nLoop > 0) continue;

                bool hold_PQ;

                if (rp.repository[i].graph.check_untangle)
                {
                    hold_PQ = PQ.start_ProcessQuery(ref rp.repository[i].graph, currentN, ref rp.repository[i].clsHWLS_Untangle, rp.repository[i].clsLoop, workLoop, rp.repository[i].clsSESE, workSESE, x, y, flag_Check);
                }
                else
                {
                    hold_PQ = PQ.start_ProcessQuery(ref rp.repository[i].graph, currentN, ref rp.repository[i].clsHWLS, rp.repository[i].clsLoop, workLoop, rp.repository[i].clsSESE, workSESE, x, y, flag_Check);
                }

                if (hold_PQ)
                {
                    Results_List[nResults] = rp.repository[i].ID_model;
                    //add to listview
                    //ListViewItem itm;
                    //itm = new ListViewItem(Results_List[nResults]);
                    //listView1.Items.Add(itm);
                    dataGridView1.Rows.Add(Results_List[nResults]);
                    nResults++;
                }
            }
            Run_Times_total = (DateTime.Now - totalTime).TotalSeconds;
            //MessageBox.Show("Finish in " + Run_Times_total.ToString() + " seconds", "Message");

            //display the Results_List[] - list of satisfied models to user.
            Results.Text = nResults.ToString() + " model(s)";
            string st = "Execution Time: ";

            ExeTime.Text     = st + Run_Times_total.ToString() + "s";
            QueryStatus.Text = "Success";
        }
Пример #2
0
        private void recordQueryTime(int model_index, int BhR_index, int x, int y)
        {
            if (rp.repository == null)
            {
                MessageBox.Show("Repository not found", "Error");
                return;
            }
            //Initialized
            PQ = new gProAnalyzer.Functionalities.ProcessQuery();
            bool[]   flag_Check   = new bool[8];
            string[] Results_List = new string[rp.nModel];

            //get query request (what behavior relation need to check) =>> flag_Check[] = false => get this relation
            flag_Check[0] = true; //totalConcurrency
            flag_Check[1] = true; //existConcurrency
            flag_Check[2] = true; //totalCausal
            flag_Check[3] = true; //existCausal
            //====================
            flag_Check[4] = true; //canConflict
            flag_Check[5] = true; //NOTcanConflict
            flag_Check[6] = true; //canCoocur
            flag_Check[7] = true; //NOTcanCoocur

            if (BhR_index == 0)
            {
                flag_Check[0] = false;
            }
            if (BhR_index == 1)
            {
                flag_Check[1] = false;
            }
            if (BhR_index == 2)
            {
                flag_Check[2] = false;
            }
            if (BhR_index == 3)
            {
                flag_Check[3] = false;
            }
            if (BhR_index == 4)
            {
                flag_Check[4] = false;
            }
            if (BhR_index == 6)
            {
                flag_Check[6] = false;
            }

            int i        = model_index;
            int currentN = rp.repository[i].graph.finalNet;
            //GraphVariables.clsHWLS curr_HWLS = rp.repository[i].clsHWLS;
            int workLoop = rp.repository[i].clsLoop.orgLoop;
            int workSESE = rp.repository[i].clsSESE.finalSESE;

            //if (rp.repository[i].graph.check_untangle)
            //{
            //    currentN = rp.repository[i].graph.untangleNet;
            //    //curr_HWLS = rp.repository[i].clsHWLS_Untangle;
            //    workLoop = rp.repository[i].clsLoop.untangleLoop;
            //    workSESE = rp.repository[i].clsSESE.untangleSESE;
            //}
            if (check_XY(rp, currentN, i, x, y) == true)
            {
                bool hold_PQ;
                hold_PQ = PQ.start_ProcessQuery(ref rp.repository[i].graph, currentN, ref rp.repository[i].clsHWLS, rp.repository[i].clsLoop, workLoop, rp.repository[i].clsSESE, workSESE, x, y, flag_Check);
            }
            //store file at once model
            //store_File(@"I:\PQ_Simulation.csv", rp.repository[i].ID_model, "__");
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e) //store data button
        {
            int maxIteration = 1000;

            if (rp.repository == null)
            {
                MessageBox.Show("Repository not found", "Error");
                return;
            }
            //Initialized
            PQ = new gProAnalyzer.Functionalities.ProcessQuery();
            bool[]   flag_Check   = new bool[8];
            string[] Results_List = new string[rp.nModel];
            int      nResults     = 0;

            //get query request (what behavior relation need to check) =>> flag_Check[] = false => get this relation
            flag_Check[0] = true; //totalConcurrency
            flag_Check[1] = true; //existConcurrency
            flag_Check[2] = true; //totalCausal
            flag_Check[3] = true; //existCausal
            //====================
            flag_Check[4] = true; //canConflict
            flag_Check[5] = true; //NOTcanConflict
            flag_Check[6] = true; //canCoocur
            flag_Check[7] = true; //NOTcanCoocur

            DateTime totalTime = new DateTime(); totalTime = DateTime.Now; double Run_Times_total = 0;
            DateTime tempTime = new DateTime();

            for (int i = 0; i < rp.nModel; i++)
            {
                double[] SessionTime = new double[8];
                for (int j = 0; j < 8; j++)
                {
                    flag_Check[j] = false;
                    int RandCount = 0;

                    //Generate a pair of X and Y based on Random(1, nNode) //100 times
                    do
                    {
                        Random rand = new Random();
                        int    x    = rand.Next(0, rp.repository[i].graph.Network[3].nNode);
                        int    y    = rand.Next(0, rp.repository[i].graph.Network[3].nNode);

                        int currentN = rp.repository[i].graph.finalNet;
                        //GraphVariables.clsHWLS curr_HWLS = rp.repository[i].clsHWLS;
                        int workLoop = rp.repository[i].clsLoop.orgLoop;
                        int workSESE = rp.repository[i].clsSESE.finalSESE;
                        if (rp.repository[i].graph.check_untangle)
                        {
                            currentN = rp.repository[i].graph.untangleNet;
                            //curr_HWLS = rp.repository[i].clsHWLS_Untangle;
                            workLoop = rp.repository[i].clsLoop.untangleLoop;
                            workSESE = rp.repository[i].clsSESE.untangleSESE;
                        }

                        if (check_XY(rp, currentN, i, x, y) == true)
                        {
                            tempTime = DateTime.Now;
                            bool hold_PQ;
                            if (rp.repository[i].graph.check_untangle)
                            {
                                hold_PQ = PQ.start_ProcessQuery(ref rp.repository[i].graph, currentN, ref rp.repository[i].clsHWLS_Untangle, rp.repository[i].clsLoop, workLoop, rp.repository[i].clsSESE, workSESE, x, y, flag_Check);
                            }
                            else
                            {
                                hold_PQ = PQ.start_ProcessQuery(ref rp.repository[i].graph, currentN, ref rp.repository[i].clsHWLS, rp.repository[i].clsLoop, workLoop, rp.repository[i].clsSESE, workSESE, x, y, flag_Check);
                            }

                            SessionTime[j] = SessionTime[j] + (DateTime.Now - tempTime).TotalMilliseconds;
                            RandCount++;
                        }
                    } while (RandCount < maxIteration);

                    SessionTime[j] = SessionTime[j] / maxIteration; //not divide by maxIteration =>> lower than that
                    flag_Check[j]  = true;
                }
                //store file at once model
                store_File(@"I:\PQ_Simulation.csv", rp.repository[i].ID_model, SessionTime);
            }
            Run_Times_total = (DateTime.Now - totalTime).TotalSeconds;
            MessageBox.Show("Finish in " + Run_Times_total.ToString() + " seconds", "Message");

            //display the Results_List[] - list of satisfied models to user.
        }