public string CalculateDelta(LoopData ld, List <Path> paths) { string delta = " 1 "; for (int i = 1; i < ld.Size; i++) { if (i % 2 != 0) { delta += "- ( "; } else { delta += "+ ( "; } foreach (List <List <Node> > lln in ld.getNonTouching(i)) { foreach (List <Node> loop in lln) { delta += CalculateGain(NodesToEdges(loop, paths)); } delta += " + "; } if (delta.EndsWith(" + ")) { ; } delta = delta.Substring(0, delta.Length - 3); delta += " ) "; } return(delta); }
public void CalculateNonTouching(LoopData loopData) { int max = loopData.Size; for (int i = 2; i < max; i++) { int asd = loopData.getNonTouching(i - 1).Count; for (int j = 0; j < loopData.getNonTouching(i - 1).Count; j++) { List <List <Node> > temploops = new List <List <Node> >(); loopsHash.Clear(); foreach (List <Node> loop in loopData.getNonTouchingat(i - 1, j)) { temploops.Add(loop); foreach (Node n in loop) { if (!loopsHash.ContainsKey(n.Name)) { loopsHash.Add(n.Name, n); } } } int k = 0; if (i == 2) { k = j + 1; } List <List <Node> > cachedloop = new List <List <Node> >(); foreach (List <Node> loop in temploops) { cachedloop.Add(loop); } for (; k < loopData.getNonTouching(1).Count; k++) { if (IsNonTouching(loopsHash, loopData.getLoop(i - 1, k, 0))) { temploops.Add(loopData.getLoop(i - 1, k, 0)); loopData.addNonTouching(i, temploops); } if (temploops.Count == i) { temploops = new List <List <Node> >(); foreach (List <Node> loop in cachedloop) { temploops.Add(loop); } } } } } removeDuplicates(loopData); }
public void removeDuplicates(LoopData ld) { int max = ld.Size; for (int i = 3; i < max; i++) { for (int j = 0; j < ld.getNonTouching(i).Count; j++) { for (int k = j + 1; k < ld.getNonTouching(i).Count; k++) { if (similarListLopps(ld.getNonTouchingat(i, j), ld.getNonTouchingat(i, k))) { ld.getNonTouching(i).RemoveAt(k); k--; } } } } }
private void SolveBtn_Click(object sender, EventArgs e) { List <List <Node> > fpaths = gh.CalculatePath(start, end); List <List <Node> > loops = gh.CalculateLoops(nodes); PrintPaths(fpaths); printLoops(loops); LoopData ld = new LoopData(loops); gh.CalculateNonTouching(ld); List <string> allS = ld.printAll(); foreach (string s in allS) { loopsList.Items.Add(s); } string tf = gh.CalculateTransferFunction(ld, paths, fpaths); TFText.AppendText(tf); }
public string CalculateTransferFunction(LoopData ld, List <Path> paths, List <List <Node> > fpaths) { string tf = ""; foreach (List <Node> path in fpaths) { tf += CalculateGain(NodesToEdges(path, paths)); tf += " ( 1 "; for (int i = 1; i < ld.Size; i++) { string temp = ""; foreach (List <List <Node> > lln in ld.getNonTouching(i)) { int count = 0; bool flag = true; foreach (List <Node> loop in lln) { if (IsNonTouching(path, loop)) { if (flag) { if (i % 2 != 0) { temp += "- ( "; } else { temp += "+ ( "; } flag = false; } temp += CalculateGain(NodesToEdges(loop, paths)); count++; } } if (count == i) { tf += temp; temp = ""; } else { temp = ""; } } //tf = tf.Substring(0, tf.Length - 3); tf += " ) "; } tf += " + "; } if (tf.EndsWith(" + ")) { ; } tf = tf.Substring(0, tf.Length - 2); tf += "\n"; tf += "_______________________________________________________________________\n"; tf += " ( "; tf += CalculateDelta(ld, paths); tf += " ) "; return(tf); }