private HistoryTrans FindTransN(string inNode, List <string> banTrans) { List <HistoryTrans> listHist = new List <HistoryTrans>(); foreach (string transN in graphN[inNode].arcCollection) { if (!banTrans.Exists(element => element == transN)) { string nextNode = transListN[transN].oppositePort(inNode); List <string> banNewHist = new List <string>(banTrans); banNewHist.Add(transN); HistoryTrans passedNext = FindTransN(nextNode, banNewHist); passedNext.AddTrans(transN, nextNode); listHist.Add(passedNext); } } if (listHist.Count > 0) { HistoryTrans returnHist = listHist[0]; foreach (HistoryTrans hist in listHist) { if (returnHist.countNode < hist.countNode) { returnHist = hist; } } return(returnHist); } HistoryTrans emptyHist = new Transistors.HistoryTrans(); return(emptyHist); }
public HistoryTrans(HistoryTrans inHist) { passedNodes = new List <string>(inHist.passedNodes); passedTrans = new List <string>(inHist.passedTrans); countNode = inHist.countNode; countPortG = inHist.countPortG; approprTrans = inHist.approprTrans; }
public void PlaceTransP() { placedTransP = new Transistors.HistoryTrans(); //HistoryTrans emptyHist = new Transistors.HistoryTrans(); HistoryTrans oneHist = new Transistors.HistoryTrans(); List <HistoryTrans> listHist = new List <Transistors.HistoryTrans>(); int currentNumberN = placedTransN.GetCountInLine(0) - 1;//passedTrans.Count - 1; List <string> banP = new List <string>(); do { listHist = new List <Transistors.HistoryTrans>(); foreach (string nodeP in graphP.Keys) { oneHist = FindTransP(nodeP, currentNumberN, banP); if (oneHist.countNode > 0) { oneHist.AddNode(nodeP); listHist.Add(oneHist); } } /*foreach (HistoryTrans histTrans in listHist) * if ( histTrans.countNode > oneHist.countNode || * (histTrans.countNode == oneHist.countNode && histTrans.countPortG > oneHist.countPortG) ) * oneHist = histTrans; */ if (listHist.Count > 0) { //allHist.AddRange(lastHist.passedTrans); oneHist = listHist[0]; foreach (HistoryTrans histTrans in listHist) { if ((histTrans.passedTrans.Count == placedTransN.GetCountInLine(currentNumberN)) && (histTrans.approprTrans > oneHist.approprTrans)) { oneHist = histTrans; } } if (placedTransP.countNode > 0) { placedTransP.passedTrans.Add(""); } placedTransP.passedTrans.AddRange(oneHist.passedTrans); placedTransP.passedNodes.AddRange(oneHist.passedNodes); placedTransP.countNode += (oneHist.countNode); placedTransP.countPortG += (oneHist.countPortG); banP.AddRange(oneHist.passedTrans); //placedTransP.countPortG += (oneHist.); currentNumberN += placedTransN.GetCountInLine(currentNumberN + 2) + 1;//oneHist.passedTrans.Count; } }while ((listHist.Count > 0) && (currentNumberN >= 0)); }
private HistoryTrans GetLastLine(HistoryTrans inHist) { int indx = inHist.passedTrans.FindLastIndex(element => element == ""); if (indx < 0) { return(inHist); } else { return(inHist.GetLastArray(indx)); } }
public void ChooseTransNSet(int inNumber) { placedTransN = histTransN[inNumber]; }
public HistoryTrans(HistoryTrans inHist) { passedNodes = new List<string>(inHist.passedNodes); passedTrans = new List<string>(inHist.passedTrans); countNode = inHist.countNode; countPortG = inHist.countPortG; approprTrans = inHist.approprTrans; }
private HistoryTrans GetLastLine(HistoryTrans inHist) { int indx = inHist.passedTrans.FindLastIndex(element => element == ""); if (indx < 0) return inHist; else return inHist.GetLastArray(indx); }
public void PlaceTransP() { placedTransP = new Transistors.HistoryTrans(); //HistoryTrans emptyHist = new Transistors.HistoryTrans(); HistoryTrans oneHist = new Transistors.HistoryTrans(); List<HistoryTrans> listHist = new List<Transistors.HistoryTrans>(); int currentNumberN = placedTransN.GetCountInLine(0) - 1;//passedTrans.Count - 1; List<string> banP = new List<string>(); do { listHist = new List<Transistors.HistoryTrans>(); foreach (string nodeP in graphP.Keys) { oneHist = FindTransP(nodeP, currentNumberN, banP); if (oneHist.countNode > 0) { oneHist.AddNode(nodeP); listHist.Add(oneHist); } } /*foreach (HistoryTrans histTrans in listHist) if ( histTrans.countNode > oneHist.countNode || (histTrans.countNode == oneHist.countNode && histTrans.countPortG > oneHist.countPortG) ) oneHist = histTrans; */ if (listHist.Count > 0) { //allHist.AddRange(lastHist.passedTrans); oneHist = listHist[0]; foreach (HistoryTrans histTrans in listHist) { if ( (histTrans.passedTrans.Count == placedTransN.GetCountInLine(currentNumberN)) && (histTrans.approprTrans > oneHist.approprTrans) ) oneHist = histTrans; } if ( placedTransP.countNode > 0 ) placedTransP.passedTrans.Add(""); placedTransP.passedTrans.AddRange(oneHist.passedTrans); placedTransP.passedNodes.AddRange(oneHist.passedNodes); placedTransP.countNode += (oneHist.countNode); placedTransP.countPortG += (oneHist.countPortG); banP.AddRange(oneHist.passedTrans); //placedTransP.countPortG += (oneHist.); currentNumberN += placedTransN.GetCountInLine(currentNumberN + 2) + 1;//oneHist.passedTrans.Count; } } while ((listHist.Count > 0) && (currentNumberN >= 0)); }
/// <summary> /// creation of list placed transistors /// </summary> public int PlaceTransN() { graphN = initNodesN(); graphP = initNodesP(); HistoryTrans oneHist = new Transistors.HistoryTrans(); //HistoryTrans allHist = new Transistors.HistoryTrans(); List<string> allHist = new List<string>(); //allHist.Add(""); bool continueFinding = true; HistoryTrans emptyTrans = new Transistors.HistoryTrans(); //HistoryTrans lastHist;// = new Transistors.HistoryTrans(); histTransN = new List<Transistors.HistoryTrans>(); do { if (histTransN.FindIndex(element => element.countPortG == transListN.Count) >= 0) continueFinding = false; if (histTransN.Count == 0) { foreach (string peakName in graphN.Keys) { oneHist = FindTransN(peakName, new List<string>()); if (oneHist.countNode > 0) { oneHist.AddNode(peakName); if (transListN.Count > oneHist.countPortG) { oneHist.passedTrans.Add(""); } histTransN.Add(oneHist); } } } else { List<HistoryTrans> addingHistN = new List<HistoryTrans>(); for (int i = 0; i < histTransN.Count; ) //(HistoryTrans histUnit in histTransN) { bool isHistUpdated = false; foreach (string peakName in graphN.Keys) { oneHist = FindTransN(peakName, histTransN[i].passedTrans); if (oneHist.countNode > 0) { HistoryTrans newHist = new HistoryTrans(histTransN[i]); newHist.AddNode(peakName); //histTransN.Add(oneHist); newHist.passedTrans.AddRange(oneHist.passedTrans); newHist.passedNodes.AddRange(oneHist.passedNodes); newHist.countNode += (oneHist.countNode); newHist.countPortG += (oneHist.countPortG); if (transListN.Count > newHist.countPortG) { newHist.passedTrans.Add(""); } addingHistN.Add(newHist); isHistUpdated = true; } } if (isHistUpdated) histTransN.RemoveAt(i); else i++; } histTransN.AddRange(addingHistN); } } while ( continueFinding ); for (int i = 0; i < histTransN.Count; ) //(HistoryTrans histUnit in histTransN) { if (histTransN[i].countPortG < transListN.Count) histTransN.RemoveAt(i); else i++; } return histTransN.Count; }
private HistoryTrans FindTransP(string inNodeP, int numberN, List <string> banTrans) { List <HistoryTrans> listHist = new List <Transistors.HistoryTrans>(); if ((numberN >= 0) && (placedTransN.passedTrans[numberN] != "")) { foreach (string trP in graphP[inNodeP].arcCollection) { if (!banTrans.Exists(element => element == trP)) { List <string> banP = new List <string>(banTrans); banP.Add(trP); string nextNodeP = transListP[trP].oppositePort(inNodeP); HistoryTrans oneHist = FindTransP(nextNodeP, numberN - 1, banP); oneHist.AddTrans(trP, nextNodeP); if ((numberN >= 0) && //(placedTransN.passedTrans[numberN] != "") && (transListN[placedTransN.passedTrans[numberN]].portG == transListP[trP].portG)) { oneHist.approprTrans += 3; } else { if ((numberN > 0) && (placedTransN.passedTrans[numberN - 1] != "") && (transListN[placedTransN.passedTrans[numberN - 1]].portG == transListP[trP].portG)) { oneHist.approprTrans++; } if (((numberN + 1) < placedTransN.countPortG) && (placedTransN.passedTrans[numberN + 1] != "") && (transListN[placedTransN.passedTrans[numberN + 1]].portG == transListP[trP].portG)) { oneHist.approprTrans++; } } if ((numberN >= 0) && (placedTransN.passedNodes[numberN] == nextNodeP)) { oneHist.approprTrans += 2; } else { if ((numberN > 0) && (placedTransN.passedNodes[numberN - 1] == nextNodeP)) { oneHist.approprTrans++; } if (((numberN + 1) < placedTransN.countNode) && (placedTransN.passedNodes[numberN + 1] == inNodeP)) //nextNodeP { oneHist.approprTrans++; } } listHist.Add(oneHist); } } } if (listHist.Count > 0) { HistoryTrans returnHist = listHist[0]; foreach (HistoryTrans hist in listHist) { if (hist.approprTrans > returnHist.approprTrans) //(returnHist.countNode < hist.countNode || // (returnHist.countNode == hist.countNode && returnHist.countPortG < hist.countPortG)) { returnHist = hist; } } return(returnHist); } HistoryTrans emptyHist = new Transistors.HistoryTrans(); return(emptyHist); //} }
/// <summary> /// creation of list placed transistors /// </summary> public int PlaceTransN() { graphN = initNodesN(); graphP = initNodesP(); HistoryTrans oneHist = new Transistors.HistoryTrans(); //HistoryTrans allHist = new Transistors.HistoryTrans(); List <string> allHist = new List <string>(); //allHist.Add(""); bool continueFinding = true; HistoryTrans emptyTrans = new Transistors.HistoryTrans(); //HistoryTrans lastHist;// = new Transistors.HistoryTrans(); histTransN = new List <Transistors.HistoryTrans>(); do { if (histTransN.FindIndex(element => element.countPortG == transListN.Count) >= 0) { continueFinding = false; } if (histTransN.Count == 0) { foreach (string peakName in graphN.Keys) { oneHist = FindTransN(peakName, new List <string>()); if (oneHist.countNode > 0) { oneHist.AddNode(peakName); if (transListN.Count > oneHist.countPortG) { oneHist.passedTrans.Add(""); } histTransN.Add(oneHist); } } } else { List <HistoryTrans> addingHistN = new List <HistoryTrans>(); for (int i = 0; i < histTransN.Count;) //(HistoryTrans histUnit in histTransN) { bool isHistUpdated = false; foreach (string peakName in graphN.Keys) { oneHist = FindTransN(peakName, histTransN[i].passedTrans); if (oneHist.countNode > 0) { HistoryTrans newHist = new HistoryTrans(histTransN[i]); newHist.AddNode(peakName); //histTransN.Add(oneHist); newHist.passedTrans.AddRange(oneHist.passedTrans); newHist.passedNodes.AddRange(oneHist.passedNodes); newHist.countNode += (oneHist.countNode); newHist.countPortG += (oneHist.countPortG); if (transListN.Count > newHist.countPortG) { newHist.passedTrans.Add(""); } addingHistN.Add(newHist); isHistUpdated = true; } } if (isHistUpdated) { histTransN.RemoveAt(i); } else { i++; } } histTransN.AddRange(addingHistN); } }while (continueFinding); for (int i = 0; i < histTransN.Count;) //(HistoryTrans histUnit in histTransN) { if (histTransN[i].countPortG < transListN.Count) { histTransN.RemoveAt(i); } else { i++; } } return(histTransN.Count); }