public static void copy_SESE(ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int fromSESE, int toSESE) { clsSESE.SESE[toSESE] = new gProAnalyzer.GraphVariables.clsSESE.strSESE(); clsSESE.SESE[toSESE].maxDepth = clsSESE.SESE[fromSESE].maxDepth; clsSESE.SESE[toSESE].nSESE = clsSESE.SESE[fromSESE].nSESE; clsSESE.SESE[toSESE].SESE = new gProAnalyzer.GraphVariables.clsSESE.strSESEInform[clsSESE.SESE[toSESE].nSESE]; for (int i = 0; i < clsSESE.SESE[toSESE].nSESE; i++) { clsSESE.SESE[toSESE].SESE[i].depth = clsSESE.SESE[fromSESE].SESE[i].depth; clsSESE.SESE[toSESE].SESE[i].parentSESE = clsSESE.SESE[fromSESE].SESE[i].parentSESE; clsSESE.SESE[toSESE].SESE[i].nChild = clsSESE.SESE[fromSESE].SESE[i].nChild; clsSESE.SESE[toSESE].SESE[i].child = new int[clsSESE.SESE[toSESE].SESE[i].nChild]; for (int k = 0; k < clsSESE.SESE[toSESE].SESE[i].nChild; k++) { clsSESE.SESE[toSESE].SESE[i].child[k] = clsSESE.SESE[fromSESE].SESE[i].child[k]; } clsSESE.SESE[toSESE].SESE[i].Entry = clsSESE.SESE[fromSESE].SESE[i].Entry; clsSESE.SESE[toSESE].SESE[i].Exit = clsSESE.SESE[fromSESE].SESE[i].Exit; clsSESE.SESE[toSESE].SESE[i].nNode = clsSESE.SESE[fromSESE].SESE[i].nNode; clsSESE.SESE[toSESE].SESE[i].Node = new int[clsSESE.SESE[toSESE].SESE[i].nNode]; for (int k = 0; k < clsSESE.SESE[toSESE].SESE[i].nNode; k++) { clsSESE.SESE[toSESE].SESE[i].Node[k] = clsSESE.SESE[fromSESE].SESE[i].Node[k]; } } }
public static int getSESE_index(ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int entry, int exit) { for (int i = 0; i < clsSESE.SESE[currentSESE].nSESE; i++) { if (clsSESE.SESE[currentSESE].SESE[i].Entry == entry && clsSESE.SESE[currentSESE].SESE[i].Exit == exit) { return(i); } } return(-1); }
public int RunTest(ref gProAnalyzer.GraphVariables.clsGraph graph, ref gProAnalyzer.GraphVariables.clsHWLS clsHWLS, ref gProAnalyzer.GraphVariables.clsLoop clsLoop, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int numRun) { duration = 0; HiPerfTimer pt = new HiPerfTimer(); pt.Start(); for (int i = 0; i < numRun; i++) { Initialize_All(); //SplitType1.Run_Split_Type1(ref graph, graph.orgNet, graph.midNet); //findLoop.Run_FindLoop(ref graph, graph.midNet, ref clsLoop, clsLoop.orgLoop, ref clsLoop.IrreducibleError); graph.Network[graph.finalNet] = graph.Network[graph.orgNet]; //SplitType2.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); //sese.find_SESE_WithLoop(ref graph, graph.finalNet, ref clsLoop, clsLoop.orgLoop, ref clsSESE, clsSESE.finalSESE, -2); gProAnalyzer.Functionalities.SESEIdentification.find_SESE_Dummy(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); //Decompose cyclic subgraphs //Make nesting forest? gProAnalyzer.Ultilities.makeNestingForest.make_NestingForest(ref graph, graph.finalNet, ref clsHWLS, ref clsLoop, clsLoop.orgLoop, ref clsSESE, clsSESE.finalSESE); } pt.Stop(); duration += pt.Duration; duration = duration / (double)numRun; duration = duration * 1000; //makInst.make_InstanceFlow(ref graph, graph.finalNet, 0, "", ""); //================================================== //== get initial behavior profile == //graph.Network[graph.reduceNet] = graph.Network[graph.finalNet]; //extendG.full_extentNetwork(ref graph, graph.reduceNet, 0, 0); //indexing.get_InitialBehaviorProfile(ref graph, graph.reduceNet, ref clsHWLS, ref clsLoop, clsLoop.orgLoop, ref clsSESE, clsSESE.finalSESE); //Database storing return(0); }
public frmSplitModels_Rigids() { InitializeComponent(); graph = new gProAnalyzer.GraphVariables.clsGraph(); clsSESE = new gProAnalyzer.GraphVariables.clsSESE(); clsLoop = new gProAnalyzer.GraphVariables.clsLoop(); clsHWLS = new gProAnalyzer.GraphVariables.clsHWLS(); clsError = new gProAnalyzer.GraphVariables.clsError(); loadGraph = new gProAnalyzer.Preprocessing.clsLoadGraph(); runSESE = new gProAnalyzer.Run_Analysis_SESE(); runVerification = new gProAnalyzer.Run_Analysis_Verification(); }
public frmBasicSimulation() { loadG = new Preprocessing.clsLoadGraph(); graph = new GraphVariables.clsGraph(); clsLoop = new GraphVariables.clsLoop(); clsSESE = new GraphVariables.clsSESE(); clsHWLS = new gProAnalyzer.GraphVariables.clsHWLS(); clsError = new gProAnalyzer.GraphVariables.clsError(); test = new gProAnalyzer.Testing(); runVerification = new gProAnalyzer.Run_Analysis_Verification(); InitializeComponent(); }
public Dashboard_Experiment() { InitializeComponent(); loadG = new Preprocessing.clsLoadGraph(); graph = new GraphVariables.clsGraph(); clsLoop = new GraphVariables.clsLoop(); clsSESE = new GraphVariables.clsSESE(); clsHWLS = new gProAnalyzer.GraphVariables.clsHWLS(); clsError = new gProAnalyzer.GraphVariables.clsError(); runVerification = new gProAnalyzer.Run_Analysis_Verification(); progressBar1.Visible = false; btnRun.Visible = false; exportExcel.Visible = false; }
public static void Add_Parent_SESE(ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int pSESE, int addNum, int addNode) { int[] imSESE = clsSESE.SESE[currentSESE].SESE[pSESE].Node; clsSESE.SESE[currentSESE].SESE[pSESE].nNode += addNum; clsSESE.SESE[currentSESE].SESE[pSESE].Node = new int[clsSESE.SESE[currentSESE].SESE[pSESE].nNode]; for (int m = 0; m < imSESE.Length; m++) { clsSESE.SESE[currentSESE].SESE[pSESE].Node[m] = imSESE[m]; } clsSESE.SESE[currentSESE].SESE[pSESE].Node[clsSESE.SESE[currentSESE].SESE[pSESE].nNode - addNum] = addNode; if (clsSESE.SESE[currentSESE].SESE[pSESE].parentSESE != -1) { Add_Parent_SESE(ref clsSESE, currentSESE, clsSESE.SESE[currentSESE].SESE[pSESE].parentSESE, addNum, addNode); } }
public static void Run_Split_Type3(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref GraphVariables.clsLoop clsLoop, int orgLoop, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, bool isRigidSplit) //isRigidSplit is used for flag to determine whether to split entry of rigid containing start events or not!! { Initialize_All(); bool mStop = false; int sNode; int eNode; int curDepth = clsSESE.SESE[currentSESE].maxDepth; do { for (int j = 0; j < clsSESE.SESE[currentSESE].nSESE; j++) //Visit all the SESE flow { if (clsSESE.SESE[currentSESE].SESE[j].depth != curDepth) { continue; } sNode = clsSESE.SESE[currentSESE].SESE[j].Entry; eNode = clsSESE.SESE[currentSESE].SESE[j].Exit; if (!check_SESE_Entry(ref graph, currentN, ref clsSESE, currentSESE, sNode, j)) { Type_III_Split_Entry(ref graph, currentN, ref clsSESE, currentSESE, j, 1, sNode, eNode, ""); } if (!check_SESE_Entry(ref graph, currentN, ref clsSESE, currentSESE, eNode, j)) { Type_III_Split_Exit(ref graph, currentN, ref clsSESE, currentSESE, j, 1, eNode, eNode); } } curDepth--; } while (curDepth > 0 && !mStop); gProAnalyzer.Functionalities.DominanceIdentification.find_Dom(ref graph, currentN); //Dom gProAnalyzer.Functionalities.DominanceIdentification.find_Pdom(ref graph, currentN); //Postdom gProAnalyzer.Functionalities.DominanceIdentification.find_DomEI(ref graph, currentN, -1); //SS split node만..... //eDom^-1(NodeD) gProAnalyzer.Functionalities.DominanceIdentification.find_PdomEI(ref graph, currentN); // join node만..... //ePdom^-1(NodeR) gProAnalyzer.Functionalities.LoopIdentification.Run_FindLoop(ref graph, currentN, ref clsLoop, orgLoop, ref clsLoop.IrreducibleError); }
public static void add_SESE(ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int nodeD, int nodeR, int[] calSESE, int depth, int parentSESE) { //final checking rigid and add more SESE (1 or more rigids inside) GraphVariables.clsSESE.strSESEInform[] oldSESE = new GraphVariables.clsSESE.strSESEInform[clsSESE.SESE[currentSESE].nSESE]; for (int k = 0; k < clsSESE.SESE[currentSESE].nSESE; k++) { oldSESE[k] = clsSESE.SESE[currentSESE].SESE[k]; } clsSESE.SESE[currentSESE].SESE = new GraphVariables.clsSESE.strSESEInform[clsSESE.SESE[currentSESE].nSESE + 1]; for (int k = 0; k < clsSESE.SESE[currentSESE].nSESE; k++) { clsSESE.SESE[currentSESE].SESE[k] = oldSESE[k]; } clsSESE.SESE[currentSESE].SESE[clsSESE.SESE[currentSESE].nSESE].depth = depth; clsSESE.SESE[currentSESE].SESE[clsSESE.SESE[currentSESE].nSESE].parentSESE = parentSESE; clsSESE.SESE[currentSESE].SESE[clsSESE.SESE[currentSESE].nSESE].Entry = nodeD; clsSESE.SESE[currentSESE].SESE[clsSESE.SESE[currentSESE].nSESE].Exit = nodeR; clsSESE.SESE[currentSESE].SESE[clsSESE.SESE[currentSESE].nSESE].nNode = calSESE.Length; clsSESE.SESE[currentSESE].SESE[clsSESE.SESE[currentSESE].nSESE].Node = calSESE; clsSESE.SESE[currentSESE].nSESE++; }
private static void Initialize_All(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE) { //mapping = new gProAnalyzer.Ultilities.mappingGraph(); //copySE = new gProAnalyzer.Ultilities.copySESE(); //check = new gProAnalyzer.Ultilities.checkGraph(); //fndIntersect = new gProAnalyzer.Ultilities.findIntersection(); gProAnalyzer.Ultilities.mappingGraph.to_adjList_Directed(ref graph, currentN, ref adjList); Mark = new bool[graph.Network[currentN].nNode]; Mark = Array.ConvertAll <bool, bool>(Mark, b => b = false); curDepth = clsSESE.SESE[currentSESE].maxDepth; getPolygons = new int[graph.Network[currentN].nNode * 2]; nPolygons = 0; gProAnalyzer.Ultilities.copySESE.copy_SESE(ref clsSESE, currentSESE, clsSESE.tempSESE); }
private static void Type_III_Split_Entry(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int kSESE, int addNum, int sNode, int cNode, string sName) { gProAnalyzer.Preprocessing.clsExtendNetwork.extent_Network(ref graph, currentN, addNum); int addNode = graph.Network[currentN].nNode - addNum; graph.Network[currentN].Node[addNode].Kind = graph.Network[currentN].Node[sNode].Kind; //new change => to keep the node after split same it father. graph.Network[currentN].Node[addNode].orgNum = sNode; graph.Network[currentN].Node[addNode].parentNum = addNode; graph.Network[currentN].Node[addNode].Special = ""; if (sName == "SSD") { graph.Network[currentN].Node[addNode].Name = "SSD";// addNode.ToString(); graph.Network[currentN].Node[addNode].Type_I = ""; } else { graph.Network[currentN].Node[addNode].Name = graph.Network[currentN].Node[sNode].Name;// sNode.ToString(); graph.Network[currentN].Node[addNode].Type_I = graph.Network[currentN].Node[sNode].Type_I; graph.Network[currentN].Node[addNode].Type_II = graph.Network[currentN].Node[sNode].Type_II + "_se"; } int addLink = graph.Network[currentN].nLink - addNum; graph.Network[currentN].Link[addLink].fromNode = sNode; graph.Network[currentN].Link[addLink].toNode = addNode; //Noi link trong SESE for (int k = 0; k < graph.Network[currentN].nLink - addNum; k++) { if (graph.Network[currentN].Link[k].fromNode == sNode) { bool inSESE = false; for (int m = 0; m < clsSESE.SESE[currentSESE].SESE[kSESE].nNode; m++) { //Neu moi Link K trong SESE => inSESE = true => tạo kết nối với addNode if (graph.Network[currentN].Link[k].toNode == clsSESE.SESE[currentSESE].SESE[kSESE].Node[m]) { inSESE = true; break; } } if (inSESE) { graph.Network[currentN].Link[k].fromNode = addNode; gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, currentN, graph.Network[currentN].Link[k].toNode); } } if (graph.Network[currentN].Link[k].toNode == sNode) { bool inSESE = false; for (int m = 0; m < clsSESE.SESE[currentSESE].SESE[kSESE].nNode; m++) { if (graph.Network[currentN].Link[k].fromNode == clsSESE.SESE[currentSESE].SESE[kSESE].Node[m]) { inSESE = true; break; } } if (inSESE) { graph.Network[currentN].Link[k].toNode = addNode; gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, currentN, graph.Network[currentN].Link[k].fromNode); } } } gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, currentN, addNode); //find the new predecessors and sucessor of this node gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, currentN, sNode); //find the new predecessors and sucessor of this node => after split type III into 2 node (sNode and addNode) //Đổi entry bằng addNode cho SESE clsSESE.SESE[currentSESE].SESE[kSESE].Entry = addNode; for (int m = 0; m < clsSESE.SESE[currentSESE].SESE[kSESE].nNode; m++) { if (clsSESE.SESE[currentSESE].SESE[kSESE].Node[m] == sNode) { clsSESE.SESE[currentSESE].SESE[kSESE].Node[m] = addNode; break; } } //parent정보 변경 if (clsSESE.SESE[currentSESE].SESE[kSESE].parentSESE != -1) { Add_Parent_SESE(ref clsSESE, currentSESE, clsSESE.SESE[currentSESE].SESE[kSESE].parentSESE, addNum, addNode); } //==== ADD CODE HERE ========== //We need to check whether this SESE (currentSESE and kSESE) is a simple strucuture or not. //if it is a simple structure we will find the way to change the SESE Entry gateway. //A simple structure is a structure which have 2 gateways, Entry and Exit (of SESE) //So First, we will check SESE is simple structure, Second, we will change the gateway type //verifySimpleStructure(currentN, currentSESE, kSESE, SESE[currentSESE].SESE[kSESE].Entry, SESE[currentSESE].SESE[kSESE].Exit, true); //==== END OF NEW CODE ======== }
private bool isSimpleStructure(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int kSESE) { int nNodeSESE = clsSESE.SESE[currentSESE].SESE[kSESE].nNode; int countNode = 0; int currNode; for (int i = 0; i < nNodeSESE; i++) { currNode = clsSESE.SESE[currentSESE].SESE[kSESE].Node[i]; if (graph.Network[currentN].Node[currNode].Kind == "OR" || graph.Network[currentN].Node[currNode].Kind == "XOR" || graph.Network[currentN].Node[currNode].Kind == "AND") { countNode = countNode + 1; } } if (countNode > 2) { return(false); } else { return(true); } }
private void verifySimpleStructure(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int kSESE, int entrySESE, int exitSESE, bool flag) { int index; string currName = null; if (flag == true) { index = graph.Network[currentN].Node[entrySESE].Name.Length; if (index > 1) { currName = graph.Network[currentN].Node[entrySESE].Name.Substring(0, 2); } if (isSimpleStructure(ref graph, currentN, ref clsSESE, currentSESE, kSESE) == true && currName == "SS") { graph.Network[currentN].Node[entrySESE].Kind = graph.Network[currentN].Node[exitSESE].Kind; } } else { index = graph.Network[currentN].Node[exitSESE].Name.Length; if (index > 1) { currName = graph.Network[currentN].Node[exitSESE].Name.Substring(0, 2); } if (isSimpleStructure(ref graph, currentN, ref clsSESE, currentSESE, kSESE) == true && currName == "EE") { graph.Network[currentN].Node[exitSESE].Kind = graph.Network[currentN].Node[entrySESE].Kind; } } }
public static bool check_SESE_Entry(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int curNode, int curSESE) //check outter edges of an entrySESE or exitSESE (if more than 1 => should split) { int count_outterEdges = 0; for (int i = 0; i < graph.Network[currentN].Node[curNode].nPost; i++) { int node = graph.Network[currentN].Node[curNode].Post[i]; if (!node_insideSESE(clsSESE.SESE[currentSESE].SESE[curSESE].Node, node)) { count_outterEdges++; } } for (int i = 0; i < graph.Network[currentN].Node[curNode].nPre; i++) { int node = graph.Network[currentN].Node[curNode].Pre[i]; if (!node_insideSESE(clsSESE.SESE[currentSESE].SESE[curSESE].Node, node)) { count_outterEdges++; } } if (count_outterEdges == 1) { return(true); } else { return(false); } }
public static void Type_III_Split_Exit(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int kSESE, int addNum, int eNode, int cNode) { gProAnalyzer.Preprocessing.clsExtendNetwork.extent_Network(ref graph, currentN, addNum); int addNode = graph.Network[currentN].nNode - addNum; graph.Network[currentN].Node[addNode].Kind = graph.Network[currentN].Node[cNode].Kind; graph.Network[currentN].Node[addNode].orgNum = eNode; graph.Network[currentN].Node[addNode].parentNum = addNode; graph.Network[currentN].Node[addNode].Special = ""; graph.Network[currentN].Node[addNode].Name = graph.Network[currentN].Node[eNode].Name;// eNode.ToString(); graph.Network[currentN].Node[addNode].Type_I = graph.Network[currentN].Node[eNode].Type_I; graph.Network[currentN].Node[addNode].Type_II = graph.Network[currentN].Node[eNode].Type_II + "_sx"; int addLink = graph.Network[currentN].nLink - addNum; graph.Network[currentN].Link[addLink].fromNode = addNode; graph.Network[currentN].Link[addLink].toNode = eNode; //기존 Link 정보 변경 for (int k = 0; k < graph.Network[currentN].nLink - addNum; k++) { if (graph.Network[currentN].Link[k].toNode == eNode) //For normal SESE (Acyclic) { bool inSESE = false; for (int m = 0; m < clsSESE.SESE[currentSESE].SESE[kSESE].nNode; m++) { if (graph.Network[currentN].Link[k].fromNode == clsSESE.SESE[currentSESE].SESE[kSESE].Node[m]) { inSESE = true; break; } } if (inSESE) { graph.Network[currentN].Link[k].toNode = addNode; gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, currentN, graph.Network[currentN].Link[k].fromNode); } } if (graph.Network[currentN].Link[k].fromNode == eNode) //For special SESE (Weird NL) { bool inSESE = false; for (int m = 0; m < clsSESE.SESE[currentSESE].SESE[kSESE].nNode; m++) { if (graph.Network[currentN].Link[k].toNode == clsSESE.SESE[currentSESE].SESE[kSESE].Node[m]) { inSESE = true; break; } } if (inSESE) { graph.Network[currentN].Link[k].fromNode = addNode; gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, currentN, graph.Network[currentN].Link[k].toNode); } } } gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, currentN, addNode); gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, currentN, eNode); clsSESE.SESE[currentSESE].SESE[kSESE].Exit = addNode; for (int m = 0; m < clsSESE.SESE[currentSESE].SESE[kSESE].nNode; m++) { if (clsSESE.SESE[currentSESE].SESE[kSESE].Node[m] == eNode) { clsSESE.SESE[currentSESE].SESE[kSESE].Node[m] = addNode; break; } } if (clsSESE.SESE[currentSESE].SESE[kSESE].parentSESE != -1) { Add_Parent_SESE(ref clsSESE, currentSESE, clsSESE.SESE[currentSESE].SESE[kSESE].parentSESE, addNum, addNode); } //Do the same entry of SESE => We check simple structure of this current SESE and change the gateway type //verifySimpleStructure(currentN, currentSESE, kSESE, SESE[currentSESE].SESE[kSESE].Entry, SESE[currentSESE].SESE[kSESE].Exit, false); }
public static int get_post_exitSESE(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int sese, int node) { if (graph.Network[currentN].Node[node].nPost > 1) { for (int i = 0; i < graph.Network[currentN].Node[node].nPost; i++) { if (node_insideSESE(clsSESE.SESE[currentSESE].SESE[sese].Node, graph.Network[currentN].Node[node].Post[i]) == false) { return(graph.Network[currentN].Node[node].Post[i]); } } //node_insideSESE(int[] calSESE, int node) } else if (graph.Network[currentN].Node[node].nPost == 1) { return(graph.Network[currentN].Node[node].Post[0]); } return(-1); }
public static void get_calSESE_Polygon(int[] getPolygons, int nPolygons, ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int nodeD, int nodeR, int depth, int parentSESE) { bool flag = true; int[] tempList = new int[nPolygons]; int[] tempLabel = new int[nPolygons]; int count_temp = 0; for (int i = 0; i < nPolygons; i++) { if (flag) { tempList = new int[nPolygons]; tempLabel = new int[nPolygons]; count_temp = 0; } int node_type = type_Node(ref graph, currentN, ref clsSESE, currentSESE, getPolygons[i], nodeD, nodeR); if (node_type > 0) { tempList[count_temp] = getPolygons[i]; tempLabel[count_temp] = node_type; count_temp++; if (i < (nPolygons - 1)) { if (type_Node(ref graph, currentN, ref clsSESE, currentSESE, getPolygons[i + 1], nodeD, nodeR) > 0) { flag = false; } else { flag = true; } } else { flag = true; } } else { flag = true; //cut 01110001 string and extract a polygon } if (flag == true && count_temp > 1) { int[] calSESE = new int[graph.Network[currentN].nNode]; int curIndex = 0; //extend calSESE int[][] listSESE = new int[clsSESE.SESE[currentSESE].nSESE][]; int nListSESE = 0; bool isOK = false; for (int k = 0; k < count_temp; k++) { if (tempLabel[k] == 2 && (k + 1) < count_temp) { if (tempLabel[k + 1] == 3) { listSESE[nListSESE] = new int[2]; listSESE[nListSESE][0] = tempList[k]; listSESE[nListSESE][1] = tempList[k + 1]; nListSESE++; } } if (tempLabel[k] == 1) { calSESE[curIndex] = tempList[k]; curIndex++; isOK = true; } } for (int k = 0; k < nListSESE; k++) { int en, ex; en = listSESE[k][0]; ex = listSESE[k][1]; int seseIndex = getSESE_index(ref clsSESE, currentSESE, en, ex); if (seseIndex > -1) { clsSESE.SESE[currentSESE].SESE[seseIndex].Node.CopyTo(calSESE, curIndex); curIndex = curIndex + clsSESE.SESE[currentSESE].SESE[seseIndex].nNode; } } int[] old_calSESE = new int[curIndex]; for (int k = 0; k < curIndex; k++) { old_calSESE[k] = calSESE[k]; } calSESE = new int[curIndex]; for (int k = 0; k < curIndex; k++) { calSESE[k] = old_calSESE[k]; } if (nListSESE > 1 || isOK) { add_SESE(ref clsSESE, currentSESE, tempList[0], tempList[count_temp - 1], calSESE, (depth + 1), parentSESE); } } } }
//Reduce SESE into a single node => Represent as SESE_Entry public static void reduce_SESE(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, gProAnalyzer.GraphVariables.clsSESE clsSESE, int workSESE, int currSESE) { int[] imNode = new int[graph.Network[currentN].nNode + 1]; int num = 0; //imNode[num] = clsSESE.SESE[workSESE].SESE[currSESE].Entry; //num++; //Mark node in SESE as will be isolated for (int j = 0; j < clsSESE.SESE[workSESE].SESE[currSESE].nNode; j++) { graph.Network[currentN].Node[clsSESE.SESE[workSESE].SESE[currSESE].Node[j]].done = true; // Collapse nodes in SESE except ENTRY imNode[num] = clsSESE.SESE[workSESE].SESE[currSESE].Node[j]; num++; } int Entry = clsSESE.SESE[workSESE].SESE[currSESE].Entry; graph.Network[currentN].Node[Entry].done = false; graph.Network[currentN].Node[Entry].Kind = "SESE"; graph.Network[currentN].Node[Entry].Name = "SESE[" + currSESE.ToString() + "]"; graph.Network[currentN].Node[Entry].Type_I = ""; graph.Network[currentN].Node[Entry].Type_II = ""; int exitNode = clsSESE.SESE[workSESE].SESE[currSESE].Exit; //Edit the EDGES == (REMOVE UNECESSARY EDGES) int pSESE = clsSESE.SESE[workSESE].SESE[currSESE].parentSESE; for (int k = 0; k < graph.Network[currentN].nLink; k++) { if (graph.Network[currentN].Link[k].fromNode == Entry) //Remove out-edges from ENTRY { //if (clsSESE.SESE[workSESE].SESE[currSESE].nNode == 2) //{ //graph.Network[currentN].Link[k].fromNode = graph.Network[currentN].Link[k].fromNode; //} //else graph.Network[currentN].Link[k].fromNode = graph.Network[currentN].Link[k].toNode; } //Remove edges in node which join as ENTRY if (graph.Network[currentN].Link[k].toNode == Entry && graph.Network[currentN].Node[Entry].nPre > 1) { bool bInLoop = false; for (int j = 0; j < num; j++) { if (graph.Network[currentN].Link[k].fromNode == imNode[j]) { bInLoop = true; break; } } if (bInLoop) { graph.Network[currentN].Link[k].toNode = graph.Network[currentN].Link[k].fromNode; } } //Remove in-edge from inside to EXIT if (graph.Network[currentN].Link[k].toNode == exitNode) { graph.Network[currentN].Link[k].toNode = graph.Network[currentN].Link[k].fromNode; } //Remove edges in node which split as EXIT if (graph.Network[currentN].Link[k].fromNode == exitNode && graph.Network[currentN].Node[exitNode].nPost > 1) { bool bInLoop = false; for (int j = 0; j < num; j++) { if (graph.Network[currentN].Link[k].toNode == imNode[j]) { bInLoop = true; break; } } if (bInLoop) { graph.Network[currentN].Link[k].fromNode = graph.Network[currentN].Link[k].toNode; } } } //Edit out-edges of ENTRY. for (int k = 0; k < graph.Network[currentN].nLink; k++) { if (graph.Network[currentN].Link[k].fromNode == exitNode && graph.Network[currentN].Link[k].fromNode != graph.Network[currentN].Link[k].toNode) { graph.Network[currentN].Link[k].fromNode = Entry; } } //Finally - update node information for (int i = 0; i < graph.Network[currentN].nNode; i++) { if (graph.Network[currentN].Node[i].done) { graph.Network[currentN].Node[i].nPre = 0; graph.Network[currentN].Node[i].nPost = 0; graph.Network[currentN].Node[i].Pre = null; graph.Network[currentN].Node[i].Post = null; graph.Network[currentN].Node[i].Special = ""; } else { //nodeInfo = new gProAnalyzer.Ultilities.clsFindNodeInfo(); gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, currentN, i); } } }
public static int type_Node(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE, int node, int nodeD, int nodeR) // return 1 for TASK/EVENT, return 2 for ENTRY SESE, return 3 for EXIT SESE { if (node != -1) { if (node == nodeD || node == nodeR) { return(0); } if (graph.Network[currentN].Node[node].nPre > 1 || graph.Network[currentN].Node[node].nPost > 1) { for (int i = 0; i < clsSESE.SESE[currentSESE].nSESE; i++) { if (node == clsSESE.SESE[currentSESE].SESE[i].Entry) { return(2); } if (node == clsSESE.SESE[currentSESE].SESE[i].Exit) { return(3); } } } else if (graph.Network[currentN].Node[node].Kind == "TASK" || graph.Network[currentN].Node[node].Kind == "EVENT" || graph.Network[currentN].Node[node].Kind == "START" || graph.Network[currentN].Node[node].Kind == "END") { return(1); } } return(0); }
public static void make_SESE_hierarchy(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE) { for (int iSE = 0; iSE < clsSESE.SESE[currentSESE].nSESE; iSE++) { for (int jSE = 0; jSE < clsSESE.SESE[currentSESE].nSESE; jSE++) { if (clsSESE.SESE[currentSESE].SESE[iSE].nNode >= clsSESE.SESE[currentSESE].SESE[jSE].nNode) { continue; } int[] calSESE = gProAnalyzer.Ultilities.findIntersection.find_Intersection(clsSESE.SESE[currentSESE].SESE[jSE].nNode, clsSESE.SESE[currentSESE].SESE[iSE].Node, clsSESE.SESE[currentSESE].SESE[jSE].Node); if (gProAnalyzer.Ultilities.checkGraph.check_SameSet(calSESE, clsSESE.SESE[currentSESE].SESE[iSE].Node)) // iSE가 jSE의 child면 // check the same of calSESE (after intersection) and iSE { //until here, we have just dealed with the .parentSESE int pSE = jSE; if (clsSESE.SESE[currentSESE].SESE[iSE].parentSESE != -1) { if (clsSESE.SESE[currentSESE].SESE[jSE].nNode > clsSESE.SESE[currentSESE].SESE[clsSESE.SESE[currentSESE].SESE[iSE].parentSESE].nNode) { pSE = clsSESE.SESE[currentSESE].SESE[iSE].parentSESE; } } clsSESE.SESE[currentSESE].SESE[iSE].parentSESE = pSE; } } } int max_Depth = 0; for (int iSE = 0; iSE < clsSESE.SESE[currentSESE].nSESE; iSE++) { //find Depth int depth = 1; int cSE = iSE; do { if (clsSESE.SESE[currentSESE].SESE[cSE].parentSESE == -1) { break; } cSE = clsSESE.SESE[currentSESE].SESE[cSE].parentSESE; depth++; } while (true); //find child int cntFind = 0; int[] get_SESE = new int[clsSESE.SESE[currentSESE].nSESE]; //store a child of iSE SESE for (int jSE = 0; jSE < clsSESE.SESE[currentSESE].nSESE; jSE++) { if (clsSESE.SESE[currentSESE].SESE[jSE].parentSESE == iSE) { get_SESE[cntFind] = jSE; cntFind++; } } clsSESE.SESE[currentSESE].SESE[iSE].depth = depth; clsSESE.SESE[currentSESE].SESE[iSE].nChild = cntFind; clsSESE.SESE[currentSESE].SESE[iSE].child = new int[cntFind]; for (int k = 0; k < cntFind; k++) { clsSESE.SESE[currentSESE].SESE[iSE].child[k] = get_SESE[k]; } if (depth > max_Depth) { max_Depth = depth; } } clsSESE.SESE[currentSESE].maxDepth = max_Depth; //================================ //modify SESE (SESE[currentSESE].SESE[i].parentSESE); //modify_SESE_Hierarchy(currentSESE); //================================ for (int i = 0; i < clsSESE.SESE[currentSESE].nSESE; i++) { clsSESE.SESE[currentSESE].SESE[i].parentSESE = -1; } // Make hierarchy for (int iSE = 0; iSE < clsSESE.SESE[currentSESE].nSESE; iSE++) { for (int jSE = 0; jSE < clsSESE.SESE[currentSESE].nSESE; jSE++) { if (clsSESE.SESE[currentSESE].SESE[iSE].nNode >= clsSESE.SESE[currentSESE].SESE[jSE].nNode) { continue; } int[] calSESE = gProAnalyzer.Ultilities.findIntersection.find_Intersection(clsSESE.SESE[currentSESE].SESE[jSE].nNode, clsSESE.SESE[currentSESE].SESE[iSE].Node, clsSESE.SESE[currentSESE].SESE[jSE].Node); if (gProAnalyzer.Ultilities.checkGraph.check_SameSet(calSESE, clsSESE.SESE[currentSESE].SESE[iSE].Node)) // iSE가 jSE의 child면 // check the same of calSESE (after intersection) and iSE { //until here, we have just dealed with the .parentSESE int pSE = jSE; if (clsSESE.SESE[currentSESE].SESE[iSE].parentSESE != -1) { if (clsSESE.SESE[currentSESE].SESE[jSE].nNode > clsSESE.SESE[currentSESE].SESE[clsSESE.SESE[currentSESE].SESE[iSE].parentSESE].nNode) { pSE = clsSESE.SESE[currentSESE].SESE[iSE].parentSESE; } } clsSESE.SESE[currentSESE].SESE[iSE].parentSESE = pSE; } } } //======================== max_Depth = 0; for (int iSE = 0; iSE < clsSESE.SESE[currentSESE].nSESE; iSE++) { if (iSE == 17) { //int stop; } //find Depth int depth = 1; int cSE = iSE; do { if (clsSESE.SESE[currentSESE].SESE[cSE].parentSESE == -1) { break; } cSE = clsSESE.SESE[currentSESE].SESE[cSE].parentSESE; depth++; } while (true); //find child int cntFind = 0; int[] get_SESE = new int[clsSESE.SESE[currentSESE].nSESE]; //store a child of iSE SESE for (int jSE = 0; jSE < clsSESE.SESE[currentSESE].nSESE; jSE++) { if (clsSESE.SESE[currentSESE].SESE[jSE].parentSESE == iSE) { get_SESE[cntFind] = jSE; cntFind++; } } clsSESE.SESE[currentSESE].SESE[iSE].depth = depth; clsSESE.SESE[currentSESE].SESE[iSE].nChild = cntFind; clsSESE.SESE[currentSESE].SESE[iSE].child = new int[cntFind]; for (int k = 0; k < cntFind; k++) { clsSESE.SESE[currentSESE].SESE[iSE].child[k] = get_SESE[k]; } if (depth > max_Depth) { max_Depth = depth; } } clsSESE.SESE[currentSESE].maxDepth = max_Depth; }
public static void polygonIdentification(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, ref gProAnalyzer.GraphVariables.clsSESE clsSESE, int currentSESE) { Initialize_All(ref graph, currentN, ref clsSESE, currentSESE); //output => polygon which contain parentSESE information //convert model to adjList[][] do { for (int i = 0; i < clsSESE.SESE[currentSESE].nSESE; i++) { if (clsSESE.SESE[currentSESE].SESE[i].depth == curDepth) { int curEntry = clsSESE.SESE[currentSESE].SESE[i].Entry; int curExit = clsSESE.SESE[currentSESE].SESE[i].Exit; if (i == 3) { } //reduce all nested SESE in adjList for (int k = 0; k < clsSESE.SESE[currentSESE].SESE[i].nChild; k++) { int child = clsSESE.SESE[currentSESE].SESE[i].child[k]; int en = clsSESE.SESE[currentSESE].SESE[child].Entry; int ex = clsSESE.SESE[currentSESE].SESE[child].Exit; adjList[en] = new int[2]; adjList[en][0] = 1; adjList[en][1] = ex; for (int z = 0; z < clsSESE.SESE[currentSESE].SESE[child].nNode; z++) { int temp_node = clsSESE.SESE[currentSESE].SESE[child].Node[z]; Mark[temp_node] = true; if ((temp_node == clsSESE.SESE[currentSESE].SESE[child].Entry) || (temp_node == clsSESE.SESE[currentSESE].SESE[child].Exit)) { Mark[temp_node] = false; } } int[] temp = new int[graph.Network[currentN].Node[ex].nPost]; int nTemp = 0; for (int w = 0; w < graph.Network[currentN].Node[ex].nPost; w++) { if (Mark[graph.Network[currentN].Node[ex].Post[w]] == false) { temp[nTemp] = graph.Network[currentN].Node[ex].Post[w]; nTemp++; } } adjList[ex][0] = nTemp; for (int w = 0; w < nTemp; w++) { adjList[ex][w + 1] = temp[w]; } } //DFS_Polygon() for (int j = 0; j < graph.Network[currentN].Node[curEntry].nPost; j++) { if (i == 3) { } getPolygons = new int[graph.Network[currentN].nNode * 2]; nPolygons = 0; firstNode = graph.Network[currentN].Node[curEntry].Post[j]; int after_node = get_post_exitSESE(ref graph, currentN, ref clsSESE, currentSESE, i, curExit); DFS_Polygon(adjList, ref Mark, firstNode, curEntry, after_node, ref getPolygons, ref nPolygons); //=> 0011110000111001110001110 sample if (nPolygons > 1) { //process polygon get_calSESE_Polygon(getPolygons, nPolygons, ref graph, currentN, ref clsSESE, clsSESE.tempSESE, curEntry, curExit, curDepth, i); } } Mark = Array.ConvertAll <bool, bool>(Mark, b => b = false); } } curDepth--; }while (curDepth > 0); for (int k = 0; k < clsSESE.SESE[currentSESE].nSESE; k++) { if (clsSESE.SESE[currentSESE].SESE[k].depth == 1) { int en = clsSESE.SESE[currentSESE].SESE[k].Entry; int ex = clsSESE.SESE[currentSESE].SESE[k].Exit; adjList[en] = new int[2]; adjList[en][0] = 1; adjList[en][1] = ex; for (int z = 0; z < clsSESE.SESE[currentSESE].SESE[k].nNode; z++) { Mark[clsSESE.SESE[currentSESE].SESE[k].Node[z]] = true; if ((clsSESE.SESE[currentSESE].SESE[k].Node[z] == clsSESE.SESE[currentSESE].SESE[k].Entry) || (clsSESE.SESE[currentSESE].SESE[k].Node[z] == clsSESE.SESE[currentSESE].SESE[k].Exit)) { Mark[clsSESE.SESE[currentSESE].SESE[k].Node[z]] = false; } } int[] temp = new int[graph.Network[currentN].Node[ex].nPost]; int nTemp = 0; for (int w = 0; w < graph.Network[currentN].Node[ex].nPost; w++) { if (Mark[graph.Network[currentN].Node[ex].Post[w]] == false) { temp[nTemp] = graph.Network[currentN].Node[ex].Post[w]; nTemp++; } } adjList[ex][0] = nTemp; for (int w = 0; w < nTemp; w++) { adjList[ex][w + 1] = temp[w]; } } } //find polygon outside from START to END int START_plg = -1; int END_plg = -1; for (int i = 0; i < graph.Network[currentN].nNode; i++) { if (graph.Network[currentN].Node[i].Kind == "START") { START_plg = i; } if (graph.Network[currentN].Node[i].Kind == "END") { END_plg = i; } } getPolygons = new int[graph.Network[currentN].nNode * 2]; nPolygons = 0; firstNode = START_plg; DFS_Polygon(adjList, ref Mark, firstNode, START_plg, END_plg, ref getPolygons, ref nPolygons); //=> 0011110000111001110001110 sample getPolygons[nPolygons - 1] = END_plg; //modify getPolygons[nPolygons] = -1; //modify nPolygons++; //modify if (nPolygons > 1) { get_calSESE_Polygon(getPolygons, nPolygons, ref graph, currentN, ref clsSESE, clsSESE.tempSESE, -1, -1, curDepth, -1); } //update the hierarchy of SESE (copy SESE from tempSESE to currentSESE) gProAnalyzer.Ultilities.copySESE.copy_SESE(ref clsSESE, clsSESE.tempSESE, currentSESE); make_SESE_hierarchy(ref graph, currentN, ref clsSESE, currentSESE); }