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(); }
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); }
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)); }
public static IScheduler GetScheduler(String schedulerName, ProblemSetting ps) { // get the type of the interface var type = typeof(IScheduler); // query all the classes that implement IMyInterface in current assembly // startTime.IsClass is very important, otherwise you will get more interface types // that inherited IMyInterface, include IMyInterface itself var q = from t in Assembly.GetExecutingAssembly().GetTypes() where t.IsClass && type.IsAssignableFrom(t) select t; // convert the query result to list (List<type>) var classes = q.ToList(); // find the one we need // var myClass = classes.FirstOrDefault(c => c.Name.ToLower().Contains(arrivalType.ToString().ToLower())); var myClass = classes.FirstOrDefault(c => { return c.Name.ToLower().Equals((schedulerName + "Scheduler").ToLower()); }); // create an instance from a type var instance = (IScheduler)Activator.CreateInstance(myClass, ps); // return the created instance return instance; }
public static IScheduler GetScheduler(String schedulerName, ProblemSetting ps) { // get the type of the interface var type = typeof(IScheduler); // query all the classes that implement IMyInterface in current assembly // startTime.IsClass is very important, otherwise you will get more interface types // that inherited IMyInterface, include IMyInterface itself var q = from t in Assembly.GetExecutingAssembly().GetTypes() where t.IsClass && type.IsAssignableFrom(t) select t; // convert the query result to list (List<type>) var classes = q.ToList(); // find the one we need // var myClass = classes.FirstOrDefault(c => c.Name.ToLower().Contains(arrivalType.ToString().ToLower())); var myClass = classes.FirstOrDefault(c => { return(c.Name.ToLower().Equals((schedulerName + "Scheduler").ToLower())); }); // create an instance from a type var instance = (IScheduler)Activator.CreateInstance(myClass, ps); // return the created instance return(instance); }
public BestFitScheduler(ProblemSetting ps) : base(ps) { this.SchedulerType = SchedulerType.BestFit; }
public BestFitScheduler(ProblemSetting ps) : base(ps) { this.SchedulerType = SchedulerType.BestFit; }