Example #1
0
        public static void ReadData(string path, ref ProblemSetting ps, ref List<Job> jobs)
        {
            // init ps

            //note that for brownEnergyPrice/greenEnergy list, the time index start from 1, thus need to append 0 in the head of list

            var timeslotString = ReadSingleParameterFromFile(path + "totaltimeslots.txt");
            ps.TimeSlots = Int16.Parse(timeslotString); // read from file
               // Console.WriteLine("timeSlot=" + ps.TimeSlots);

            ps.ClusterNodeNum = Int16.Parse(ReadSingleParameterFromFile(path + "vm.txt")); // read from file
            //Console.WriteLine("vm=" + ps.ClusterNodeNum);

            ps.RevenueRate = Double.Parse(ReadSingleParameterFromFile(path + "revenuerate.txt")); // read from file
               // Console.WriteLine("revenue rate=" + ps.RevenueRate);

            ps.SolarEnergyList = ReadIntListFromFile(path + "solars.txt");   // read from file
               // Console.WriteLine("solar energy length" + ps.SolarEnergyList.Count);
              //  ps.SolarEnergyList.ForEach(e => Console.Write(e + " "));
              //  Console.WriteLine();

            ps.BrownPriceList = ReadDoubleListFromFile(path + "brownPrice.txt");
               // Console.WriteLine("brown price length" + ps.BrownPriceList.Count);
              //  ps.BrownPriceList.ForEach(e => Console.Write(e + " "));
               // Console.WriteLine();

            // init ps
            jobs = ReadJobFromFile(path + "jobs.txt", ps.RevenueRate);
               // Console.WriteLine("scheduledJobs");
               // scheduledJobs.ForEach(j => Console.WriteLine(j.ArrivalTime + " " + j.Deadline + " " + j.ProcessingTime + " " + j.RequiredNodes));
        }
Example #2
0
 public Simulator(IScheduler scheduler, ProblemSetting ps, List<Job> jobs)
 {
     this.Scheduler = scheduler;
     this.PS = ps.Clone();
     this.Jobs = jobs.DeepClone();
     this.OriginPS = ps.Clone();
     this.OriginJobs = jobs.DeepClone();
 }
Example #3
0
 public SchedulerBase(ProblemSetting ps)
 {
     this.ProblemSetting = ps.Clone();
     CurrentJobList = new List<Job>();
     this.ScheduledJobList = new List<Job>();
     Cluster = new Cluster(this.ProblemSetting.TimeSlots, this.ProblemSetting.ClusterNodeNum);
     //this.Results = new Dictionary<string, List<SimulateResult>>();
 }
 public SchedulerBase(ProblemSetting ps)
 {
     this.ProblemSetting   = ps.Clone();
     CurrentJobList        = new List <Job>();
     this.ScheduledJobList = new List <Job>();
     Cluster = new Cluster(this.ProblemSetting.TimeSlots, this.ProblemSetting.ClusterNodeNum);
     //this.Results = new Dictionary<string, List<SimulateResult>>();
 }
Example #5
0
        static void RunOneSimulation(String path, string schedulerName)
        {
            var ps = new ProblemSetting();
            var jobs = new List<Job>();

            FileUtil.ReadData(path, ref ps, ref jobs);

            IScheduler scheduler = SchedulerFactory.GetScheduler(schedulerName, ps);

            var simulator = new Simulator(scheduler, ps, jobs);

            var simulationresult = simulator.Simulate();

            Console.WriteLine(simulationresult);
        }
Example #6
0
        public ProblemSetting Clone()
        {
            var ps = new ProblemSetting
            {
                //Jobs = new List<Job>(),
                TimeSlots       = this.TimeSlots,
                ClusterNodeNum  = this.ClusterNodeNum,
                RevenueRate     = this.RevenueRate,
                BrownPriceList  = this.BrownPriceList != null ? new List <double>(this.BrownPriceList) : null,
                SolarEnergyList = this.SolarEnergyList != null ? new List <int>(this.SolarEnergyList): null
            };

            //Jobs.ForEach(job =>
            //    {
            //        ps.Jobs.Add(job.DeepClone());
            //    });

            return(ps);
        }
Example #7
0
        public ProblemSetting Clone()
        {
            var ps = new ProblemSetting
            {

                //Jobs = new List<Job>(),
                TimeSlots = this.TimeSlots,
                ClusterNodeNum = this.ClusterNodeNum,
                RevenueRate = this.RevenueRate,
                BrownPriceList = this.BrownPriceList !=null ? new List<double>(this.BrownPriceList) : null,
                SolarEnergyList = this.SolarEnergyList !=null ? new List<int>(this.SolarEnergyList): null
            };

            //Jobs.ForEach(job =>
            //    {
            //        ps.Jobs.Add(job.DeepClone());
            //    });

            return ps;
        }