private int calculateCountFromPercent(int count, TestedHosts testedHosts) { double newC; newC = ((int)testedHosts) / 100.0 * count; return((int)Math.Ceiling(newC)); }
public AuctionManagement(NetworkInterfaceCard communicationModule, IMachinePowerController powerController, UtilizationTable holder, TestedHosts testedHosts) : base(communicationModule, powerController, holder) { TestedHostsCount = testedHosts; }
public RunConfiguration(SimulationSize simulationSize, StartUtilizationPercent startPercent, LoadChangeAction changeAction, LoadPrediction loadPrediction, Strategies strategy, AuctionTypes pushAuctionType, AuctionTypes pullAuctionType, SchedulingAlgorithm schedulingAlgorithm, TestedHosts testedHosts, ContainersType containersType, bool networkDealy, int trialId) { LoadPrediction = loadPrediction; SimulationSize = simulationSize; StartPercent = startPercent; Strategy = strategy; PushAuctionType = pushAuctionType; PullAuctionType = pullAuctionType; SchedulingAlgorithm = schedulingAlgorithm; ChangeAction = changeAction; TestedHosts = testedHosts; ContainersType = containersType; NetworkDealy = networkDealy; TrialId = trialId; }
public MasterMachine(NetworkSwitch networkSwitch, IMachinePowerController powerController, UtilizationTable holder, Strategies strategy, AuctionTypes pushAuctionType, AuctionTypes pullAuctionType, SchedulingAlgorithm scheduling, TestedHosts testedHosts) : base(0, networkSwitch) { switch (strategy) { case Strategies.WAshraf2017Auction: _handler = new AuctionManagement(CommunicationModule, powerController, holder, testedHosts); break; case Strategies.WAshraf2017: _handler = new InorderPropingManagement(CommunicationModule, powerController, holder); break; case Strategies.Zhao: _handler = new NoMasterHandlerModule(CommunicationModule); break; case Strategies.ForsmanPush: _handler = new NoMasterHandlerModule(CommunicationModule); break; case Strategies.ForsmanPull: _handler = new NoMasterHandlerModule(CommunicationModule); break; case Strategies.Proposed2018: _handler = new ProposedMasterHandler(CommunicationModule, powerController, holder, testedHosts, pushAuctionType, pullAuctionType); break; default: throw new ArgumentOutOfRangeException(nameof(strategy), strategy, null); } Holder = holder; //StartMachine(); switch (scheduling) { case SchedulingAlgorithm.FF: scheduler = new FirstFitScheduler(holder, CommunicationModule, powerController); break; case SchedulingAlgorithm.MFull: case SchedulingAlgorithm.LFull: scheduler = new AuctionScheduler(holder, CommunicationModule, powerController, scheduling); break; default: throw new ArgumentOutOfRangeException(nameof(scheduling), scheduling, null); } }
public ProposedMasterHandler(NetworkInterfaceCard communicationModule, IMachinePowerController powerController, UtilizationTable dataHolder, TestedHosts testedHosts, AuctionTypes pushAuctionType, AuctionTypes pullAuctionType) : base(communicationModule) { PowerController = powerController; DataHolder = dataHolder; TestedHostsCount = testedHosts; PushAuctionType = pushAuctionType; PullAuctionType = pullAuctionType; }
public MasterFactory(NetworkSwitch networkSwitchObject, MachineController machineControllerObject, UtilizationTable utilizationTable, Strategies currentStrategy, AuctionTypes pushAuctionType, AuctionTypes pullAuctionType, SchedulingAlgorithm schedulingAlgorithm, TestedHosts testedHostsCount) : base(networkSwitchObject) { this.networkSwitchObject = networkSwitchObject; this.machineControllerObject = machineControllerObject; this.utilizationTable = utilizationTable; this.currentStrategy = currentStrategy; PushAuctionType = pushAuctionType; PullAuctionType = pullAuctionType; this.schedulingAlgorithm = schedulingAlgorithm; this.testedHostsCount = testedHostsCount; }
private DashStyle GetDash(Strategies key, TestedHosts tested) { switch (key) { case Strategies.Proposed2018: return(DashStyle.Solid); case Strategies.WAshraf2017: return(DashStyle.Solid); case Strategies.Zhao: return(DashStyle.Dash); case Strategies.ForsmanPush: return(DashStyle.Dot); case Strategies.ForsmanPull: return(DashStyle.DashDotDot); default: throw new ArgumentOutOfRangeException(nameof(key), key, null); } }
private Color GetColor(Strategies key, TestedHosts tested) { switch (key) { case Strategies.Proposed2018: switch (tested) { case TestedHosts.TwentyFive: return(Color.Indigo); case TestedHosts.Fifty: return(Color.CadetBlue); case TestedHosts.Hundred: return(Color.DarkViolet); default: throw new NotImplementedException(); } case Strategies.WAshraf2017: return(Color.Red); case Strategies.Zhao: return(Color.Blue); case Strategies.ForsmanPush: return(Color.Green); case Strategies.ForsmanPull: return(Color.Black); default: throw new ArgumentOutOfRangeException(nameof(key), key, null); } }
private void CreateGraph(ZedGraphControl zgc, FinalItems yAxis, List <TrialResult> trials) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); myPane.YAxis.Scale.MinAuto = true; myPane.YAxis.Scale.MaxAuto = true; // Set the Titles myPane.Title.Text = yAxis.ToString().Replace('_', ' '); myPane.XAxis.Title.Text = $"Number of Hosts (N)"; myPane.YAxis.Title.Text = yAxis.ToString().Replace('_', ' '); Dictionary <string, PointPairList> all = new Dictionary <string, PointPairList>(); //all.Add(Strategies.Proposed2018+"_"+1, new PointPairList()); //all.Add(Strategies.Proposed2018 + "_" + 5, new PointPairList()); //all.Add(Strategies.Proposed2018 + "_" + 10, new PointPairList()); //all.Add(Strategies.Proposed2018 + "_" + 20, new PointPairList()); all.Add(Strategies.WAshraf2017.ToString(), new PointPairList()); all.Add(Strategies.Zhao.ToString(), new PointPairList()); all.Add(Strategies.ForsmanPush.ToString(), new PointPairList()); all.Add(Strategies.ForsmanPull.ToString(), new PointPairList()); foreach (var trial in trials) { var st = (Strategies)Enum.Parse(typeof(Strategies), trial.Algorithm); //trials.Single( // x => x.Size == trial.Size && x.Algorithm == Strategies.InOrderProping.ToString()); var k = st == Strategies.Proposed2018 ? Strategies.Proposed2018 + "_" + trial.TestedPercent : st.ToString(); switch (yAxis) { case FinalItems.Hosts: all[k].Add(trial.Size, trial.Hosts); myPane.YAxis.Title.Text = "Number Of Used Hosts"; break; case FinalItems.RMSE: all[k].Add(trial.Size, trial.RMSE); myPane.YAxis.Title.Text = "RMSE"; break; case FinalItems.RMSE_Ratio: var rmseval = trials.Where(x => x.Size == trial.Size && x.Change == trial.Change).Max(x => x.RMSE); var rmseMaxtrial = trials.First(x => x.Size == trial.Size && x.Change == trial.Change && x.RMSE == rmseval); all[k].Add(trial.Size, trial.RMSE / rmseMaxtrial.RMSE); myPane.YAxis.Title.Text = "RMSE Ratio"; break; case FinalItems.Power: var val = trials.Where(x => x.Size == trial.Size && x.Change == trial.Change).Max(x => x.Power); var mtrial = trials.Single(x => x.Size == trial.Size && x.Change == trial.Change && x.Power == val); all[k].Add(trial.Size, trial.Power / mtrial.Power); myPane.YAxis.Title.Text = "Power Consumption Ratio"; break; //case DrawItems.StdDev: // all[st].Add(trial.Size, trial.StdDev); // break; case FinalItems.Average_Entropy: all[k].Add(trial.Size, trial.AverageEntropy); myPane.YAxis.Scale.Min = 0.99; myPane.YAxis.Scale.Max = 1.01; break; case FinalItems.Average_Entropy_Ratio: var AEval = trials.Where(x => x.Size == trial.Size && x.Change == trial.Change).Max(x => x.AverageEntropy); var AEMaxtrial = trials.First(x => x.Size == trial.Size && x.Change == trial.Change && x.AverageEntropy == AEval); all[k].Add(trial.Size, trial.AverageEntropy / AEMaxtrial.AverageEntropy); myPane.YAxis.Title.Text = "Average Entropy Ratio"; break; case FinalItems.Final_Entropy: all[k].Add(trial.Size, trial.FinalEntropy); myPane.YAxis.Scale.Min = 0.99; myPane.YAxis.Scale.Max = 1.01; break; case FinalItems.Migrations: val = trials.Where(x => x.Size == trial.Size && x.Change == trial.Change).Max(x => x.Migrations); mtrial = trials.First(x => x.Size == trial.Size && x.Change == trial.Change && x.Migrations == val); all[k].Add(trial.Size, trial.Migrations / mtrial.Migrations); myPane.YAxis.Title.Text = "Migrations Count Ratio"; break; case FinalItems.SLA_Violations_Count: all[k].Add(trial.Size, trial.SlaViolations); break; case FinalItems.SLA_Violations_Percent: all[k].Add(trial.Size, trial.SlaViolationsPercent); break; case FinalItems.Messages: val = trials.Where(x => x.Size == trial.Size && x.Change == trial.Change).Max(x => x.TotalMessages); mtrial = trials.Single(x => x.Size == trial.Size && x.Change == trial.Change && x.TotalMessages == val); myPane.YAxis.Title.Text = "Message Count Ratio"; all[k].Add(trial.Size, trial.TotalMessages / mtrial.TotalMessages); break; case FinalItems.Total_Image_Pulls: all[k].Add(trial.Size, trial.ImagePullsTotal); myPane.YAxis.Title.Text = "Total Image Pulls"; break; case FinalItems.Average_Down_Time: all[k].Add(trial.Size, trial.AverageDownTime); myPane.YAxis.Title.Text = "Average Downtime"; break; case FinalItems.Average_Pulls_PerImage: all[k].Add(trial.Size, trial.ImagePullsRatio); myPane.YAxis.Title.Text = "Average Pulls PerImage"; break; case FinalItems.Containers_Average: all[k].Add(trial.Size, trial.ContainersAverage); myPane.YAxis.Title.Text = "Containers Average"; break; default: throw new ArgumentOutOfRangeException(nameof(yAxis), yAxis, null); } } float d = 0; foreach (var a in all) { var st = (Strategies)Enum.Parse(typeof(Strategies), a.Key.Split('_')[0]); TestedHosts t = TestedHosts.Hundred; if (st == Strategies.Proposed2018) { t = (TestedHosts)int.Parse(a.Key.Split('_')[1]); } LineItem l = new LineItem (a.Key == "WAshraf2017" ? "Proposed Algorithm" : a.Key.ToString(), a.Value, GetColor(st, t), SymbolType.Square, 3); l.Symbol.Size = 5; l.Symbol.Fill = new Fill(GetColor(st, t)); l.Line.Style = GetDash(st, t); //l.Line.DashOn = d; //l.Line.DashOff = d*2; d++; myPane.CurveList.Add(l); } myPane.Legend.Position = LegendPos.BottomCenter; //myPane.Chart.Fill = new Fill(Color.White, Color.LightCyan, 360.0f); if (yAxis == FinalItems.Messages || yAxis == FinalItems.Power || yAxis == FinalItems.Migrations || yAxis == FinalItems.RMSE_Ratio || yAxis == FinalItems.Average_Entropy_Ratio) { myPane.YAxis.Scale.Format = "#.### %"; } else { myPane.YAxis.Scale.Format = ""; } // Tell ZedGraph to reconfigure the // axes since the data have changed zgc.AxisChange(); zgc.Refresh(); }
public MeasureValueHolder ReadDataFromDisk(string mainFile) { var config = mainFile.Split('\\'); SimulationSize simulationSize = (SimulationSize)Convert.ToInt32(config[3]); StartUtilizationPercent perecent = (StartUtilizationPercent)Enum.Parse(typeof(StartUtilizationPercent), config[4].Split('_')[0]); LoadChangeAction changeAction = (LoadChangeAction)Enum.Parse(typeof(LoadChangeAction), config[4].Split('_')[1]); LoadPrediction loadPrediction = (LoadPrediction)Enum.Parse(typeof(LoadPrediction), config[5]); SchedulingAlgorithm schedulingAlgorithm = (SchedulingAlgorithm)Enum.Parse(typeof(SchedulingAlgorithm), config[6]); Strategies strategy = (Strategies)Enum.Parse(typeof(Strategies), config[7].Split('_')[0]); ContainersType containerType = (ContainersType)Enum.Parse(typeof(ContainersType), config[7].Split('_')[1]); AuctionTypes pushAuctionType = (AuctionTypes)Enum.Parse(typeof(AuctionTypes), config[8].Split('_')[0]); AuctionTypes pullAuctionType = (AuctionTypes)Enum.Parse(typeof(AuctionTypes), config[8].Split('_')[1]); TestedHosts testedHosts = (TestedHosts)Enum.Parse(typeof(TestedHosts), config[9]); bool delay = bool.Parse(config[10]); int TrialId = int.Parse(config[11]); var conf = new RunConfiguration(simulationSize, perecent, changeAction, loadPrediction, strategy, pushAuctionType, pullAuctionType, schedulingAlgorithm, testedHosts, containerType, delay, TrialId); MeasureValueHolder holder = new MeasureValueHolder(conf); using (StreamReader reader = new StreamReader(mainFile)) { reader.ReadLine(); while (!reader.EndOfStream) { var line = reader.ReadLine().Split(','); int i = Convert.ToInt32(line[0]); double entropy = Convert.ToDouble(line[1]); double predictedEntropy = Convert.ToDouble(line[2]); double avgRealVolume = Convert.ToDouble(line[3]); double avgPredictedVolume = Convert.ToDouble(line[4]); double idealHostCount = Convert.ToDouble(line[5]); double noHosts = Convert.ToDouble(line[6]); double underHosts = Convert.ToDouble(line[7]); double overHosts = Convert.ToDouble(line[8]); double normalHosts = Convert.ToDouble(line[9]); double evacuatingHosts = Convert.ToDouble(line[10]); double migrations = Convert.ToDouble(line[11]); double pushRequests = Convert.ToDouble(line[12]); double pushLoadAvailabilityRequest = Convert.ToDouble(line[13]); double pullRequests = Convert.ToDouble(line[14]); double pullLoadAvailabilityRequest = Convert.ToDouble(line[15]); double totalMessages = Convert.ToDouble(line[16]); double slaViolationsCount = Convert.ToDouble(line[17]); double slaViolationsPercent = Convert.ToDouble(line[18]); double minNeeded = Convert.ToDouble(line[19]); double maxNeeded = Convert.ToDouble(line[20]); double power = Convert.ToDouble(line[21]); double stdDev = Convert.ToDouble(line[22]); double imagePulls = Convert.ToDouble(line[23]); double communicatedSize = Convert.ToDouble(line[24]); MeasuresValues m = new MeasuresValues(pushRequests, pullRequests, idealHostCount, noHosts, migrations, totalMessages, entropy, predictedEntropy, pushLoadAvailabilityRequest, pullLoadAvailabilityRequest, avgRealVolume, avgPredictedVolume, minNeeded, maxNeeded, underHosts, overHosts, normalHosts, evacuatingHosts, slaViolationsCount, slaViolationsPercent, power, stdDev, imagePulls, communicatedSize); holder.MeasuredValuesList.Add(m); } } var nfile = mainFile.Replace("All", "ConMig"); using (StreamReader reader = new StreamReader(new FileStream(nfile, FileMode.Open))) { reader.ReadLine(); while (!reader.EndOfStream) { var line = reader.ReadLine().Split(','); int conId = Convert.ToInt32(line[0]); double count = Convert.ToDouble(line[1]); double time = Convert.ToDouble(line[2]); holder.ContainerMeasureValuesList.Add(conId, new ContainerMeasureValue(conId, count, time)); } } nfile = mainFile.Replace("All", "Hosts"); using (StreamReader reader = new StreamReader(new FileStream(nfile, FileMode.Open))) { List <HostLoadInfo> list = new List <HostLoadInfo>(); int current = 0; reader.ReadLine(); while (!reader.EndOfStream) { //iteration,Id,cpu,mem,io,concount,cpuutil,memutil,ioutil, var line = reader.ReadLine().Split(','); int it = Convert.ToInt32(line[0]); int hostId = Convert.ToInt32(line[1]); double cpu = Convert.ToDouble(line[2]); double mem = Convert.ToDouble(line[3]); double io = Convert.ToDouble(line[4]); int concount = Convert.ToInt32(line[5]); double cpuutil = Convert.ToDouble(line[6]); double memutil = Convert.ToDouble(line[7]); double ioutil = Convert.ToDouble(line[8]); double dataSizeOut = Convert.ToDouble(line[9]); double dataSizeIn = Convert.ToDouble(line[10]); var linfo = new HostLoadInfo(hostId, new Load(cpu, mem, io), concount, cpuutil, memutil, ioutil, dataSizeOut, dataSizeIn); if (it == current) { list.Add(linfo); } else { holder.HostMeasureValuesList.Add(new HostMeasureValues(list)); list.Clear(); list.Add(linfo); current++; } } } if (containerType == ContainersType.D) { nfile = mainFile.Replace("All", "PullsPerImage"); using (StreamReader reader = new StreamReader(new FileStream(nfile, FileMode.Open))) { reader.ReadLine(); while (!reader.EndOfStream) { var line = reader.ReadLine().Split(','); int ImageId = Convert.ToInt32(line[0]); int Pulls = Convert.ToInt32(line[1]); holder.PullsPerImage.Add(ImageId, Pulls); } } } return(holder); }
private void CreateGraph(ZedGraphControl zgc, List <TrialResult> mainTrials) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); myPane.YAxis.Scale.MinAuto = true; myPane.YAxis.Scale.MaxAuto = true; // Set the Titles myPane.Title.Text = "DBE"; myPane.XAxis.Title.Text = $"Algorithms"; myPane.YAxis.Title.Text = "DBE"; Dictionary <string, DictionaryHolder> all = new Dictionary <string, DictionaryHolder>(); foreach (var trial in mainTrials) { var trials = mainTrials.Where(x => x.Size == trial.Size && x.StartUtil == trial.StartUtil && x.Change == trial.Change); var maxDBE = new DBEHolder { Power = trials.Max(x => x.Power), Hosts = trials.Max(x => x.Hosts), RMSE = trials.Max(x => x.RMSE), Migrations = trials.Max(x => x.Migrations), Messages = trials.Max(x => x.TotalMessages), Entropy = trials.Max(x => x.AverageEntropy), SLA = trials.Max(x => x.SlaViolations), }; var currentDBE = new DBEHolder { Power = trial.Power, Hosts = trial.Hosts, RMSE = trial.RMSE, Migrations = trial.Migrations, Messages = trial.TotalMessages, Entropy = trial.AverageEntropy, SLA = trial.SlaViolations, }; var result = DBEHolder.GetDBE(currentDBE, maxDBE); if (!all.ContainsKey(trial.Algorithm)) { all.Add(trial.Algorithm, new DictionaryHolder { Count = 1, Total = result }); } else { all[trial.Algorithm].Count++; all[trial.Algorithm].Total += result; } } var list = from row in all select new { Algorithm = row.Key, DBE = (row.Value.Total / row.Value.Count).ToString("#.###") }; dataGridView1.DataSource = list.ToArray(); foreach (var a in all) { var st = (Strategies)Enum.Parse(typeof(Strategies), a.Key.Split('_')[0]); TestedHosts t = TestedHosts.Hundred; myPane.AddBar(a.Key == "WAshraf2017" ? "Proposed Algorithm" : a.Key.ToString() , new PointPairList() { new PointPair(0, a.Value.Total / a.Value.Count) }, GetColor(st, t)); } myPane.Legend.Position = LegendPos.BottomCenter; //myPane.YAxis.Scale.Format = "#.### %"; myPane.XAxis.Type = AxisType.Text; zgc.AxisChange(); zgc.Refresh(); }