コード例 #1
0
ファイル: Program.cs プロジェクト: chickensoup/BFO
        public static void BBSearch()
        {
            Console.WriteLine("BBSearch begins.");
            // Console.ReadKey();

            a.mgrpahSetNoType2Buffer(); //初始化设置,只设置全部的type 1 buffer但是不设置type 2 buffer
            a.mgraphSetPrio();      //计算优先级
            a.mgraphResponseTime();     //计算resopnse time
            a.mgraphCalcLateness();     //计算lateness

            a.LSlist = new ArrayList();
            for (int i = 0; i < a.mgraphVexnum; i++)
            {
                for (int j = 0; j < a.mgraphVexnum; j++)
                {
                    if (a.arcs[i, j].arcAdj == 1 && a.arcs[i, j].arcBuf == 0)
                    {
                        LS lst = new LS(i, j, a);
                        a.LSlist.Add(lst);
                    }
                }
            }

            buffcostCompare bcc = new buffcostCompare();
            a.LSlist.Sort(bcc);

            VisitTree(a);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: chickensoup/BFO
        /// <summary>
        /// 复制一个MGraph
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static MGraph copyMGraph(MGraph s)
        {
            int vexnum = s.mgraphVexnum;
            int arcnum = s.mgraphArcnum;
            MGraph b = new MGraph(s.mgraphVexnum, s.mgraphArcnum);
            for (int i = 0; i < vexnum; i++)
            {
                b.mgraphSetPointArgs(i, s.vexs[i].pointPeriod, s.vexs[i].pointComptime);

                for (int j = 0; j < vexnum; j++)
                {
                    b.arcs[i, j] = new ArcCell(s.arcs[i, j].arcAdj, s.arcs[i, j].arcBuf, s.arcs[i, j].arcAdjCount);
                }
            }

            b.LSlist = new ArrayList();
            for (int i = 0; i < s.LSlist.Count; i++)
            {
                LS t = (LS)s.LSlist[i];
                LS sp = new LS(t.src, t.des, t.buffcount);
                b.LSlist.Add(sp);
            }

            b.maxBuff = s.maxBuff;
            b.minBuff = s.minBuff;
            b.prioAlg = s.prioAlg;

            return b;
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: chickensoup/BFO
        public static void VisitTree(MGraph s)
        {
            searchNode++;

            s.mgraphSetPrio();
            s.mgraphResponseTime();
            s.mgraphCalcLateness();

            if (s.mgraphSchedulable())
            {
                //TODO
                //LocalOptEvaluate();

                int currentBuff = countBuffer(s);
                if (currentBuff > s.maxBuff)
                    return;
                else if (currentBuff <= s.minBuff)
                {
                    s.minBuff = currentBuff;
                    a = copyMGraph(s);
                }
            }

            if (s.LSlist.Count != 0)
            {
                for (int i = 0; i < s.LSlist.Count; i++)
                {
                    MGraph t2 = copyMGraph(s);

                    LS t1 = (LS)t2.LSlist[i];
                    LS sp = new LS(t1.src, t1.des, t1.buffcount);

                    t2.arcs[sp.src, sp.des].arcBuf = 2;
                    t2.arcs[sp.des, sp.src].arcBuf = 2;

                    t2.LSlist.RemoveAt(i);
                    VisitTree(t2);
                }
            }
        }