public static int find_nearestParentBlock(ref GraphVariables.clsHWLS clsHWLS, int i) { int[] parentCandidates = new int[clsHWLS.FBLOCK.nFBlock]; int nParentCandidate = 0; for (int j = 0; j < clsHWLS.FBLOCK.nFBlock; j++) { if ((clsHWLS.FBLOCK.FBlock[i].nNode < clsHWLS.FBLOCK.FBlock[j].nNode) && (check_sameBlock(clsHWLS.FBLOCK.FBlock[i].Node, clsHWLS.FBLOCK.FBlock[i].nNode, clsHWLS.FBLOCK.FBlock[j].Node, clsHWLS.FBLOCK.FBlock[j].nNode))) { //bool check = false; parentCandidates[nParentCandidate] = j; nParentCandidate++; } } if (nParentCandidate > 0) { int min = clsHWLS.FBLOCK.FBlock[parentCandidates[0]].nNode; int minIndex = parentCandidates[0]; for (int j = 0; j < nParentCandidate; j++) { if (min > clsHWLS.FBLOCK.FBlock[parentCandidates[j]].nNode) { min = clsHWLS.FBLOCK.FBlock[parentCandidates[j]].nNode; minIndex = parentCandidates[j]; } } return(minIndex); } else { return(-1); } }
public static void store_BehaviorProfile(ref GraphVariables.clsHWLS clsHWLS, int currHWLS, int orgX, int orgY, bool[] returnBhPrfl, bool isDomBH) { int nDomBhIndx = clsHWLS.FBLOCK.FBlock[currHWLS].nDomBh; int nPdomBhIndx = clsHWLS.FBLOCK.FBlock[currHWLS].nPdomBh; if (isDomBH) { //#row of Dom_BhPrfl for (int i = 0; i < 9; i++) { if (i == 0) { clsHWLS.FBLOCK.FBlock[currHWLS].Dom_BhPrfl[i, nDomBhIndx] = orgY; } else { if (returnBhPrfl[i - 1] == true) { clsHWLS.FBLOCK.FBlock[currHWLS].Dom_BhPrfl[i, nDomBhIndx] = 1; } else { clsHWLS.FBLOCK.FBlock[currHWLS].Dom_BhPrfl[i, nDomBhIndx] = 0; } } } nDomBhIndx++; clsHWLS.FBLOCK.FBlock[currHWLS].nDomBh = nDomBhIndx; } else { //#row of Pdom_BhPrfl for (int i = 0; i < 9; i++) { if (i == 0) { clsHWLS.FBLOCK.FBlock[currHWLS].Pdom_BhPrfl[i, nPdomBhIndx] = orgY; } else { if (returnBhPrfl[i - 1] == true) { clsHWLS.FBLOCK.FBlock[currHWLS].Pdom_BhPrfl[i, nPdomBhIndx] = 1; } else { clsHWLS.FBLOCK.FBlock[currHWLS].Pdom_BhPrfl[i, nPdomBhIndx] = 0; } } } nPdomBhIndx++; clsHWLS.FBLOCK.FBlock[currHWLS].nPdomBh = nPdomBhIndx; } }
public static int getFblockIndex(int currentSESE, GraphVariables.clsHWLS clsHWLS) { for (int i = 0; i < clsHWLS.FBLOCK.nFBlock; i++) { if (currentSESE == clsHWLS.FBLOCK.FBlock[i].refIndex) { return(i); } } return(-1); }
public static void find_BlockDepth(ref GraphVariables.clsHWLS clsHWLS, int i, ref int curDepth) { if (clsHWLS.FBLOCK.FBlock[i].nChild > 0) { for (int j = 0; j < clsHWLS.FBLOCK.FBlock[i].nChild; j++) { curDepth++; if (clsHWLS.FBLOCK.maxDepth < curDepth) { clsHWLS.FBLOCK.maxDepth = curDepth; } clsHWLS.FBLOCK.FBlock[clsHWLS.FBLOCK.FBlock[i].child[j]].depth = curDepth; find_BlockDepth(ref clsHWLS, clsHWLS.FBLOCK.FBlock[i].child[j], ref curDepth); curDepth--; } } }
//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); } } }
public static void check_Block_Same(ref GraphVariables.clsHWLS clsHWLS) { bool check = false; do { check = false; for (int i = 0; i < clsHWLS.FBLOCK.nFBlock - 1; i++) { for (int j = i + 1; j < clsHWLS.FBLOCK.nFBlock; j++) { if ((clsHWLS.FBLOCK.FBlock[i].nNode == clsHWLS.FBLOCK.FBlock[j].nNode) && (check_sameBlock(clsHWLS.FBLOCK.FBlock[i].Node, clsHWLS.FBLOCK.FBlock[i].nNode, clsHWLS.FBLOCK.FBlock[j].Node, clsHWLS.FBLOCK.FBlock[j].nNode))) { //remove FBLOCK.FBlock[j]; if (clsHWLS.FBLOCK.FBlock[j].SESE == true) { for (int k = j + 1; k < clsHWLS.FBLOCK.nFBlock; k++) { clsHWLS.FBLOCK.FBlock[k - 1] = clsHWLS.FBLOCK.FBlock[k]; } } else { for (int k = i + 1; k < clsHWLS.FBLOCK.nFBlock; k++) { clsHWLS.FBLOCK.FBlock[k - 1] = clsHWLS.FBLOCK.FBlock[k]; } } clsHWLS.FBLOCK.nFBlock--; check = true; break; } } if (check) { break; } } } while (check); }
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 }
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; } }
public static void start_Indexing(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); int workNet = graph.finalNet; int workLoop = clsLoop.orgLoop; int workSESE = clsSESE.finalSESE; bool checkUntangle = false; //Untangling of Irreducible loops ==> USING UNTANGLE NET only (new graph) if (gProAnalyzer.Functionalities.UntanglingIL.make_UntanglingIL(ref graph, graph.finalNet, graph.untangleNet, clsHWLS, clsLoop, clsLoop.orgLoop, clsSESE, clsSESE.finalSESE)) { //return; //frmAnl.displayProcessModel(ref graph, graph.untangleNet, ref clsLoop, -1, ref clsSESE, -1); //frmAnl.Show(); //return; gProAnalyzer.Functionalities.NodeSplittingType1.Run_Split_Type1(ref graph, graph.untangleNet, graph.midNet); gProAnalyzer.Functionalities.LoopIdentification.Run_FindLoop(ref graph, graph.midNet, ref clsLoop, clsLoop.untangleLoop, ref clsLoop.IrreducibleError); gProAnalyzer.Functionalities.NodeSplittingType2.Run_Split_Type2(ref graph, graph.midNet, graph.untangleNet, ref clsLoop, clsLoop.untangleLoop); gProAnalyzer.Functionalities.DominanceIdentification.find_Dom(ref graph, graph.untangleNet); gProAnalyzer.Functionalities.DominanceIdentification.find_Pdom(ref graph, graph.untangleNet); gProAnalyzer.Functionalities.DominanceIdentification.find_DomEI(ref graph, graph.untangleNet, -2); gProAnalyzer.Functionalities.DominanceIdentification.find_PdomEI(ref graph, graph.untangleNet); gProAnalyzer.Functionalities.SESEIdentification.find_SESE_WithLoop(ref graph, graph.untangleNet, ref clsLoop, clsLoop.untangleLoop, ref clsSESE, clsSESE.untangleSESE, -2); gProAnalyzer.Functionalities.NodeSplittingType3.Run_Split_Type3(ref graph, graph.untangleNet, ref clsLoop, clsLoop.untangleLoop, ref clsSESE, clsSESE.untangleSESE, true); gProAnalyzer.Ultilities.makeNestingForest.make_NestingForest(ref graph, graph.untangleNet, ref clsHWLS_Untangle, ref clsLoop, clsLoop.untangleLoop, ref clsSESE, clsSESE.untangleSESE); workNet = graph.untangleNet; workLoop = clsLoop.untangleLoop; workSESE = clsSESE.untangleSESE; checkUntangle = true; graph.check_untangle = true; //frmAnl.displayProcessModel(ref graph, graph.untangleNet, ref clsLoop, clsLoop.untangleLoop, ref clsSESE, clsSESE.untangleSESE); //frmAnl.Show(); } //== get initial behavior profile == graph.Network[graph.reduceNet] = graph.Network[workNet]; gProAnalyzer.Ultilities.extendGraph.full_extentNetwork(ref graph, graph.reduceNet, 0, 0); if (checkUntangle) { get_InitialBehaviorProfile(ref graph, graph.reduceNet, ref clsHWLS_Untangle, ref clsLoop, workLoop, ref clsSESE, workSESE, flag_Check); } else { get_InitialBehaviorProfile(ref graph, graph.reduceNet, ref clsHWLS, ref clsLoop, workLoop, ref clsSESE, workSESE, flag_Check); } //Database storing }
//Build behavior profile for each header of each decomposed acyclic structure. each matrix for each pair? public static void get_InitialBehaviorProfile(ref GraphVariables.clsGraph graph, int currentN, ref GraphVariables.clsHWLS clsHWLS, ref GraphVariables.clsLoop clsLoop, int workLoop, ref GraphVariables.clsSESE clsSESE, int workSESE, bool[] flag_Check) { //input: a decomposed DAG //output: behavior profile of it header and its children //makeSubNetwork of clsDASPT //make instantFlow (AnalyseBehavior_InstF) of HEADER and its childs. //create behaviorProfile matrix for HEADER Initialize_All(); //bool[] flag_Check = new bool[8]; int curDepth = clsHWLS.FBLOCK.maxDepth; //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) { //Make subnet gProAnalyzer.Ultilities.makeSubNetwork.make_subNetwork(ref graph, currentN, graph.subNet, ref clsLoop, workSESE, orgIndx, ref clsSESE, "SESE", -1); int nNode = graph.Network[graph.subNet].nNode; int x = graph.Network[graph.subNet].Node[graph.Network[graph.subNet].header].Post[0]; bool[] returnBhPrfl = new bool[8]; clsHWLS.FBLOCK.FBlock[i].Dom_BhPrfl = new int[9, nNode + 1]; clsHWLS.FBLOCK.FBlock[i].Dom_BhPrfl[0, 0] = graph.Network[graph.subNet].Node[x].orgNum; //ENTRY SESE org index. clsHWLS.FBLOCK.FBlock[i].nDomBh = 1; //get behavior matrix of SESE ENTRY for (int j = 0; j < graph.Network[graph.subNet].nNode; j++) { int y = j; if (x == y || graph.Network[graph.subNet].Node[x].orgNum == -1) { continue; //Exclude VS, VE } gProAnalyzer.Ultilities.AnalyseBehavior_InstF.check_InstanceBehavior(graph, graph.subNet, x, y, ref returnBhPrfl, flag_Check); store_BehaviorProfile(ref clsHWLS, i, graph.Network[graph.subNet].Node[x].orgNum, graph.Network[graph.subNet].Node[y].orgNum, returnBhPrfl, true); } //reduce current Block LASTLY (already imply by depth pick) gProAnalyzer.Ultilities.reduceGraph.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) { //Make subnet gProAnalyzer.Ultilities.makeSubNetwork.make_AcyclicSubGraph(ref graph, currentN, graph.subNet, ref clsLoop, workLoop, orgIndx, "NL"); int nNode = graph.Network[graph.subNet].nNode; int x, y; //get behavior matrix of HEADER ENTRY and its childs x = graph.Network[graph.subNet].Node[graph.Network[graph.subNet].header].Post[0]; //Get NL Loop HEADER bool[] returnBhPrfl = new bool[8]; clsHWLS.FBLOCK.FBlock[i].Dom_BhPrfl = new int[9, nNode + 2]; //store itself behavior clsHWLS.FBLOCK.FBlock[i].Dom_BhPrfl[0, 0] = graph.Network[graph.subNet].Node[x].orgNum; //Header org index. clsHWLS.FBLOCK.FBlock[i].nDomBh = 1; for (int j = 0; j < graph.Network[graph.subNet].nNode; j++) { y = j; if (x == y || graph.Network[graph.subNet].Node[x].orgNum == -1) { continue; } gProAnalyzer.Ultilities.AnalyseBehavior_InstF.check_InstanceBehavior(graph, graph.subNet, x, y, ref returnBhPrfl, flag_Check); store_BehaviorProfile(ref clsHWLS, i, graph.Network[graph.subNet].Node[x].orgNum, graph.Network[graph.subNet].Node[y].orgNum, returnBhPrfl, true); } //get behavior matrix of Its childs and HEADER (Pdom) y = get_NodeByName(graph, graph.subNet, "V_HEADER"); if (y == -1) { continue; } returnBhPrfl = new bool[8]; clsHWLS.FBLOCK.FBlock[i].Pdom_BhPrfl = new int[9, nNode + 2]; clsHWLS.FBLOCK.FBlock[i].Pdom_BhPrfl[0, 0] = graph.Network[graph.subNet].Node[y].orgNum; //Header index. clsHWLS.FBLOCK.FBlock[i].nPdomBh = 1; for (int j = 0; j < graph.Network[graph.subNet].nNode; j++) { x = j; if (x == y || graph.Network[graph.subNet].Node[x].orgNum == -1) { continue; } gProAnalyzer.Ultilities.AnalyseBehavior_InstF.check_InstanceBehavior(graph, graph.subNet, x, y, ref returnBhPrfl, flag_Check); store_BehaviorProfile(ref clsHWLS, i, graph.Network[graph.subNet].Node[y].orgNum, graph.Network[graph.subNet].Node[x].orgNum, returnBhPrfl, false); } //reduce current Block (NL) gProAnalyzer.Ultilities.reduceGraph.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) { //Make subnet gProAnalyzer.Ultilities.makeSubNetwork.make_AcyclicSubGraph(ref graph, currentN, graph.subNet, ref clsLoop, workLoop, orgIndx, "IL"); int nNode = graph.Network[graph.subNet].nNode; int x, y; //get behavior matrix of HEADER ENTRY and its childs x = graph.Network[graph.subNet].Node[graph.Network[graph.subNet].header].Post[0]; //Get CIPd of IL clsHWLS.FBLOCK.FBlock[i].CIPd = graph.Network[graph.subNet].Node[x].orgNum; bool[] returnBhPrfl = new bool[8]; clsHWLS.FBLOCK.FBlock[i].Dom_BhPrfl = new int[9, nNode + 2]; //store itself behavior clsHWLS.FBLOCK.FBlock[i].Dom_BhPrfl[0, 0] = graph.Network[graph.subNet].Node[x].orgNum; //CIPd org index. clsHWLS.FBLOCK.FBlock[i].nDomBh = 1; for (int j = 0; j < graph.Network[graph.subNet].nNode; j++) { y = j; if (x == y || graph.Network[graph.subNet].Node[x].orgNum == -1) { continue; } gProAnalyzer.Ultilities.AnalyseBehavior_InstF.check_InstanceBehavior(graph, graph.subNet, x, y, ref returnBhPrfl, flag_Check); store_BehaviorProfile(ref clsHWLS, i, graph.Network[graph.subNet].Node[x].orgNum, graph.Network[graph.subNet].Node[y].orgNum, returnBhPrfl, true); } //combine from CID(x, y) ==>> MISSING => SOLVED (no need) //get behavior matrix of Its childs and HEADER (Pdom) y = get_NodeByName(graph, graph.subNet, "V_CIPd"); if (y == -1) { continue; } returnBhPrfl = new bool[8]; clsHWLS.FBLOCK.FBlock[i].Pdom_BhPrfl = new int[9, nNode + 2]; clsHWLS.FBLOCK.FBlock[i].Pdom_BhPrfl[0, 0] = graph.Network[graph.subNet].Node[y].orgNum; //Header index. clsHWLS.FBLOCK.FBlock[i].nPdomBh = 1; for (int j = 0; j < graph.Network[graph.subNet].nNode; j++) { x = j; if (x == y || graph.Network[graph.subNet].Node[x].orgNum == -1) { continue; } gProAnalyzer.Ultilities.AnalyseBehavior_InstF.check_InstanceBehavior(graph, graph.subNet, x, y, ref returnBhPrfl, flag_Check); store_BehaviorProfile(ref clsHWLS, i, graph.Network[graph.subNet].Node[y].orgNum, graph.Network[graph.subNet].Node[x].orgNum, returnBhPrfl, false); } //combine from CID(x, y) ==>> MISSING => SOLVED (no need) //reduce current Block (IL) gProAnalyzer.Ultilities.reduceGraph.reduce_IrLoop(ref graph, currentN, clsLoop, workLoop, orgIndx); } } curDepth--; } while (curDepth > 0); }
public static int check_real_errors(GraphVariables.clsGraph graph, int currentN, GraphVariables.clsHWLS clsHWLS, GraphVariables.clsLoop clsLoop, int currentLoop, ref GraphVariables.clsError clsError, int errorNode) //return(1) => Real; return(2) => Potential; return(3) => Dom { int[][] adjList = null; if (true) //acyclic { int[] getPath = new int[graph.Network[currentN].nNode]; int START = graph.Network[currentN].header; int nGetPath = 0; bool[] Mark = new bool[graph.Network[currentN].nNode]; gProAnalyzer.Ultilities.mappingGraph.to_adjList_Directed(ref graph, currentN, ref adjList); //We already buil an instance subgraph based on InstanceNode !! Huaahhh~ //Check "Real error" first for (int i = 0; i < clsError.nError; i++) //filtering the DL or LoS of acyclic only { if (!check_Error_Num(clsError, i)) { continue; //filtering acylci error } bool flag_Real_error = true; //0: real; int EXIT = Convert.ToInt32(clsError.Error[i].Node); DFS_Recursive(adjList, ref Mark, START, EXIT, ref getPath, ref nGetPath, clsError, ref flag_Real_error); if (flag_Real_error == true) { clsError.Error[i].TypeOfError = "R"; } else { clsError.Error[i].TypeOfError = "P"; } } //Check "Domiance error" from "Potential error" for (int i = 0; i < clsError.nError; i++) //filtering the DL or LoS of acyclic only { if (!check_Error_Num(clsError, i)) { continue; //filtering acylci error } if (clsError.Error[i].TypeOfError != "R") { continue; //only pick REAL errors for referencing } int currError = Convert.ToInt32(clsError.Error[i].Node); //This is a real error for (int k = 0; k < clsError.nError; k++) //filtering the DL or LoS of acyclic only { if (!check_Error_Num(clsError, k)) { continue; //filtering acylci error } if (clsError.Error[k].Node == clsError.Error[i].Node) { continue; } if (Ultilities.checkGraph.Node_In_Set(graph.Network[currentN].Node[currError].DomEI, graph.Network[currentN].Node[currError].nDomEI, Convert.ToInt32(clsError.Error[k].Node))) { clsError.Error[k].TypeOfError = "D"; } } } //Check "Dominance_by_Potential error" of Potential errors (From the leftover potential errors) for (int i = 0; i < clsError.nError; i++) //filtering the DL or LoS of acyclic only { if (!check_Error_Num(clsError, i)) { continue; //filtering acyclic error } if (clsError.Error[i].TypeOfError != "P") { continue; } int currError = Convert.ToInt32(clsError.Error[i].Node); for (int k = 0; k < clsError.nError; k++) //filtering the DL or LoS of acyclic only { if (!check_Error_Num(clsError, k)) { continue; //filtering acylci error } if (clsError.Error[k].Node == clsError.Error[i].Node) { continue; } if (Ultilities.checkGraph.Node_In_Set(graph.Network[currentN].Node[currError].DomEI, graph.Network[currentN].Node[currError].nDomEI, Convert.ToInt32(clsError.Error[k].Node))) { clsError.Error[k].TypeOfError = "DP"; } } } } else //if cylic graph { //First, check Error type DL, LoS, same with above (Must reduce all loop) => Compute the dominance relations //If error from inside NL => check (IF REDUCE LOOP => MUST MARK other reducedLoop as having Error for easily check). //If current NL => Take out NL subgraph => run DFS to check "Real_Error" and "Potential_errors" -> Check "Dominance_Errors" //If current NL Header is "Real" => keep everything original //If current NL Header is "Dom" => All error wil be "Dominace_Errors" //If current NL Header is "Potential" => All error will be "Potential_Errors" #region int curDepth = clsHWLS.FBLOCK.maxDepth; do { for (int k = 0; k < clsHWLS.FBLOCK.nFBlock; k++) { if (clsHWLS.FBLOCK.FBlock[k].depth != curDepth) { continue; } int orgIndx = clsHWLS.FBLOCK.FBlock[k].refIndex; if (clsHWLS.FBLOCK.FBlock[k].SESE == false && clsLoop.Loop[currentLoop].Loop[orgIndx].nEntry == 1) { gProAnalyzer.Ultilities.makeSubNetwork.make_AcyclicSubGraph(ref graph, currentN, graph.subNet, ref clsLoop, currentLoop, orgIndx, "NL"); int[] getPath = new int[graph.Network[graph.subNet].nNode]; int START = graph.Network[graph.subNet].header; int nGetPath = 0; bool[] Mark = new bool[graph.Network[graph.subNet].nNode]; gProAnalyzer.Ultilities.mappingGraph.to_adjList_Directed(ref graph, graph.subNet, ref adjList); //We already buil an instance subgraph based on InstanceNode !! Huaahhh~ //Check "Real error" first for (int i = 0; i < clsError.nError; i++) //filtering the DL or LoS of acyclic only { if (!(clsError.Error[k].messageNum == 3 || clsError.Error[k].messageNum == 4 || clsError.Error[k].messageNum == 29 || clsError.Error[k].messageNum == 5 || clsError.Error[k].messageNum == 6)) { continue; //filtering Loop error only [3,4,5,6,29] } bool flag_Real_error = true; //0: real; int EXIT = Convert.ToInt32(clsError.Error[i].Node); DFS_Recursive(adjList, ref Mark, START, EXIT, ref getPath, ref nGetPath, clsError, ref flag_Real_error); if (flag_Real_error == true) { clsError.Error[i].TypeOfError = "R"; } else { clsError.Error[i].TypeOfError = "P"; } } } } curDepth--; } while (curDepth > 0); #endregion } return(1); }
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"); }
public static bool make_UntanglingIL(ref GraphVariables.clsGraph graph, int currentN, int untangleNet, GraphVariables.clsHWLS clsHWLS, GraphVariables.clsLoop clsLoop, int workLoop, GraphVariables.clsSESE clsSESE, int workSESE) { Initialize_All(); bool existUntangle = false; //scan for all IL and analyze at the lowest lever first. graph.Network[untangleNet] = graph.Network[currentN]; gProAnalyzer.Ultilities.extendGraph.full_extentNetwork(ref graph, untangleNet, 0, 0); //now work in untangleNet gProAnalyzer.Ultilities.copyLoop.copy_Loop(ref clsLoop, workLoop, clsLoop.untangleLoop); int curDepth = clsHWLS.FBLOCK.maxDepth; do { for (int i = 0; i < clsHWLS.FBLOCK.nFBlock; i++) { if (clsHWLS.FBLOCK.FBlock[i].depth != curDepth || clsHWLS.FBLOCK.FBlock[i].nEntry == 1) { continue; //only get IL } int orgLoopIndx = clsHWLS.FBLOCK.FBlock[i].refIndex; int newLoopIndx = find_newLoopIndex(graph, untangleNet, clsLoop, workLoop, clsLoop.untangleLoop, orgLoopIndx); gProAnalyzer.Ultilities.findConcurrencyEntriesIL.check_Concurrency(ref graph, untangleNet, graph.conNet, graph.subNet, clsLoop, clsLoop.untangleLoop, newLoopIndx, ref clsSESE); //concurrency[] and concurrencyInst[] were found in clsLoop. //find CID again => int CID = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.orgCID; //we can access searchNode[] in fndConcurrencyIL to get DF => then find boundaries nodes of current IL int[] DFlow_IL_Flow = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.DFlow_IL_Flow;; int nNodeDFlow_IL = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.nNodeDFlow_IL; int[] expand_DFlow_IL_Flow = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.expand_DFlow_IL_Flow; int expand_nNodeDFlow_IL = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.expand_nNodeDFlow_IL; int[] DFlow = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.DFlow; int nDFlow = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.nDFlow; int[] expand_DFlow = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.expand_DFlow; int expand_nDFlow = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.expand_nDFlow; int[] boundaryNodes = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.boundaryNodes;//get the boundaryNode of currentN graph. int[] expand_boundaryNode = gProAnalyzer.Ultilities.findConcurrencyEntriesIL.expand_boundaryNodes; //check whether need to untangle the IL or not? => if need -> next step (Check PdFlow? also) if (!check_UntanglingIL(clsLoop, clsLoop.untangleLoop, newLoopIndx)) { continue; } graph.Network[graph.nickNet] = graph.Network[untangleNet]; gProAnalyzer.Ultilities.extendGraph.full_extentNetwork(ref graph, graph.nickNet, 0, 0); //Using NICKNET for reference of Link remove_DFlow_IL(ref graph, untangleNet, ref clsLoop, clsLoop.untangleLoop, newLoopIndx, expand_boundaryNode, CID, expand_DFlow_IL_Flow, expand_nNodeDFlow_IL); //must use expand version //Next: make_subNet of new Untangling subGraph based on concurrencyInst[] of current IL //Next: plug into original network + expand loops in DFlow (if any) - links/ edges' index should be modified also gProAnalyzer.Ultilities.makeSubNetwork.combine_subGraph_Untangling(ref graph, graph.nickNet, untangleNet, graph.conNet, graph.subNet, graph.dummyNet, clsLoop, clsLoop.untangleLoop, newLoopIndx, expand_boundaryNode, boundaryNodes, CID); //using subNet as referrence (also //Using NICKNET for reference of Link) //return true; //final step => polishing the subgraph by removing some unnecessary node (gateways only have 1 incoming/ outgoing edge?) //remove disconnected nodes (~ mark Done = true) removing_disconnectedNode(ref graph, untangleNet); existUntangle = true; //At least done 1 untangle of 1 IL //return true;; for (int k = 0; k < graph.Network[untangleNet].nNode; k++) { gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, untangleNet, k); } gProAnalyzer.Functionalities.NodeSplittingType1.Run_Split_Type1(ref graph, graph.untangleNet, graph.midNet); gProAnalyzer.Functionalities.LoopIdentification.Run_FindLoop(ref graph, graph.midNet, ref clsLoop, clsLoop.untangleLoop, ref clsLoop.IrreducibleError); gProAnalyzer.Functionalities.NodeSplittingType2.Run_Split_Type2(ref graph, untangleNet, graph.untangleNet, ref clsLoop, clsLoop.untangleLoop); } curDepth--; } while (curDepth > 0); //find PRE/POST DOM/ PDOM + LOOP + SESE + Node splitting again for (int i = 0; i < graph.Network[untangleNet].nNode; i++) { gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, untangleNet, i); } return(existUntangle); }
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); }