コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: anfrolkin/EulerMake
        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));
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: anfrolkin/EulerMake
        /// <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;
        }
コード例 #4
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);
        }