Exemplo n.º 1
0
        public static void zad1()
        {
            var result = new Tests().StartTest(100, 10, 10000, 10);

            var graph = new GraphGenerator();

            graph.AddSeries("quick", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item1.Select(x => (double)x.Key).ToList(), result.Item1.Select(x => x.Value.Item1).ToList(), Color.Red);
            graph.AddSeries("sedge", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item2.Select(x => (double)x.Key).ToList(), result.Item2.Select(x => x.Value.Item1).ToList(), Color.Blue);
            graph.AddSeries("yaro", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item3.Select(x => (double)x.Key).ToList(), result.Item3.Select(x => x.Value.Item1).ToList(), Color.Green);
            graph.SaveGraph("oczekiwana check");

            graph = new GraphGenerator();
            graph.AddSeries("quick", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item1.Select(x => (double)x.Key).ToList(), result.Item1.Select(x => x.Value.Item2).ToList(), Color.Red);
            graph.AddSeries("sedge", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item2.Select(x => (double)x.Key).ToList(), result.Item2.Select(x => x.Value.Item2).ToList(), Color.Blue);
            graph.AddSeries("yaro", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item3.Select(x => (double)x.Key).ToList(), result.Item3.Select(x => x.Value.Item2).ToList(), Color.Green);
            graph.SaveGraph("wariacja check");

            graph = new GraphGenerator();
            graph.AddSeries("quick", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item1.Select(x => (double)x.Key).ToList(), result.Item1.Select(x => x.Value.Item3).ToList(), Color.Red);
            graph.AddSeries("sedge", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item2.Select(x => (double)x.Key).ToList(), result.Item2.Select(x => x.Value.Item3).ToList(), Color.Blue);
            graph.AddSeries("yaro", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item3.Select(x => (double)x.Key).ToList(), result.Item3.Select(x => x.Value.Item3).ToList(), Color.Green);
            graph.SaveGraph("oczekiwana swap");


            graph = new GraphGenerator();
            graph.AddSeries("quick", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item1.Select(x => (double)x.Key).ToList(), result.Item1.Select(x => x.Value.Item4).ToList(), Color.Red);
            graph.AddSeries("sedge", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item2.Select(x => (double)x.Key).ToList(), result.Item2.Select(x => x.Value.Item4).ToList(), Color.Blue);
            graph.AddSeries("yaro", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item3.Select(x => (double)x.Key).ToList(), result.Item3.Select(x => x.Value.Item4).ToList(), Color.Green);
            graph.SaveGraph("wariacja swap");
        }
Exemplo n.º 2
0
        public void Testing(int count, int step, int testCount)
        {
            var result = Enumerable.Range(1, count).Select(x => GetResult(x * step, testCount)).ToList();

            var numbers = result.Select(x => x.n).ToList();

            var graph = new GraphGenerator();

            graph.AddSeries("constPoint", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.ExpectedValue.ConstPointNumber).ToList(), Color.Red);
            graph.AddSeries("Cycles", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.ExpectedValue.CyclesNumber).ToList(), Color.Blue);
            graph.AddSeries("Records", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.ExpectedValue.RecordNumber).ToList(), Color.Green);
            graph.SaveGraph("ExpectedValue " + DateTime.Now);

            graph = new GraphGenerator();
            graph.AddSeries("constPoint", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Variance.ConstPointNumber).ToList(), Color.Red);
            graph.AddSeries("Cycles", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Variance.CyclesNumber).ToList(), Color.Blue);
            graph.AddSeries("Records", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Variance.RecordNumber).ToList(), Color.Green);
            graph.SaveGraph("Variance " + DateTime.Now);

            graph = new GraphGenerator();
            graph.AddSeries("constPoint", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Kurtosis.ConstPointNumber).ToList(), Color.Red);
            graph.AddSeries("Cycles", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Kurtosis.CyclesNumber).ToList(), Color.Blue);
            graph.AddSeries("Records", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Kurtosis.RecordNumber).ToList(), Color.Green);
            graph.SaveGraph("Kurtosis " + DateTime.Now);
        }
Exemplo n.º 3
0
 public void GenerateGraphZ3(string graphName, HashGenerator hashGenerator, Dictionary <int, List <double> > dictionary)
 {
     new[] { 2, 3, 10, 20, 100, 400 }.ToList().ForEach(k =>
     {
         var result         = hashGenerator.GetForK(k, dictionary);
         var graphGenerator = new GraphGenerator();
         graphGenerator.AddSeries($"{graphName}{k}", SeriesChartType.Point, result.Select(x => (double)x.Key).ToList(), result.Select(x => x.Value / x.Key).ToList());
         graphGenerator.SaveGraph($"{graphName}_k{k}");
     });
 }
