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(); }
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 = $"Host Selection Policy"; 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(AuctionTypes.MostFull.ToString(), new PointPairList()); all.Add(AuctionTypes.LeastFull.ToString(), new PointPairList()); all.Add(AuctionTypes.Random.ToString(), new PointPairList()); all.Add(AuctionTypes.LeastPulls.ToString(), new PointPairList()); foreach (var trial in trials) { var st = (AuctionTypes)Enum.Parse(typeof(AuctionTypes), trial.PushAuctionType); //trials.Single( // x => x.Size == trial.Size && x.Algorithm == Strategies.InOrderProping.ToString()); var k = st.ToString(); int tested = trial.TestedPercent; switch (yAxis) { case FinalItems.Hosts: all[k].Add(tested, trial.Hosts); //all[k].Add(trial.Tested, trial.Hosts); myPane.YAxis.Title.Text = "Number Of Used Hosts"; break; case FinalItems.RMSE: all[k].Add(tested, 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(tested, trial.RMSE / rmseMaxtrial.RMSE); myPane.YAxis.Title.Text = "RMSE Ratio"; break; case FinalItems.Power: all[k].Add(tested, trial.Power); myPane.YAxis.Title.Text = "Power Consumption"; break; //case DrawItems.StdDev: // all[st].Add(trial.Size, trial.StdDev); // break; case FinalItems.Average_Entropy: all[k].Add(tested, 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(tested, trial.AverageEntropy / AEMaxtrial.AverageEntropy); myPane.YAxis.Title.Text = "Average Entropy Ratio"; break; case FinalItems.Final_Entropy: all[k].Add(tested, trial.FinalEntropy); myPane.YAxis.Scale.Min = 0.99; myPane.YAxis.Scale.Max = 1.01; break; case FinalItems.Migrations: all[k].Add(tested, trial.Migrations); myPane.YAxis.Title.Text = "Migrations Count Ratio"; break; case FinalItems.SLA_Violations_Count: all[k].Add(tested, trial.SlaViolations); break; case FinalItems.SLA_Violations_Percent: all[k].Add(tested, trial.SlaViolationsPercent); break; case FinalItems.Messages: myPane.YAxis.Title.Text = "Message Count"; all[k].Add(tested, trial.TotalMessages); break; case FinalItems.Total_Image_Pulls: all[k].Add(tested, trial.ImagePullsTotal); myPane.YAxis.Title.Text = "Total Image Pulls"; break; case FinalItems.Average_Pulls_PerImage: all[k].Add(tested, trial.ImagePullsRatio); myPane.YAxis.Title.Text = "Average Pulls PerImage"; break; case FinalItems.Containers_Average: all[k].Add(tested, trial.ContainersAverage); myPane.YAxis.Title.Text = "Containers Average"; break; case FinalItems.Average_Down_Time: all[k].Add(tested, trial.AverageDownTime); myPane.YAxis.Title.Text = "Average DownTime"; break; case FinalItems.Container_Density: all[k].Add(tested, trial.AverageContainerPerHost); break; default: throw new ArgumentOutOfRangeException(nameof(yAxis), yAxis, null); } } foreach (var a in all) { var st = (AuctionTypes)Enum.Parse(typeof(AuctionTypes), a.Key); myPane.AddBar(a.Key, null, a.Value.Select(x => x.Y).ToArray(), GetColor(st)); } myPane.XAxis.MajorTic.IsBetweenLabels = true; myPane.XAxis.Scale.TextLabels = trials.Select(x => x.TestedPercent.ToString()).Distinct().ToArray(); myPane.XAxis.Type = AxisType.Text; // Tell ZedGraph to reconfigure the // axes since the data have changed zgc.AxisChange(); zgc.Refresh(); }