Esempio n. 1
0
        //#5
        public static bool check_Causal(GraphVariables.clsGraph graph, int currentN, int[] InstantNode, int nInstantNode, ref int[][] adjList, int x, int y, ref int xy_coo)
        {
            bool CanCooccur = check_CanCooccur(InstantNode, nInstantNode, x, y);

            if (CanCooccur)
            {
                xy_coo++;
            }
            else
            {
                return(false);
            }

            int[] getPath  = new int[nInstantNode];
            int   nGetPath = 0;

            bool[] Mark = new bool[graph.Network[currentN].nNode];
            gProAnalyzer.Ultilities.mappingGraph.to_adjList_bInstance(ref graph, currentN, ref adjList); //We already buil an instance subgraph based on InstanceNode !! Huaahhh~

            DFS(adjList, ref Mark, x, ref getPath, ref nGetPath);
            for (int i = 0; i < nGetPath; i++)
            {
                if (getPath[i] == y)
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public static int getCID_IL(GraphVariables.clsGraph graph, int fromN, GraphVariables.clsLoop clsLoop, int workLoop, int loop)
        {
            //gProAnalyzer.Ultilities.findIntersection interSect = new gProAnalyzer.Ultilities.findIntersection();
            //gProAnalyzer.Ultilities.reduceGraph reduceG = new gProAnalyzer.Ultilities.reduceGraph();

            int[] calDom = null;
            for (int k = 0; k < clsLoop.Loop[workLoop].Loop[loop].nEntry; k++)
            {
                calDom = gProAnalyzer.Ultilities.findIntersection.find_Intersection(graph.Network[fromN].nNode, calDom, graph.Network[fromN].Node[clsLoop.Loop[workLoop].Loop[loop].Entry[k]].Dom);
            }

            if (calDom.Length > 0)
            {
                int CID = -1;
                //pick another CID if current CID
                for (int i = calDom.Length - 1; i > -1; i--)
                {
                    if (gProAnalyzer.Ultilities.reduceGraph.check_CID_In_Loop(clsLoop, workLoop, loop, calDom[i]) == false)
                    {
                        CID = calDom[i];
                        break;
                    }
                }
                if (CID == -1)
                {
                    MessageBox.Show("Find_IncludeNode of DFlow error", "Error");
                    return(-1); //error
                }
                int header = CID;
                return(header);
            }
            return(-1);
        }
Esempio n. 3
0
        public static void add_to_exclusiveInst(GraphVariables.clsGraph graph, int tempNet, ref GraphVariables.clsLoop clsLoop, int workLoop, int curLoop, int curEnIndx, int[] InstantNode, int nInstantNode)
        {
            int temp_nExclusive = clsLoop.Loop[workLoop].Loop[curLoop].nExclusiveInst[curEnIndx];

            int[] temp_exclusiveInst = new int[temp_nExclusive];

            temp_exclusiveInst = clsLoop.Loop[workLoop].Loop[curLoop].exclusiveInst[curEnIndx];

            clsLoop.Loop[workLoop].Loop[curLoop].nExclusiveInst[curEnIndx] = 0;
            clsLoop.Loop[workLoop].Loop[curLoop].exclusiveInst[curEnIndx]  = new int[nInstantNode];

            for (int j = 0; j < nInstantNode; j++)
            {
                int orgInstNode = graph.Network[tempNet].Node[InstantNode[j]].orgNum;
                if (gProAnalyzer.Ultilities.checkGraph.Node_In_Set(clsLoop.Loop[workLoop].Loop[curLoop].exclusiveInst[curEnIndx], clsLoop.Loop[workLoop].Loop[curLoop].nExclusiveInst[curEnIndx], orgInstNode) == false)
                {
                    if (clsLoop.Loop[workLoop].Loop[curLoop].nExclusiveInst[curEnIndx] < 1)
                    {
                        clsLoop.Loop[workLoop].Loop[curLoop].nExclusiveInst[curEnIndx] = 0;
                    }

                    int instIndex = clsLoop.Loop[workLoop].Loop[curLoop].nExclusiveInst[curEnIndx];
                    clsLoop.Loop[workLoop].Loop[curLoop].exclusiveInst[curEnIndx][instIndex] = orgInstNode;
                    instIndex++;
                    clsLoop.Loop[workLoop].Loop[curLoop].nExclusiveInst[curEnIndx] = instIndex;
                }
            }

            int temp_nExclusive_2 = clsLoop.Loop[workLoop].Loop[curLoop].nExclusiveInst[curEnIndx];

            int[] temp_exclusiveInst_2 = new int[temp_nExclusive_2];
            temp_exclusiveInst_2 = clsLoop.Loop[workLoop].Loop[curLoop].exclusiveInst[curEnIndx];

            int[] totalTemp = new int[temp_nExclusive_2 + temp_nExclusive];
            int   nTotal    = 0;

            for (int i = 0; i < temp_nExclusive; i++)
            {
                totalTemp[nTotal] = temp_exclusiveInst[i];
                nTotal++;
            }
            for (int i = 0; i < temp_nExclusive_2; i++)
            {
                if (gProAnalyzer.Ultilities.checkGraph.Node_In_Set(totalTemp, nTotal, temp_exclusiveInst_2[i]) == false)
                {
                    totalTemp[nTotal] = temp_exclusiveInst_2[i];
                    nTotal++;
                }
            }
            //cleaning array
            int[] newArray = new int[nTotal];
            for (int i = 0; i < nTotal; i++)
            {
                newArray[i] = totalTemp[i];
            }

            clsLoop.Loop[workLoop].Loop[curLoop].nExclusiveInst[curEnIndx] = nTotal;
            clsLoop.Loop[workLoop].Loop[curLoop].exclusiveInst[curEnIndx]  = newArray;
            //clsLoop.Loop[workLoop].Loop[curLoop].exclusiveInst[curEnIndx] =
        }
Esempio n. 4
0
 public void find_Path(GraphVariables.clsGraph graph, int fromN, GraphVariables.clsLoop clsLoop, int workLoop, int loop, int fromNode, int toNode,
                       ref bool[] mark, ref int[] X, int header, ref int[] searchNode, ref int nSearchNode)
 {
     //must guarantee no EXIT in PdFlow()
     for (int j = 0; j < graph.Network[fromN].Node[fromNode].nPost; j++)
     {
         int postNode = graph.Network[fromN].Node[fromNode].Post[j];
         if (mark[postNode] == false && gProAnalyzer.Ultilities.checkGraph.Node_In_Loop(clsLoop, workLoop, postNode, loop))
         {
             X[fromNode]    = postNode;
             mark[postNode] = true;
             if (postNode == toNode)
             {
                 //getResult(ref X, header, toNode, ref searchNode, ref nSearchNode);
                 mark[postNode] = false;
             }
             else
             {
                 mark[postNode] = true;
                 find_Path(graph, fromN, clsLoop, workLoop, loop, postNode, toNode, ref mark, ref X, header, ref searchNode, ref nSearchNode);
                 mark[postNode] = false;
             }
         }
     }
 }
Esempio n. 5
0
        //====================================================================================================

        public static void prepare_find_Path(GraphVariables.clsGraph graph, int fromN, ref bool[] mark, bool type)
        {
            for (int i = 0; i < graph.Network[fromN].nNode; i++)
            {
                mark[i] = type;
            }
        }
Esempio n. 6
0
        //recursive update Full node of loop[i] and all its child loop[j,k,l]
        public static int[] GetFullNode(ref GraphVariables.clsGraph graph, int currentN, ref GraphVariables.clsLoop clsLoop, int workLoop, int i, ref int n)
        {
            int depth = clsLoop.Loop[workLoop].maxDepth;
            int loop  = -1;

            //bool check = false;
            int[] tempArr  = new int[graph.Network[currentN].nNode];
            int   nTempArr = 0;

            int[] tmpLoop = new int[graph.Network[currentN].nNode];
            //1 header
            // for each node of this loop => if node is header => find again; else => add to arrNode
            for (int k = 0; k < clsLoop.Loop[workLoop].Loop[i].nNode; k++)
            {
                tmpLoop = new int[graph.Network[currentN].nNode];
                n       = 0;
                if (check_header(ref clsLoop, workLoop, i, k, ref loop))
                {
                    tmpLoop = GetFullNode(ref graph, currentN, ref clsLoop, workLoop, loop, ref n);
                    addArr(tmpLoop, ref tempArr, n, ref nTempArr);
                }
                else
                {
                    tempArr[nTempArr] = clsLoop.Loop[workLoop].Loop[i].Node[k];
                    nTempArr++;
                }
            }

            tempArr[nTempArr] = clsLoop.Loop[workLoop].Loop[i].header;
            nTempArr++;
            clsLoop.Loop[workLoop].Loop[i].nNode = nTempArr;
            clsLoop.Loop[workLoop].Loop[i].Node  = tempArr;
            n = nTempArr;
            return(tempArr);
        }
Esempio n. 7
0
        //fromN = currentN (as referrence)
        private void make_UntanglingSubGraph(ref GraphVariables.clsGraph graph, int fromN, int toN, ref GraphVariables.clsLoop clsLoop, int workLoop, int curLoop,
                                             int[] boundaryNodes, int[] DFlow_IL_Flow, int nNodeDFlow, int[] DFlow, int nDFlow, int orgCID)
        {
            //fill out searchNode of makeSubNetwork (fromN network)
            gProAnalyzer.Ultilities.makeSubNetwork.searchNode  = new int[nDFlow];
            gProAnalyzer.Ultilities.makeSubNetwork.nSearchNode = 0;
            int newSubgraph_Index = -1;

            for (int i = 0; i < nDFlow; i++)
            {
                gProAnalyzer.Ultilities.makeSubNetwork.searchNode[i] = DFlow[i]; //DFlow contain original index of fromN..
                if (DFlow[i] == orgCID)
                {
                    newSubgraph_Index = i;
                }
            }

            //make subNetwork (like SESE)
            gProAnalyzer.Ultilities.makeSubNetwork.make_subNode(ref graph, fromN, toN, false, "", true, "OR"); //only add 1 node to subNetwork
            graph.Network[toN].header = newSubgraph_Index;
            gProAnalyzer.Ultilities.makeSubNetwork.make_subLink(ref graph, fromN, toN, ref clsLoop, workLoop, curLoop, "", false, null, false, null, -1);
            //One more thing. => connect all boundary nodes in DFlow to virtual new "OR" join

            //makeSubLink_Untangling(ref graph, fromN, toN, boundaryNodes, orgCID); //multiple end subgraph is allowed

            for (int i = 0; i < graph.Network[toN].nNode; i++)
            {
                gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, toN, i);
            }

            //============== Do UNTANGLING ===================        (NOW WE HAVE A FULL CLONE SUBGRAPH WITH DFLOW + IL + Boundary nodes => do again everything (include findLoop-reduceLoop)

            int nConcur = clsLoop.Loop[workLoop].Loop[curLoop].nConcurrency;

            int[] Combine_searchNode = new int[graph.Network[toN].nNode * nConcur];
            int   nCombine           = 0;

            //for each concurrency Entry set
            for (int i = 0; i < nConcur; i++)
            {
                //find searchNode by InstanceFlow from CID to cc_Entries (Remember to mark different node for duplication)
                int[] searchNode  = makInstF.get_InstanceFlow(ref graph, toN, clsLoop, workLoop, curLoop, i); //CheckAgain
                int   nSearchNode = searchNode.Length;
                //combine searchNode with current IL nodes (Remember marking different node for duplication)

                //make_subNetwork for current branch
                //insert node into nodeList (makeSubNode())
                //insert links into linkList (Using searchNode to makeSubLink()) - (Remember to adjust the node index - e.g traceable node[i].orgNum)
                //connect to/with virtual boundary nodes => when merging to original => just replace virtual boundary nodes
                //do again with other branch =>
            }

            //====Make subLink of all nodes in Untangling subgraph (Remember duplication of nodes and Link index when duplication)

            //find nodeInfo

            //================================================
        }
Esempio n. 8
0
 public static int get_NodeByName(GraphVariables.clsGraph graph, int currentN, string name)
 {
     for (int i = 0; i < graph.Network[currentN].nNode; i++)
     {
         if (graph.Network[currentN].Node[i].Name == name)
         {
             return(i);
         }
     }
     return(-1);
 }
Esempio n. 9
0
 public static int get_NewNodeIndex(GraphVariables.clsGraph graph, int currentN, int node)
 {
     for (int i = 0; i < graph.Network[currentN].nNode; i++)
     {
         if (graph.Network[currentN].Node[i].orgNum == node)
         {
             return(i);
         }
     }
     return(-1);
 }
Esempio n. 10
0
        public static void removing_disconnectedNode(ref GraphVariables.clsGraph graph, int currentN)
        {
            int[] nodeList = new int[graph.Network[currentN].nNode];
            for (int i = 0; i < nodeList.Length; i++)
            {
                nodeList[i] = i;
            }

            gProAnalyzer.GraphVariables.clsNode.strNode[] imNode = new gProAnalyzer.GraphVariables.clsNode.strNode[graph.Network[currentN].nNode];
            int nImNode = 0;

            for (int i = 0; i < graph.Network[currentN].nNode; i++)
            {
                if (graph.Network[currentN].Node[i].done == false)
                {
                    imNode[nImNode] = graph.Network[currentN].Node[i];

                    if (nImNode != i)
                    {
                        nodeList[i] = nImNode;
                    }

                    nImNode++;
                }
            }

            for (int i = 0; i < nodeList.Length; i++)
            {
                if (nodeList[i] != i)
                {
                    int newIndx  = nodeList[i];
                    int oldIndex = i;
                    for (int j = 0; j < graph.Network[currentN].nLink; j++)
                    {
                        if (graph.Network[currentN].Link[j].fromNode == oldIndex)
                        {
                            graph.Network[currentN].Link[j].fromNode = newIndx;
                        }
                        if (graph.Network[currentN].Link[j].toNode == oldIndex)
                        {
                            graph.Network[currentN].Link[j].toNode = newIndx;
                        }
                    }
                }
            }

            graph.Network[currentN].nNode = nImNode;
            graph.Network[currentN].Node  = new gProAnalyzer.GraphVariables.clsNode.strNode[graph.Network[currentN].nNode];
            for (int i = 0; i < graph.Network[currentN].nNode; i++)
            {
                graph.Network[currentN].Node[i] = imNode[i];
            }
        }
Esempio n. 11
0
 public static void find_Path_CIPd(GraphVariables.clsGraph graph, int currentN, int fromNode, int toNode, ref bool[] mark)
 {
     for (int i = 0; i < graph.Network[currentN].Node[fromNode].nPost; i++)
     {
         int post = graph.Network[currentN].Node[fromNode].Post[i];
         if (post != toNode)
         {
             mark[post] = true;
             find_Path_CIPd(graph, currentN, post, toNode, ref mark);
         }
     }
 }
Esempio n. 12
0
        //#6
        public static bool check_Concurrency(GraphVariables.clsGraph graph, int currentN, int[] InstantNode, int nInstantNode, ref int[][] adjList, int x, int y)
        {
            //not  causal relation
            //not conflict relation
            bool causal_x_y = check_Causal(graph, currentN, InstantNode, nInstantNode, ref adjList, x, y);
            bool causal_y_x = check_Causal(graph, currentN, InstantNode, nInstantNode, ref adjList, y, x);
            bool CanCooccur = check_CanCooccur(InstantNode, nInstantNode, x, y);

            if (!causal_x_y && !causal_y_x && CanCooccur)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 13
0
 public static void ConnectedComponent(GraphVariables.clsGraph graph, int baseNet, int header, ref int[] mark, ref int[,] A, int CCs)
 {
     if (mark[header] == 0)
     {
         mark[header] = CCs;
         for (int i = 0; i < graph.Network[baseNet].nNode; i++)
         {
             if (A[header, i] == 1)
             {
                 ConnectedComponent(graph, baseNet, i, ref mark, ref A, CCs);
             }
         }
     }
 }
Esempio n. 14
0
        public static int edges_in_Node_Set(GraphVariables.clsGraph graph, int currentN, int[] nodeSet, int nNodeSet)
        {
            int countEdges = 0;

            for (int i = 0; i < graph.Network[currentN].nLink; i++)
            {
                int fromNode = graph.Network[currentN].Link[i].fromNode;
                int toNode   = graph.Network[currentN].Link[i].toNode;
                if (Node_In_Set(nodeSet, nNodeSet, fromNode) && Node_In_Set(nodeSet, nNodeSet, toNode))
                {
                    countEdges++;
                }
            }
            return(countEdges);
        }
Esempio n. 15
0
        public static void find_ConnectedComponents(GraphVariables.clsGraph graph, int baseNet, ref int CCs, ref int[] mark)
        {
            CCs      = 0;
            int[,] A = new int[1, 1]; //just place holder
            Ultilities.mappingGraph.to_adjacencyMatrix_Undirected(ref graph, baseNet, ref A, ref graph.Network[baseNet].nNode);

            mark = new int[graph.Network[baseNet].nNode]; //autofill = false;
            for (int i = 0; i < graph.Network[baseNet].nNode; i++)
            {
                if (mark[i] == 0)
                {
                    CCs++;
                    ConnectedComponent(graph, baseNet, i, ref mark, ref A, CCs);
                }
            }
        }
Esempio n. 16
0
        private int Initialize_loopDAG(GraphVariables.clsGraph graph, int currentN, GraphVariables.clsLoop clsLoop, int currentLoop)
        {
            int countDAG = 0;

            for (int i = 0; i < clsLoop.Loop[currentLoop].nLoop; i++)
            {
                if (clsLoop.Loop[currentLoop].Loop[i].nEntry == 1)
                {
                    countDAG += 2;
                }
                else
                {
                    countDAG += 3;
                }
            }
            return(countDAG);
        }
Esempio n. 17
0
        //==============================================================================================================



        //NO
        private void mark_strCombination_OR(GraphVariables.clsGraph graph, int currentN, int[] InstantNode, int nInstantNode, string[] strCombination_OR, int[] parrentTrace)
        {
            for (int i = 0; i < nInstantNode; i++)
            {
                if (strCombination_OR[i] == null)
                {
                    continue;
                }
                int ignore = 0;
                for (int j = 0; j < graph.Network[currentN].Node[InstantNode[i]].nPost; j++)
                {
                    if (strCombination_OR[i].Substring(i, 1) == "0")
                    {
                        continue;
                    }
                    ignore++;
                    if (ignore > 1)
                    {
                        int inst_Index = getIndex(InstantNode, nInstantNode, graph.Network[currentN].Node[InstantNode[i]].Post[j]);
                        if (inst_Index != -1)
                        {
                            strCombination_OR[inst_Index] = "SS";
                        }
                    }
                }
            }

            int nParrentNode = graph.Network[currentN].nNode;

            for (int i = 0; i < nInstantNode; i++)
            {
                if (i == 0)
                {
                    parrentTrace[InstantNode[i]] = -1;
                }
                else
                {
                    if (strCombination_OR[i] != "SS")
                    {
                        parrentTrace[InstantNode[i]] = InstantNode[i - 1];
                    }
                }
            }
        }
Esempio n. 18
0
 //might not use
 private void reduceAllChild(ref GraphVariables.clsGraph graph, int currentN, GraphVariables.clsHWLS clsHWLS, int currBlock, GraphVariables.clsLoop clsLoop, int workLoop,
                             GraphVariables.clsSESE clsSESE, int workSESE, int orgIndex)
 {
     for (int i = 0; i < clsHWLS.FBLOCK.nFBlock; i++)
     {
         if (clsHWLS.FBLOCK.FBlock[i].parentBlock == currBlock)
         {
             if (clsHWLS.FBLOCK.FBlock[i].SESE == true)
             {
                 gProAnalyzer.Ultilities.reduceGraph.reduce_SESE(ref graph, currentN, clsSESE, workSESE, orgIndex);
             }
             if (clsHWLS.FBLOCK.FBlock[i].SESE == false && clsLoop.Loop[workLoop].Loop[orgIndex].nEntry == 1)
             {
                 gProAnalyzer.Ultilities.reduceGraph.reduce_Loop(ref graph, currentN, ref clsLoop, workLoop, orgIndex, "", false);
             }
             //if (clsHWLS.FBLOCK.FBlock[i].SESE == false && clsLoop.Loop[workLoop].Loop[orgIndex].nEntry > 1)
             //reduceG.reduce_IrLoop(ref graph, currentN, clsLoop, workLoop, orgIndex);
         }
     }
 }
Esempio n. 19
0
        public void total_reduceSubgraph(ref GraphVariables.clsGraph graph, int currentN, GraphVariables.clsHWLS clsHWLS, GraphVariables.clsLoop clsLoop, int workLoop,
                                         GraphVariables.clsSESE clsSESE, int workSESE, int stopDepth) //Reduce all the loops inside (NL, IL)
        {
            int curDepth = clsHWLS.FBLOCK.maxDepth;

            if (curDepth == stopDepth)
            {
                return;
            }
            //curDepth = 1;
            do
            {
                for (int i = 0; i < clsHWLS.FBLOCK.nFBlock; i++)
                {
                    if (clsHWLS.FBLOCK.FBlock[i].depth != curDepth)
                    {
                        continue;
                    }
                    int orgIndx = clsHWLS.FBLOCK.FBlock[i].refIndex;

                    //If SESE => Make subnetwork and find Dominator Behavior relation matrix (1 matrix)
                    if (clsHWLS.FBLOCK.FBlock[i].SESE)
                    {
                        reduce_SESE(ref graph, currentN, clsSESE, workSESE, orgIndx);
                    }

                    //If NL => Make subnetwork and find Dom/ Pdom Behavior relation matrix (2 matrices)
                    if (clsHWLS.FBLOCK.FBlock[i].SESE == false && clsLoop.Loop[workLoop].Loop[orgIndx].nEntry == 1)
                    {
                        reduce_Loop(ref graph, currentN, ref clsLoop, workLoop, orgIndx, "", false);
                    }

                    //if IL => Find CIPd => Make subnetwork with CIPd and find Dom/ Pdom Behavior relation matrix (2 matrices)
                    if (clsHWLS.FBLOCK.FBlock[i].SESE == false && clsLoop.Loop[workLoop].Loop[orgIndx].nEntry > 1)
                    {
                        reduce_IrLoop(ref graph, currentN, clsLoop, workLoop, orgIndx);
                    }
                }
                curDepth--;
            } while (curDepth > stopDepth);
        }
Esempio n. 20
0
        public static void start_Indexing_Acyclic(ref GraphVariables.clsGraph graph, ref GraphVariables.clsHWLS clsHWLS, ref GraphVariables.clsHWLS clsHWLS_Untangle,
                                                  ref GraphVariables.clsLoop clsLoop, ref GraphVariables.clsSESE clsSESE, bool[] flag_Check)
        {
            Initialize_All();

            gProAnalyzer.Functionalities.NodeSplittingType1.Run_Split_Type1(ref graph, graph.orgNet, graph.midNet);

            gProAnalyzer.Functionalities.LoopIdentification.Run_FindLoop(ref graph, graph.midNet, ref clsLoop, clsLoop.orgLoop, ref clsLoop.IrreducibleError);

            graph.Network[graph.finalNet] = graph.Network[graph.midNet];
            gProAnalyzer.Functionalities.NodeSplittingType2.Run_Split_Type2(ref graph, graph.midNet, graph.finalNet, ref clsLoop, clsLoop.orgLoop);

            gProAnalyzer.Functionalities.DominanceIdentification.find_Dom(ref graph, graph.finalNet);
            gProAnalyzer.Functionalities.DominanceIdentification.find_Pdom(ref graph, graph.finalNet);
            gProAnalyzer.Functionalities.DominanceIdentification.find_DomEI(ref graph, graph.finalNet, -2);
            gProAnalyzer.Functionalities.DominanceIdentification.find_PdomEI(ref graph, graph.finalNet);

            gProAnalyzer.Functionalities.SESEIdentification.find_SESE_WithLoop(ref graph, graph.finalNet, ref clsLoop, clsLoop.orgLoop, ref clsSESE, clsSESE.finalSESE, -2);
            gProAnalyzer.Functionalities.NodeSplittingType3.Run_Split_Type3(ref graph, graph.finalNet, ref clsLoop, clsLoop.orgLoop, ref clsSESE, clsSESE.finalSESE, true);

            //Make nesting forest
            gProAnalyzer.Ultilities.makeNestingForest.make_NestingForest(ref graph, graph.finalNet, ref clsHWLS, ref clsLoop, clsLoop.orgLoop, ref clsSESE, clsSESE.finalSESE);

            GraphVariables.clsError clsError = new gProAnalyzer.GraphVariables.clsError();

            //Fix each SOS entry for Bond and Rigid
            gProAnalyzer.Functionalities.VerificationG.Initialize_Verification(ref graph, ref clsError, ref clsLoop, ref clsSESE, ref clsHWLS);


            //verify bond first =>>

            int workNet  = graph.finalNet;
            int workLoop = clsLoop.orgLoop;
            int workSESE = clsSESE.finalSESE;

            //== get initial behavior profile ==
            graph.Network[graph.reduceNet] = graph.Network[workNet];
            gProAnalyzer.Ultilities.extendGraph.full_extentNetwork(ref graph, graph.reduceNet, 0, 0);
            get_InitialBehaviorProfile(ref graph, graph.reduceNet, ref clsHWLS, ref clsLoop, workLoop, ref clsSESE, workSESE, flag_Check);
            //Database storing
        }
Esempio n. 21
0
 public static int find_newLoopIndex(GraphVariables.clsGraph graph, int currentN, GraphVariables.clsLoop clsLoop, int old_workLoop, int new_workLoop, int loopIndx)
 {
     for (int i = 0; i < clsLoop.Loop[new_workLoop].nLoop; i++)
     {
         if (clsLoop.Loop[new_workLoop].Loop[i].nEntry == clsLoop.Loop[old_workLoop].Loop[loopIndx].nEntry)
         {
             int countE = 0;
             for (int j = 0; j < clsLoop.Loop[new_workLoop].Loop[i].nEntry; j++)
             {
                 if (graph.Network[currentN].Node[clsLoop.Loop[new_workLoop].Loop[i].Entry[j]].orgNum == clsLoop.Loop[old_workLoop].Loop[loopIndx].Entry[j])
                 {
                     countE++;
                 }
                 if (countE == clsLoop.Loop[new_workLoop].Loop[i].nEntry)
                 {
                     return(i);
                 }
             }
             countE = 0;
         }
     }
     return(-1);
 }
Esempio n. 22
0
        //make an empty space of CID+IL for Untangling the IL latter.
        public static void remove_DFlow_IL(ref GraphVariables.clsGraph graph, int tempNet, ref GraphVariables.clsLoop clsLoop, int workLoop, int curLoop,
                                           int[] boundaryNodes, int CID, int[] DFlow_IL_Flow, int nNodeDFlow)
        {
            GraphVariables.clsEdge.strEdge[] imLink = new GraphVariables.clsEdge.strEdge[graph.Network[tempNet].nLink];
            int nImLink = 0;

            //remove the links of  boundary nodes except CID
            for (int i = 0; i < graph.Network[tempNet].nLink; i++)
            {
                int fromNode = graph.Network[tempNet].Link[i].fromNode;
                int toNode   = graph.Network[tempNet].Link[i].toNode;
                if (!(gProAnalyzer.Ultilities.checkGraph.Node_In_Set(DFlow_IL_Flow, nNodeDFlow, fromNode) == true && gProAnalyzer.Ultilities.checkGraph.Node_In_Set(DFlow_IL_Flow, nNodeDFlow, toNode) == true))
                {
                    imLink[nImLink] = graph.Network[tempNet].Link[i];
                    nImLink++;
                }
            }
            //mark DONE for removed nodes
            for (int i = 0; i < graph.Network[tempNet].nNode; i++)
            {
                if (gProAnalyzer.Ultilities.checkGraph.Node_In_Set(DFlow_IL_Flow, nNodeDFlow, i) && gProAnalyzer.Ultilities.checkGraph.Node_In_Set(boundaryNodes, boundaryNodes.Length, i) == false && graph.Network[tempNet].Node[i].orgNum != CID)
                {
                    graph.Network[tempNet].Node[i].done = true; //need i?
                }
            }
            graph.Network[tempNet].nLink = nImLink;
            graph.Network[tempNet].Link  = new GraphVariables.clsEdge.strEdge[nImLink];
            for (int i = 0; i < graph.Network[tempNet].nLink; i++)
            {
                graph.Network[tempNet].Link[i] = imLink[i];
            }
            //update pre/post of each nodes
            for (int i = 0; i < graph.Network[tempNet].nNode; i++)
            {
                gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, tempNet, i);
            }
        }
Esempio n. 23
0
        public static string Bond_Check(ref GraphVariables.clsGraph graph, int currentN, ref GraphVariables.clsSESE clsSESE, int workSESE, int currentSESE, ref GraphVariables.clsHWLS clsHWLS) //should upgrade bond check ===
        {
            int count_gateway = 0;
            //check SESE nested with Loops (2 cases) (if SESE have at least 1 directly child is loop => rigid.
            int f_index = getFblockIndex(currentSESE, clsHWLS);

            for (int i = 0; i < clsHWLS.FBLOCK.FBlock[f_index].nChild; i++)
            {
                int child = clsHWLS.FBLOCK.FBlock[f_index].child[i];
                if (clsHWLS.FBLOCK.FBlock[child].SESE == false && !(clsHWLS.FBLOCK.FBlock[child].nEntry == 1 && clsHWLS.FBLOCK.FBlock[child].nExit == 1))
                {
                    return("R");
                }
            }

            for (int i = 0; i < clsSESE.SESE[workSESE].SESE[currentSESE].nNode; i++)
            {
                int node = clsSESE.SESE[workSESE].SESE[currentSESE].Node[i];
                if (Node_In_SESE(clsSESE, workSESE, node, currentSESE))
                {
                    if (graph.Network[currentN].Node[node].nPre > 1 || graph.Network[currentN].Node[node].nPost > 1)
                    {
                        count_gateway++;
                        if (count_gateway > 2)
                        {
                            return("R");
                        }
                    }
                }
            }
            if (count_gateway == 0)
            {
                return("P");
            }

            return("B");
        }
Esempio n. 24
0
        public void build_loopDAG(ref GraphVariables.clsGraph graph, int currentN, ref GraphVariables.clsLoop clsLoop, int currentLoop,
                                  ref GraphVariables.clsSESE clsSESE, ref GraphVariables.clsLoopDAG clsLoopDAG, int currentLoopDAG)
        {
            int init_n = Initialize_loopDAG(graph, currentN, clsLoop, currentLoop);

            clsLoopDAG.loopDAG[currentLoopDAG].loopDAG  = new GraphVariables.clsLoopDAG.strLoopDAGInfo[init_n];
            clsLoopDAG.loopDAG[currentLoopDAG].nLoopDAG = 0;

            //clsLoopDAG.loopDAG[currentLoopDAG].loopDAG[1].DAG.header;

            //int count_loopDAG = 0;

            for (int i = 0; i < clsLoop.Loop[currentLoop].nLoop; i++)
            {
                gProAnalyzer.GraphVariables.clsLoop.strLoopInform loop = clsLoop.Loop[currentLoop].Loop[i];
                if (loop.nEntry == 1) //NL
                {
                    gProAnalyzer.Ultilities.makeSubNetwork.make_subNetwork(ref graph, currentN, graph.acyclicNet, ref clsLoop, currentLoop, i, ref clsSESE, "FF", -1);
                }
                else //IL
                {
                }
            }
        }
Esempio n. 25
0
        public static void make_NestingForest(ref GraphVariables.clsGraph graph, int currentN, ref GraphVariables.clsHWLS clsHWLS, ref GraphVariables.clsLoop clsLoop,
                                              int workLoop, ref GraphVariables.clsSESE clsSESE, int workSESE)
        {
            int bIndex = 0;

            //FBLOCK.FBlock = new strFBlock[SESE[currentSESE].nSESE + Loop[currentLoop].nLoop];
            if (workSESE >= 0 && workLoop >= 0)
            {
                clsHWLS.FBLOCK.FBlock = new GraphVariables.clsHWLS.strFBlock[clsSESE.SESE[workSESE].nSESE + clsLoop.Loop[workLoop].nLoop];
            }
            else
            {
                if (workSESE >= 0)
                {
                    clsHWLS.FBLOCK.FBlock = new GraphVariables.clsHWLS.strFBlock[clsSESE.SESE[workSESE].nSESE];
                }
                else
                {
                    clsHWLS.FBLOCK.FBlock = new GraphVariables.clsHWLS.strFBlock[clsLoop.Loop[workLoop].nLoop];
                }
            }

            //Copy SESE
            if (workSESE >= 0 && clsSESE.SESE[workSESE].nSESE > 0)
            {
                //copy SESE and LOOP to FBlock;
                for (int i = 0; i < clsSESE.SESE[workSESE].nSESE; i++)
                {
                    //copy SESE to FBlock
                    //FBlock[bIndex].child = SESE[currentSESE].SESE[i].child;
                    //FBlock[bIndex].depth = SESE[currentSESE].SESE[i].depth;
                    clsHWLS.FBLOCK.FBlock[bIndex].Entry    = new int[1];
                    clsHWLS.FBLOCK.FBlock[bIndex].Entry[0] = clsSESE.SESE[workSESE].SESE[i].Entry;
                    clsHWLS.FBLOCK.FBlock[bIndex].Exit     = new int[1];
                    clsHWLS.FBLOCK.FBlock[bIndex].Exit[0]  = clsSESE.SESE[workSESE].SESE[i].Exit;
                    clsHWLS.FBLOCK.FBlock[bIndex].nEntry   = 1;
                    clsHWLS.FBLOCK.FBlock[bIndex].nExit    = 1;
                    clsHWLS.FBLOCK.FBlock[bIndex].Node     = clsSESE.SESE[workSESE].SESE[i].Node;
                    clsHWLS.FBLOCK.FBlock[bIndex].nNode    = clsSESE.SESE[workSESE].SESE[i].nNode;
                    //FBlock[bIndex].parentBlock ??
                    clsHWLS.FBLOCK.FBlock[bIndex].SESE     = true;
                    clsHWLS.FBLOCK.FBlock[bIndex].refIndex = i;
                    bIndex++;
                }
            }

            //Copy Loop
            if (workLoop >= 0 && clsLoop.Loop[workLoop].nLoop > 0)
            {
                copy_Loop(ref clsLoop, workLoop, clsLoop.newTempLoop);
                //modify tempLoop => expand the node
                for (int i = 0; i < clsLoop.Loop[clsLoop.newTempLoop].nLoop; i++)
                {
                    if (clsLoop.Loop[clsLoop.newTempLoop].Loop[i].parentLoop != -1)
                    {
                        continue;                                                             //only start with the outter loop //Log: Otc28_2020
                    }
                    //MAKE A SLIGHT CHANGE HERE ======================================
                    //if (clsLoop.Loop[clsLoop.newTempLoop].Loop[i].depth != 1) continue;
                    int   n    = 0;
                    int[] temp = GetFullNode(ref graph, currentN, ref clsLoop, clsLoop.newTempLoop, i, ref n); //get full node of Loop (newTempLoop) update this loop and all child (including header)
                    //remove redundancy in Loop[i].Node[];
                    //temp = removeRedundancyNode(temp);
                }
                //copy Loop to FBlock
                for (int i = 0; i < clsLoop.Loop[clsLoop.newTempLoop].nLoop; i++)
                {
                    //FBlock[bIndex].child = ??
                    //FBlock[bIndex].depth = ??
                    clsHWLS.FBLOCK.FBlock[bIndex].Entry  = clsLoop.Loop[clsLoop.newTempLoop].Loop[i].Entry;
                    clsHWLS.FBLOCK.FBlock[bIndex].Exit   = clsLoop.Loop[clsLoop.newTempLoop].Loop[i].Exit;
                    clsHWLS.FBLOCK.FBlock[bIndex].nEntry = clsLoop.Loop[clsLoop.newTempLoop].Loop[i].nEntry;
                    clsHWLS.FBLOCK.FBlock[bIndex].nExit  = clsLoop.Loop[clsLoop.newTempLoop].Loop[i].nExit;
                    clsHWLS.FBLOCK.FBlock[bIndex].Node   = clsLoop.Loop[clsLoop.newTempLoop].Loop[i].Node;
                    clsHWLS.FBLOCK.FBlock[bIndex].nNode  = clsLoop.Loop[clsLoop.newTempLoop].Loop[i].nNode;
                    //FBlock[bIndex].parentBlock = ??
                    clsHWLS.FBLOCK.FBlock[bIndex].SESE     = false;
                    clsHWLS.FBLOCK.FBlock[bIndex].refIndex = i;
                    bIndex++;
                }
            }

            clsHWLS.FBLOCK.nFBlock = bIndex;

            //remove same block
            check_Block_Same(ref clsHWLS);
            //Find parent block
            for (int i = 0; i < clsHWLS.FBLOCK.nFBlock; i++)
            {
                int j = find_nearestParentBlock(ref clsHWLS, i);
                clsHWLS.FBLOCK.FBlock[i].parentBlock = j;
            }
            //find Children
            for (int i = 0; i < clsHWLS.FBLOCK.nFBlock; i++)
            {
                int[] child_of_i = new int[clsHWLS.FBLOCK.nFBlock];
                int   nChild     = 0;
                for (int j = 0; j < clsHWLS.FBLOCK.nFBlock; j++)
                {
                    if (clsHWLS.FBLOCK.FBlock[j].parentBlock == i)
                    {
                        child_of_i[nChild] = j;
                        nChild++;
                    }
                }
                clsHWLS.FBLOCK.FBlock[i].child  = child_of_i;
                clsHWLS.FBLOCK.FBlock[i].nChild = nChild;
            }
            //find Depth
            clsHWLS.FBLOCK.maxDepth = 0;
            //int maxDepth = 0;
            int curDepth = 0;

            for (int i = 0; i < clsHWLS.FBLOCK.nFBlock; i++)
            {
                curDepth = 1;
                //FBLOCK.maxDepth = 1;
                if (clsHWLS.FBLOCK.FBlock[i].parentBlock != -1)
                {
                    continue;
                }
                clsHWLS.FBLOCK.FBlock[i].depth = curDepth;
                find_BlockDepth(ref clsHWLS, i, ref curDepth);
            }
            if (clsHWLS.FBLOCK.nFBlock > 0 && clsHWLS.FBLOCK.maxDepth == 0)
            {
                clsHWLS.FBLOCK.maxDepth = 1;
            }
        }
Esempio n. 26
0
        public static int[] getBoundaryNode(GraphVariables.clsGraph graph, int finalNet, int subNet, GraphVariables.clsLoop clsLoop, int workLoop, int curLoop,
                                            ref int[] tempSet, ref int nTempSet, ref int[] DFlow, ref int nDFlow, bool CheckCombineLoops)
        {
            DFlow    = new int[graph.Network[finalNet].nNode];
            nDFlow   = 0;
            tempSet  = new int[graph.Network[finalNet].nNode];
            nTempSet = 0;
            int[] listCID_Loop = new int[clsLoop.Loop[workLoop].nLoop]; //index of reduced loops
            int   nList        = 0;

            for (int i = 0; i < graph.Network[subNet].nNode; i++)
            {
                if (graph.Network[subNet].Node[i].orgNum != -1)
                {
                    tempSet[nTempSet] = graph.Network[subNet].Node[i].orgNum;
                    nTempSet++;
                    DFlow[nDFlow] = graph.Network[subNet].Node[i].orgNum;
                    nDFlow++;
                    if (graph.Network[subNet].Node[i].header == true)
                    {
                        listCID_Loop[nList] = graph.Network[subNet].Node[i].headerOfLoop;
                        nList++;
                    }
                }
            }

            if (CheckCombineLoops)
            {
                //combine tempSet + Loops (Expanded from reduced before)
                for (int i = 0; i < nList; i++)
                {
                    for (int j = 0; j < clsLoop.Loop[workLoop].Loop[listCID_Loop[i]].nNode; j++)
                    {
                        if (gProAnalyzer.Ultilities.checkGraph.Node_In_Set(tempSet, nTempSet, clsLoop.Loop[workLoop].Loop[listCID_Loop[i]].Node[j]) == true)
                        {
                            continue;
                        }
                        tempSet[nTempSet] = clsLoop.Loop[workLoop].Loop[listCID_Loop[i]].Node[j];
                        nTempSet++;
                        DFlow[nDFlow] = clsLoop.Loop[workLoop].Loop[listCID_Loop[i]].Node[j];
                        nDFlow++;
                    }
                }
            }

            //combine tempSet + current IL
            if (gProAnalyzer.Ultilities.checkGraph.Node_In_Set(tempSet, nTempSet, clsLoop.Loop[workLoop].Loop[curLoop].header) == false)
            {
                tempSet[nTempSet] = clsLoop.Loop[workLoop].Loop[curLoop].header;
                nTempSet++;
            }
            for (int i = 0; i < clsLoop.Loop[workLoop].Loop[curLoop].nNode; i++)
            {
                if (gProAnalyzer.Ultilities.checkGraph.Node_In_Set(tempSet, nTempSet, clsLoop.Loop[workLoop].Loop[curLoop].Node[i]) == false)
                {
                    tempSet[nTempSet] = clsLoop.Loop[workLoop].Loop[curLoop].Node[i];
                    nTempSet++;
                }
            }

            int[] boundarySet = new int[nTempSet];
            int   nBoundary   = 0;

            for (int i = 0; i < nTempSet; i++)
            {
                int node = tempSet[i];
                for (int j = 0; j < graph.Network[finalNet].nLink; j++)
                {
                    if (graph.Network[finalNet].Link[j].fromNode == node) //boundary nodes is always split-node
                    {
                        if (gProAnalyzer.Ultilities.checkGraph.Node_In_Set(tempSet, nTempSet, graph.Network[finalNet].Link[j].toNode) == false)
                        {
                            boundarySet[nBoundary] = node;
                            nBoundary++;
                        }
                    }
                }
            }

            int[] returnSet = new int[nBoundary];
            for (int i = 0; i < nBoundary; i++)
            {
                returnSet[i] = boundarySet[i];
            }
            return(returnSet);
        }
Esempio n. 27
0
        //Get concurrency combination of IL<entries> from their CID (Output => SubNet)
        public static void check_Concurrency(ref GraphVariables.clsGraph graph, int currentN, int conNet, int subNet, GraphVariables.clsLoop clsLoop, int workLoop, int loop, ref GraphVariables.clsSESE clsSESE)
        {
            Initialize_All();

            //make_ConcurrencyFlow
            graph.Network[conNet] = graph.Network[currentN]; //CIDFlow begining is stored in conNet (Network[8])
            gProAnalyzer.Ultilities.extendGraph.full_extentNetwork(ref graph, conNet, 0, 0);

            gProAnalyzer.Ultilities.copyLoop.copy_Loop(ref clsLoop, workLoop, clsLoop.tempLoop);

            //reduce all loop except "loop" and its parents. (Applied NEW TYPE OF IL REDUCTION) ==>> REDUCE SAME DEPTH??? => ITS OK!!
            gProAnalyzer.Ultilities.reduceGraph.Preprocessing_total_reduceSubgraph(ref graph, conNet, clsLoop, workLoop, loop);

            //make DFlow() + CID in this procedure.
            gProAnalyzer.Ultilities.makeSubNetwork.make_subNetwork(ref graph, conNet, subNet, ref clsLoop, clsLoop.tempLoop, loop, ref clsSESE, "CC", -1); //find concurrency set
            //============ (by pass) using "CC" subgraph to find other parameter (just lazy) ==============
            DFlow_IL_Flow        = null;
            nNodeDFlow_IL        = 0;
            expand_DFlow_IL_Flow = null; //combine DFlow+IL and expand nested loops (if any)
            expand_nNodeDFlow_IL = 0;

            DFlow         = null;
            nDFlow        = 0;
            expand_DFlow  = null;
            expand_nDFlow = 0;

            orgCID = getCID_IL(graph, conNet, clsLoop, workLoop, loop); //CID of original graph index (All entries)

            expand_boundaryNodes = getBoundaryNode(graph, conNet, subNet, clsLoop, workLoop, loop, ref expand_DFlow_IL_Flow, ref expand_nNodeDFlow_IL, ref expand_DFlow, ref expand_nDFlow, true);
            boundaryNodes        = getBoundaryNode(graph, conNet, subNet, clsLoop, workLoop, loop, ref DFlow_IL_Flow, ref nNodeDFlow_IL, ref DFlow, ref nDFlow, false);
            //==============================================================================================

            gProAnalyzer.Ultilities.makeSubNetwork.make_subGraph_DFlow(ref graph, conNet, subNet, ref clsLoop, clsLoop.tempLoop, loop, DFlow, nDFlow, boundaryNodes, orgCID); //subgraph contains DFlow + boundaryNode

            //========>>>>> NEED FIX THE CONCURRENT ENTRY SET IDENTIFICATION => Recording all set, not optimize anything
            make_ConcurrencyInstance(graph, subNet, ref clsLoop, clsLoop.tempLoop, loop); //find concurrency entry sets using DFlow() => store in clsLoop.
            //========>>>>> MUST FIX <<<<<============

            //some ERRORS here, check it for QUERY paper (Next paper)
            make_ConcurrencyInstance_Untangling(ref graph, subNet, ref clsLoop, clsLoop.tempLoop, loop); //find the instanceNode to each concurrencySet => store in clsLoop also

            //copy concurrency inform =============== THIS IS FOR THE VERIFICATION PAPER ONLY
            clsLoop.Loop[workLoop].Loop[loop].nConcurrency = clsLoop.Loop[clsLoop.tempLoop].Loop[loop].nConcurrency; //tranfer all the concurrency value from tempLoop [3] to workloop [2]
            if (clsLoop.Loop[clsLoop.tempLoop].Loop[loop].Concurrency != null)
            {
                clsLoop.Loop[workLoop].Loop[loop].Concurrency = new int[clsLoop.Loop[workLoop].Loop[loop].nEntry];
                for (int k = 0; k < clsLoop.Loop[workLoop].Loop[loop].nEntry; k++)
                {
                    clsLoop.Loop[workLoop].Loop[loop].Concurrency[k] = clsLoop.Loop[clsLoop.tempLoop].Loop[loop].Concurrency[k];
                }
            }

            //copy InstanceNode_DFlow to workLoop - Concurrent Entry
            clsLoop.Loop[workLoop].Loop[loop].nConcurrInst = new int[clsLoop.Loop[clsLoop.tempLoop].Loop[loop].nConcurrInst.Length]; //tranfer all the concurrency value from tempLoop [3] to workloop [2]
            for (int i = 0; i < clsLoop.Loop[workLoop].Loop[loop].nConcurrInst.Length; i++)
            {
                clsLoop.Loop[workLoop].Loop[loop].nConcurrInst[i] = clsLoop.Loop[clsLoop.tempLoop].Loop[loop].nConcurrInst[i];
            }

            if (clsLoop.Loop[clsLoop.tempLoop].Loop[loop].concurrInst != null)
            {
                clsLoop.Loop[workLoop].Loop[loop].concurrInst = new int[clsLoop.Loop[workLoop].Loop[loop].nConcurrInst.Length][];
                for (int k = 0; k < clsLoop.Loop[workLoop].Loop[loop].nConcurrInst.Length; k++)
                {
                    if (clsLoop.Loop[clsLoop.tempLoop].Loop[loop].concurrInst[k] == null)
                    {
                        continue;
                    }
                    clsLoop.Loop[workLoop].Loop[loop].concurrInst[k] = new int[clsLoop.Loop[clsLoop.tempLoop].Loop[loop].concurrInst[k].Length];
                    for (int l = 0; l < clsLoop.Loop[workLoop].Loop[loop].nConcurrInst[k]; l++)
                    {
                        clsLoop.Loop[workLoop].Loop[loop].concurrInst[k][l] = clsLoop.Loop[clsLoop.tempLoop].Loop[loop].concurrInst[k][l];
                    }
                }
            }

            //copy InstanceNode_DFlow to workLoop - Exclusive entries
            clsLoop.Loop[workLoop].Loop[loop].nExclusiveInst = new int[clsLoop.Loop[clsLoop.tempLoop].Loop[loop].nExclusiveInst.Length]; //tranfer all the concurrency value from tempLoop [3] to workloop [2]
            for (int i = 0; i < clsLoop.Loop[workLoop].Loop[loop].nExclusiveInst.Length; i++)
            {
                clsLoop.Loop[workLoop].Loop[loop].nExclusiveInst[i] = clsLoop.Loop[clsLoop.tempLoop].Loop[loop].nExclusiveInst[i];
            }

            if (clsLoop.Loop[clsLoop.tempLoop].Loop[loop].exclusiveInst != null)
            {
                clsLoop.Loop[workLoop].Loop[loop].exclusiveInst = new int[clsLoop.Loop[workLoop].Loop[loop].nExclusiveInst.Length][];
                for (int k = 0; k < clsLoop.Loop[workLoop].Loop[loop].nExclusiveInst.Length; k++)
                {
                    if (clsLoop.Loop[clsLoop.tempLoop].Loop[loop].exclusiveInst[k] == null)
                    {
                        continue;
                    }
                    clsLoop.Loop[workLoop].Loop[loop].exclusiveInst[k] = new int[clsLoop.Loop[clsLoop.tempLoop].Loop[loop].exclusiveInst[k].Length];
                    for (int l = 0; l < clsLoop.Loop[workLoop].Loop[loop].nExclusiveInst[k]; l++)
                    {
                        clsLoop.Loop[workLoop].Loop[loop].exclusiveInst[k][l] = clsLoop.Loop[clsLoop.tempLoop].Loop[loop].exclusiveInst[k][l];
                    }
                }
            }
            //output is the model in Network.SUBNET
            //output: Get Concurrency[] and ConcurrencyInst of DFlow().
        }
Esempio n. 28
0
        public static void make_ConcurrencyInstance_Untangling(ref GraphVariables.clsGraph graph, int tempNet, ref GraphVariables.clsLoop clsLoop, int workLoop, int loop)
        {
            //set the initiated value for SearchXOR, nSearch, nCurrentXOR
            int[] SearchXOR   = new int[graph.Network[tempNet].nNode]; // 0-탐색 //navigation??
            int   nSearchXOR  = 0;
            int   nCurrentXOR = 0;

            clsLoop.Loop[workLoop].Loop[loop].nConcurrInst = new int[clsLoop.Loop[workLoop].Loop[loop].nConcurrency + 1]; //+1 for compatable of concurrencyIndex (loop)
            clsLoop.Loop[workLoop].Loop[loop].concurrInst  = new int[clsLoop.Loop[workLoop].Loop[loop].nConcurrency + 1][];

            clsLoop.Loop[workLoop].Loop[loop].nExclusiveInst = new int[clsLoop.Loop[workLoop].Loop[loop].nEntry];
            clsLoop.Loop[workLoop].Loop[loop].exclusiveInst  = new int[clsLoop.Loop[workLoop].Loop[loop].nEntry][];

            do
            {
                nCurrentXOR = 0;
                for (int j = 0; j < graph.Network[tempNet].nLink; j++)
                {
                    graph.Network[tempNet].Link[j].bInstance = false;
                }

                int[]    InstantNode       = new int[graph.Network[tempNet].nNode];
                int      nInstantNode      = 0;
                string[] strCombination_OR = new string[graph.Network[tempNet].nNode];
                int      sNode             = graph.Network[tempNet].header;
                InstantNode[nInstantNode] = sNode;
                nInstantNode++;

                //Instant Flow
                //SearchXOR[] will be use in here //instanceNode() => will find the path of each instance flow (i.g. 1->4->5->8)
                if (gProAnalyzer.Ultilities.makeInstanceFlow.find_InstanceNode(ref graph, tempNet, sNode, ref InstantNode, ref nInstantNode, ref SearchXOR, ref nSearchXOR, ref nCurrentXOR, ref strCombination_OR))
                {
                    string[] readable = new string[nInstantNode];
                    readable = convert_Readable(ref graph, tempNet, InstantNode, nInstantNode);

                    for (int k = 0; k <= clsLoop.Loop[workLoop].Loop[loop].nConcurrency; k++)
                    {
                        int countE    = 0;
                        int countInst = 0;
                        for (int m = 0; m < clsLoop.Loop[workLoop].Loop[loop].nEntry; m++)
                        {
                            if (clsLoop.Loop[workLoop].Loop[loop].Concurrency[m] != k)
                            {
                                continue;
                            }
                            countE++;
                            int curEntry = get_NewNodeIndex(graph, tempNet, clsLoop.Loop[workLoop].Loop[loop].Entry[m]);
                            if (gProAnalyzer.Ultilities.checkGraph.Node_In_Set(InstantNode, nInstantNode, curEntry) == true)
                            {
                                countInst++;
                                if (k == 0)
                                {
                                    add_to_exclusiveInst(graph, tempNet, ref clsLoop, workLoop, loop, m, InstantNode, nInstantNode);
                                }
                            }
                        }
                        if (countE == countInst)
                        {
                            //store InstanceNode
                            //set Union of all instance node
                            add_to_concurrInst(graph, tempNet, ref clsLoop, workLoop, loop, k, InstantNode, nInstantNode);
                        }
                        if (true)
                        {
                        }
                    }
                }
            } while (nSearchXOR > 0);
        }
Esempio n. 29
0
        public static void make_ConcurrencyInstance(GraphVariables.clsGraph graph, int currentN, ref GraphVariables.clsLoop clsLoop, int workLoop, int loop) //Must check here !!!!!!!!!!!!
        {
            //INPUT: A acyclic graph with single start
            //OUTPUT: Mark into CONCURRENCY field of the clsLoop.Loop[workLoop].Loop[loop];

            int conNum = 0;

            int[][] conEntry = new int[clsLoop.Loop[workLoop].Loop[loop].nEntry][];
            for (int i = 0; i < clsLoop.Loop[workLoop].Loop[loop].nEntry; i++)
            {
                conEntry[i] = new int[clsLoop.Loop[workLoop].Loop[loop].nEntry];
            }

            //set the initiated value for SearchXOR, nSearch, nCurrentXOR
            int[] SearchXOR   = new int[graph.Network[currentN].nNode]; // 0-탐색 //navigation??
            int   nSearchXOR  = 0;
            int   nCurrentXOR = 0;

            do
            {
                nCurrentXOR = 0;
                for (int j = 0; j < graph.Network[currentN].nLink; j++)
                {
                    graph.Network[currentN].Link[j].bInstance = false;
                }

                int[]    InstantNode       = new int[graph.Network[currentN].nNode];
                int      nInstantNode      = 0;
                string[] strCombination_OR = new string[graph.Network[currentN].nNode];
                int      sNode             = graph.Network[currentN].header;
                InstantNode[nInstantNode] = sNode;
                nInstantNode++;

                //Instant Flow 찾으면
                //SearchXOR[] will be use in here //instanceNode() => will find the path of each instance flow (i.g. 1->4->5->8)
                if (gProAnalyzer.Ultilities.makeInstanceFlow.find_InstanceNode(ref graph, currentN, sNode, ref InstantNode, ref nInstantNode, ref SearchXOR, ref nSearchXOR, ref nCurrentXOR, ref strCombination_OR))
                {
                    //find
                    int[] imEntry = new int[clsLoop.Loop[workLoop].Loop[loop].nEntry];
                    bool  isError = true;
                    for (int i = 0; i < nInstantNode; i++)
                    {
                        for (int j = 0; j < clsLoop.Loop[workLoop].Loop[loop].nEntry; j++)
                        {
                            if (graph.Network[currentN].Node[InstantNode[i]].orgNum == clsLoop.Loop[workLoop].Loop[loop].Entry[j])
                            {
                                imEntry[j] = 1; //import entry cua node thu j (ko phai node j) = 1 sau nay no co the = 2 3 4 ...
                                isError    = false;
                                break;
                            }
                        }
                    }
                    if (!isError)
                    {
                        //Same Check
                        int    sameCon = 0; //sameConcurrent??
                        bool[] kCon    = new bool[conNum];
                        for (int k = 0; k < conNum; k++)
                        {
                            for (int j = 0; j < clsLoop.Loop[workLoop].Loop[loop].nEntry; j++)
                            {
                                if (imEntry[j] == 1 && conEntry[k][j] == 1)
                                {
                                    sameCon++;
                                    kCon[k] = true;
                                    break;
                                }
                            }
                        }
                        if (sameCon == 0)
                        {
                            conEntry[conNum] = imEntry;
                            conNum++;
                        }
                        else
                        {
                            int     conNum_T   = conNum;
                            int[][] conEntry_T = new int[conNum][];
                            for (int k = 0; k < conNum_T; k++)
                            {
                                conEntry_T[k] = new int[clsLoop.Loop[workLoop].Loop[loop].nEntry];
                                for (int j = 0; j < clsLoop.Loop[workLoop].Loop[loop].nEntry; j++)
                                {
                                    conEntry_T[k][j] = conEntry[k][j];
                                }
                            }
                            conNum = 0;
                            for (int k = 0; k < conNum_T; k++)
                            {
                                if (kCon[k])
                                {
                                    continue;
                                }
                                for (int j = 0; j < clsLoop.Loop[workLoop].Loop[loop].nEntry; j++)
                                {
                                    conEntry[conNum][j] = conEntry[k][j];
                                }
                                conNum++;
                            }
                            for (int j = 0; j < clsLoop.Loop[workLoop].Loop[loop].nEntry; j++)
                            {
                                conEntry[conNum][j] = 0;
                                if (imEntry[j] == 1)
                                {
                                    conEntry[conNum][j] = 1;
                                }
                                for (int k = 0; k < conNum_T; k++)
                                {
                                    if (!kCon[k])
                                    {
                                        continue;
                                    }
                                    if (conEntry_T[k][j] == 1)
                                    {
                                        conEntry[conNum][j] = 1;
                                    }
                                }
                            }
                            conNum++;
                        }
                    }
                } // if error
            } while (nSearchXOR > 0);

            //here => what I need to know //number of Concurrency = number of Loop Entry
            clsLoop.Loop[workLoop].Loop[loop].Concurrency = new int[clsLoop.Loop[workLoop].Loop[loop].nEntry];

            int numType = 1;

            for (int k = 0; k < conNum; k++)
            {
                int cntTrue = 0;
                for (int j = 0; j < clsLoop.Loop[workLoop].Loop[loop].nEntry; j++)
                {
                    if (conEntry[k][j] == 1)
                    {
                        cntTrue++;
                    }
                }
                if (cntTrue > 1)
                {
                    for (int j = 0; j < clsLoop.Loop[workLoop].Loop[loop].nEntry; j++)
                    {
                        if (conEntry[k][j] == 1)
                        {
                            clsLoop.Loop[workLoop].Loop[loop].Concurrency[j] = numType;
                        }
                    }
                    numType++;
                }
            }
            clsLoop.Loop[workLoop].Loop[loop].nConcurrency = numType - 1;
        }
Esempio n. 30
0
        public int[] get_InstanceFlow(ref GraphVariables.clsGraph graph, int currentN, GraphVariables.clsLoop clsLoop, int workLoop, int curLoop, int concurEn)
        {
            SearchXOR   = new int[graph.Network[currentN].nNode]; // 0-탐색
            nSearchXOR  = 0;
            nCurrentXOR = 0;
            nInst       = 0;

            int[] searchNode  = new int[graph.Network[currentN].nNode];
            int   nSearchNode = 0;

            do
            {
                nCurrentXOR = 0;
                for (int j = 0; j < graph.Network[currentN].nLink; j++) //fill all this subnetwork is un-visit
                {
                    graph.Network[currentN].Link[j].bInstance = false;  //bInstance is used for mark the node which have token (instance flow)
                }

                int[]    InstantNode       = new int[graph.Network[currentN].nNode];
                int      nInstantNode      = 0;
                string[] strCombination_OR = new string[graph.Network[currentN].nNode]; //for indexing the current propagation of OR split e.g., which successors are activated.
                //int nOR_SplitIndex = 0;

                int sNode = graph.Network[currentN].header;
                InstantNode[nInstantNode] = sNode;
                nInstantNode++;

                if (find_InstanceNode(ref graph, currentN, sNode, ref InstantNode, ref nInstantNode, ref SearchXOR, ref nSearchXOR, ref nCurrentXOR, ref strCombination_OR)) //find_InstanceNode() => output will be stored in InstantNode[] (Global variable!) - all the node which is activated in currentN.
                {
                    string[] readable = new string[nInstantNode];
                    nInst++;
                }

                //check whether current InstanceNode contains concurrentEntries or not
                int countE    = 0;
                int countInst = 0;
                for (int i = 0; i < clsLoop.Loop[workLoop].Loop[curLoop].nConcurrency; i++)
                {
                    if (clsLoop.Loop[workLoop].Loop[curLoop].Concurrency[i] == concurEn)
                    {
                        countE++;
                        for (int j = 0; j < nInstantNode; j++)
                        {
                            if (graph.Network[currentN].Node[InstantNode[j]].orgNum == clsLoop.Loop[workLoop].Loop[curLoop].Entry[i])
                            {
                                countInst++;
                            }
                        }
                    }
                }
                //if current Inst contain cc_entries set => store it
                if (countE == countInst)
                {
                    //set Union of all instance node
                    for (int j = 0; j < nInstantNode; j++)
                    {
                        if (gProAnalyzer.Ultilities.checkGraph.Node_In_Set(searchNode, nSearchNode, InstantNode[j]) == false)
                        {
                            searchNode[nSearchNode] = InstantNode[j];
                            nSearchNode++;
                        }
                    }
                }
            } while (nSearchXOR > 0);

            int[] tempArr = new int[nSearchNode];
            for (int i = 0; i < nSearchNode; i++)
            {
                tempArr[i] = searchNode[i];
            }

            return(tempArr);

            //cardinality = nInst;
        }