Exemplo n.º 4
0
        public static void Test(int count, int step, int testCount)
        {
            var result = Enumerable.Range(1, count).Select(x => GetTestResult(x * step, testCount)).ToList();

            var numbers = result.Select(x => x.n).ToList();

            var graph = new GraphGenerator();

            graph.AddSeries("arytmetyczna ", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Expected.Arytmetic).ToList(), Color.Red);
            graph.AddSeries("gemetryczna", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Expected.Geometric).ToList(), Color.Blue);
            graph.AddSeries("harmoniczna", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Expected.Harmonic).ToList(), Color.Green);
            graph.SaveGraph("ExpectedValue " + DateTime.Now);

            graph = new GraphGenerator();
            graph.AddSeries("arytmetyczna ", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Variance.Arytmetic).ToList(), Color.Red);
            graph.AddSeries("gemetryczna", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Variance.Geometric).ToList(), Color.Blue);
            graph.AddSeries("harmoniczna", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Variance.Harmonic).ToList(), Color.Green);
            graph.SaveGraph("Variance " + DateTime.Now);
        }
Exemplo n.º 5
0
        void Test(int t, int n, ISchedule schedule, string scheduleName)
        {
            var graph = new GraphGenerator(1000, 600);
            var Listk = new List <int> {
                10, 9, 8, 7, 6, 5
            };

            Listk = Listk.Select(x => n / x).Distinct().ToList();

            var fifol = new List <double>();
            var fwfl  = new List <double>();
            var lrul  = new List <double>();
            var lful  = new List <double>();
            var randl = new List <double>();
            var rmal  = new List <double>();

            Listk.ForEach(k =>
            {
                int fifoc, fwfc, lruc, lfuc, randc, rmac;
                fifoc = fwfc = lruc = lfuc = randc = rmac = 0;

                for (int j = 0; j < 100; j++)
                {
                    var fifo = new FIFOCache(k);
                    var fwf  = new FWFCachecs(k);
                    var lru  = new LRUCache(k);
                    var lfu  = new LFUCache(k);
                    var rand = new RandCache(k);
                    var rma  = new RMACache(k);

                    for (int i = 0; i < t; i++)
                    {
                        var x  = schedule.GetNextNumber();
                        fifoc += fifo.GetValue(x);
                        fwfc  += fwf.GetValue(x);
                        lruc  += lru.GetValue(x);
                        lfuc  += lfu.GetValue(x);
                        randc += rand.GetValue(x);
                        rmac  += rma.GetValue(x);
                    }
                }
                fifol.Add(fifoc / 100);
                fwfl.Add(fwfc / 100);
                lrul.Add(lruc / 100);
                lful.Add(lfuc / 100);
                randl.Add(randc / 100);
                rmal.Add(rmac / 100);
            });
            var kk = Listk.Select(x => (double)x).ToList();

            graph.AddSeries($"{scheduleName}_FIFO_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, fifol, Color.Red);
            graph.AddSeries($"{scheduleName}_FWF_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, fwfl, Color.Blue);
            graph.AddSeries($"{scheduleName}_LRU_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, lrul, Color.Black);
            graph.AddSeries($"{scheduleName}_LFU_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, lful, Color.Yellow);
            graph.AddSeries($"{scheduleName}_RAND_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, randl, Color.Green);
            graph.AddSeries($"{scheduleName}_RMA_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, rmal, Color.MediumPurple);

            graph.SaveGraph($"{scheduleName}_{n}_3");
        }
Exemplo n.º 6
0
        public void GenerateGraphZ5(string graphName, HashGenerator hashGenerator,
                                    Dictionary <int, List <double> > dictionary, int k)
        {
            new[] { 0.05, 0.01, 0.005 }.ToList().ForEach(prop =>
            {
                var result         = hashGenerator.GetForK(400, dictionary);
                var graphGenerator = new GraphGenerator();
                graphGenerator.AddSeries($"{graphName}{k}", SeriesChartType.Point, result.Select(x => (double)x.Key).ToList(), result.Select(x => x.Value / x.Key).ToList());
                var czyby = Czybyszew(prop, k);
                graphGenerator.AddSeries($"{graphName}Czybyszew{k}", SeriesChartType.Line, new[] { 1.0, 10000.0 }.ToList(), new[] { 1.0 - czyby, 1.0 - czyby }.ToList(), Color.Red);
                graphGenerator.AddSeries($"{graphName}Czybyszew2{k}", SeriesChartType.Line, new[] { 1.0, 10000.0 }.ToList(), new[] { 1.0 + czyby, 1.0 + czyby }.ToList(), Color.Red);
                var chern = Chernoff(k, prop);
                graphGenerator.AddSeries($"{graphName}Chernoff{k}", SeriesChartType.Line, new[] { 1.0, 10000.0 }.ToList(), new[] { 1.0 - chern, 1.0 - chern }.ToList(), Color.Yellow);
                graphGenerator.AddSeries($"{graphName}Chernoff2{k}", SeriesChartType.Line, new[] { 1.0, 10000.0 }.ToList(), new[] { 1.0 + chern, 1.0 + chern }.ToList(), Color.Yellow);

                var mid = TruePropability(result, prop);
                graphGenerator.AddSeries($"{graphName}true{k}", SeriesChartType.Line, new[] { 1.0, 10000.0 }.ToList(), new[] { 1.0 - mid, 1.0 - mid }.ToList(), Color.Green);
                graphGenerator.AddSeries($"{graphName}true2{k}", SeriesChartType.Line, new[] { 1.0, 10000.0 }.ToList(), new[] { 1.0 + mid, 1.0 + mid }.ToList(), Color.Green);


                graphGenerator.SaveGraph($"{graphName}_prop{prop}");
            });
        }
Exemplo n.º 7
0
        public void Test()
        {/*
            var result = Enumerable.Range(1, 100).Select(x =>
            {
                var g = new Chart.L2.Graph(x*10, 1.0 / (2.0 * x*10));
                var a = Enumerable.Range(0, 100).Select(y =>
                {
                    g.Generate();
                    return g.GetResult();
                });
                return new Chart.L2.Result
                {
                    Size = x*10,
                    First = a.Average(z => z.First),
                    Second = a.Average(z => z.Second)
                };
            }).ToList();
            
            var graph = new GraphGenerator();
            graph.AddSeries("first", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x=>(double)x.Size).ToList(), result.Select(x => x.First).ToList(), Color.Red);
            graph.AddSeries("second", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.Second).ToList(), Color.Blue);
            graph.SaveGraph("a"+Guid.NewGuid().ToString());
            */
            var result = Enumerable.Range(1, 100).Select(x =>
            {
                var g = new Chart.L2.Graph(x * 10, (1.0 / (x*10)) - (Math.Pow(x*10.0, 0.1) / (Math.Pow(x * 10.0, (4.0/3.0)))));
                var a = Enumerable.Range(0, 100).Select(y =>
                {
                    g.Generate();
                    return g.GetResult();
                });
                return new Chart.L2.Result
                {
                    Size = x * 10,
                    First = a.Average(z => z.First),
                    Second = a.Average(z => z.Second)
                };
            }).ToList();

            var graph = new GraphGenerator();
            graph.AddSeries("first", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.First).ToList(), Color.Red);
            graph.AddSeries("second", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.Second).ToList(), Color.Blue);
            graph.SaveGraph("b" + Guid.NewGuid().ToString());

            result = Enumerable.Range(1, 100).Select(x =>
            {
                var g = new Chart.L2.Graph(x * 10, (1.0 / (x * 10)) - (2.0 / (Math.Pow(x * 10.0, (4.0 / 3.0)))));
                var a = Enumerable.Range(0, 100).Select(y =>
                {
                    g.Generate();
                    return g.GetResult();
                });
                return new Chart.L2.Result
                {
                    Size = x * 10,
                    First = a.Average(z => z.First),
                    Second = a.Average(z => z.Second)
                };
            }).ToList();

            graph = new GraphGenerator();
            graph.AddSeries("first", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.First).ToList(), Color.Red);
            graph.AddSeries("second", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.Second).ToList(), Color.Blue);
            graph.SaveGraph("c" + Guid.NewGuid().ToString());

            result = Enumerable.Range(1, 100).Select(x =>
            {
                var g = new Chart.L2.Graph(x * 10, (1.0 / (x * 10)) + (2 / (Math.Pow(x * 10.0, (4.0 / 3.0)))));
                var a = Enumerable.Range(0, 100).Select(y =>
                {
                    g.Generate();
                    return g.GetResult();
                });
                return new Chart.L2.Result
                {
                    Size = x * 10,
                    First = a.Average(z => z.First),
                    Second = a.Average(z => z.Second)
                };
            }).ToList();

            graph = new GraphGenerator();
            graph.AddSeries("first", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.First).ToList(), Color.Red);
            graph.AddSeries("second", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.Second).ToList(), Color.Blue);
            graph.SaveGraph("d" + Guid.NewGuid().ToString());

            result = Enumerable.Range(1, 100).Select(x =>
            {
                var g = new Chart.L2.Graph(x * 10, (1.0 / (x * 10)) + (Math.Pow(x * 10.0, 0.1) / (Math.Pow(x * 10.0, (4.0 / 3.0)))));
                var a = Enumerable.Range(0, 100).Select(y =>
                {
                    g.Generate();
                    return g.GetResult();
                });
                return new Chart.L2.Result
                {
                    Size = x * 10,
                    First = a.Average(z => z.First),
                    Second = a.Average(z => z.Second)
                };
            }).ToList();

            graph = new GraphGenerator();
            graph.AddSeries("first", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.First).ToList(), Color.Red);
            graph.AddSeries("second", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.Second).ToList(), Color.Blue);
            graph.SaveGraph("e" + Guid.NewGuid().ToString());

            result = Enumerable.Range(1, 100).Select(x =>
            {
                var g = new Chart.L2.Graph(x * 10, 2.0 / (x * 10));
                var a = Enumerable.Range(0, 100).Select(y =>
                {
                    g.Generate();
                    return g.GetResult();
                });
                return new Chart.L2.Result
                {
                    Size = x * 10,
                    First = a.Average(z => z.First),
                    Second = a.Average(z => z.Second)
                };
            }).ToList();

            graph = new GraphGenerator();
            graph.AddSeries("first", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.First).ToList(), Color.Red);
            graph.AddSeries("second", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Select(x => (double)x.Size).ToList(), result.Select(x => x.Second).ToList(), Color.Blue);
            graph.SaveGraph("f" + Guid.NewGuid().ToString());
        }