Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        public static void testGreedy(String filename, PrioAlg prioalg)
        {
            String outputfile;
            Console.WriteLine("processing " + filename + "...");

            //Greedy Algorithm
            a = createMGraph(filename, prioalg);     //从文件读入数据

            if (a.prioAlg == PrioAlg.orig)
                outputfile = "GreedyOrig.txt";
            else
                outputfile = "GreedyAdv.txt";

            FileStream fs = new FileStream(outputfile, FileMode.Append);
            StreamWriter sw = new StreamWriter(fs);

            //测试RTM solution是否schedulable
            Console.WriteLine("测试RTM solution是否schedulable");
            a.mgrpahSetRTMBuffer();
            a.mgraphSetPrio();      //计算优先级
            a.mgraphResponseTime();     //计算resopnse time
            a.mgraphCalcLateness();     //计算lateness
            if (!a.mgraphSchedulable())
            {
                Console.WriteLine("Not schedulable, unable to perform mapping.");
                Console.ReadKey();
                return;
            }
            else
            {
                Console.WriteLine("RTM solution schedulable.");
            }

            //testPrintBuffer(a);
            //testPrintLateness(a);
            Console.WriteLine("RTM buffers = " + countBuffer(a));
            sw.WriteLine(filename);
            sw.WriteLine("RTM buffer: " + countBuffer(a));
            //Console.ReadKey();

            //计算Greedy Algorithm中得到的buffers上界
            Console.WriteLine("计算Greedy Algorithm中得到的buffers上界");
            a.mgrpahSetNoType2Buffer(); //不加type 2 buffer
            a.mgraphSetPrio();      //计算优先级
            a.mgraphResponseTime();     //计算resopnse time
            a.mgraphCalcLateness();     //计算lateness
            Console.WriteLine(GreedyTaskMapping());

            Console.WriteLine("Greedy buffers = " + countBuffer(a));
            sw.WriteLine("Greedy buffer: " + countBuffer(a));
            a.maxBuff = a.minBuff = countBuffer(a);

            sw.Flush();
            fs.Close();
        }