Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            Int32 nodeIncr = (int)numericUpDown3.Value;
            Int32 maxNodex = (int)numericUpDown4.Value;
            Int32 timeout  = (int)numericUpDown5.Value;

            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (Object o, DoWorkEventArgs a) =>
            {
                StreamWriter result = new StreamWriter(String.Format("StressTest-{0}.csv", DateTime.Now.Ticks));
                RoutingAI.Algorithms.IDistanceAlgorithm <Coordinate> distancealg = new RoutingAI.Algorithms.StraightDistanceAlgorithm();
                Random       r = new Random();
                Coordinate[] data;

                Int32 currentNodes = 100;
                while (currentNodes < maxNodex)
                {
                    data = new Coordinate[currentNodes];
                    for (int i = 0; i < data.Length; i++)
                    {
                        data[i] = new Coordinate(r.Next(-10000, 10000) / 100.0f, r.Next(-10000, 10000) / 100.0f);
                    }

                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    //KMedoidsProcessor<Coordinate> proc = new KMedoidsProcessor<Coordinate>((int)Math.Sqrt(currentNodes), data, distancealg);
                    IClusteringAlgorithm <Coordinate> proc = new PAMClusteringAlgorithm <Coordinate>(data, (int)Math.Sqrt(currentNodes), distancealg);
                    proc.Run();
                    sw.Stop();
                    result.WriteLine("{0},{1}", currentNodes, sw.ElapsedMilliseconds);
                    result.Flush();

                    this.BeginInvoke(new Action(() =>
                    {
                        //coordinates = data;
                        //processor = proc;
                        //panel1.Invalidate();
                        lblCurrentResult.Text = String.Format("{0},{1}", currentNodes, sw.ElapsedMilliseconds);
                    }));

                    currentNodes += nodeIncr;
                }
            };
            bw.RunWorkerAsync();
        }
Beispiel #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            Int32 nodeIncr = (int)numericUpDown3.Value;
            Int32 maxNodex = (int)numericUpDown4.Value;
            Int32 timeout = (int)numericUpDown5.Value;

            BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += (Object o, DoWorkEventArgs a) =>
            {
                StreamWriter result = new StreamWriter(String.Format("StressTest-{0}.csv", DateTime.Now.Ticks));
                RoutingAI.Algorithms.IDistanceAlgorithm<Coordinate> distancealg = new RoutingAI.Algorithms.StraightDistanceAlgorithm();
                Random r = new Random();
                Coordinate[] data;

                Int32 currentNodes = 100;
                while (currentNodes < maxNodex)
                {
                    data = new Coordinate[currentNodes];
                    for (int i = 0; i < data.Length; i++)
                        data[i] = new Coordinate(r.Next(-10000, 10000) / 100.0f, r.Next(-10000, 10000) / 100.0f);

                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    //KMedoidsProcessor<Coordinate> proc = new KMedoidsProcessor<Coordinate>((int)Math.Sqrt(currentNodes), data, distancealg);
                    IClusteringAlgorithm<Coordinate> proc = new PAMClusteringAlgorithm<Coordinate>(data, (int)Math.Sqrt(currentNodes), distancealg);
                    proc.Run();
                    sw.Stop();
                    result.WriteLine("{0},{1}", currentNodes, sw.ElapsedMilliseconds);
                    result.Flush();

                    this.BeginInvoke(new Action(() =>
                    {
                        //coordinates = data;
                        //processor = proc;
                        //panel1.Invalidate();
                        lblCurrentResult.Text = String.Format("{0},{1}", currentNodes, sw.ElapsedMilliseconds);
                    }));

                    currentNodes += nodeIncr;
                }

            };
            bw.RunWorkerAsync();
        }