Beispiel #1
0
        private void LoadData(ProcessDataBlock dataBlock)
        {
            dataBlock.dataLines.Clear();
            dataBlock.dataLines.Capacity = dataBlock.fileNames.Count;

            foreach (string f in dataBlock.fileNames)
            {
                dataBlock.dataLines.Add(ParseDataFile(f));
            }
        }
Beispiel #2
0
        private void CalcMeanData(ProcessDataBlock dataBlock, int maxGen)
        {
            // initialize finalLine
            dataBlock.finalLine.finalDist = 0;
            dataBlock.finalLine.totalTime = new TimeSpan(0);
            dataBlock.finalLine.genCount  = 0;
            dataBlock.finalLine.nodeCount = 0;
            dataBlock.finalLine.timePerGen.Clear();
            dataBlock.finalLine.distancePerGen.Clear();
            dataBlock.finalLine.timePerGen.Capacity     = maxGen;
            dataBlock.finalLine.distancePerGen.Capacity = maxGen;
            dataBlock.timePerGenMean = new TimeSpan(0);
            int[] genCount = new int[maxGen];

            for (int i = 0; i < maxGen; ++i)
            {
                dataBlock.finalLine.timePerGen.Add(new TimeSpan(0));
                dataBlock.finalLine.distancePerGen.Add(0);
                genCount[i] = 0;
            }

            foreach (ProcessDataLine data in dataBlock.dataLines)
            {
                // sum up data
                dataBlock.finalLine.finalDist += data.finalDist;
                dataBlock.finalLine.genCount  += data.genCount;
                dataBlock.finalLine.nodeCount  = data.nodeCount;
                dataBlock.finalLine.totalTime += data.totalTime;

                TimeSpan prev = new TimeSpan(0);
                for (int i = 0; i < data.genCount; ++i)
                {
                    dataBlock.finalLine.timePerGen[i] += (data.timePerGen[i] - prev);
                    prev = data.timePerGen[i];
                    dataBlock.finalLine.distancePerGen[i] += data.distancePerGen[i];
                    ++genCount[i];
                }
            }

            dataBlock.finalLine.finalDist /= dataBlock.dataLines.Count;
            dataBlock.finalLine.genCount  /= dataBlock.dataLines.Count;
            dataBlock.finalLine.totalTime  = new TimeSpan(dataBlock.finalLine.totalTime.Ticks / dataBlock.dataLines.Count);

            for (int i = 0; i < maxGen; ++i)
            {
                dataBlock.finalLine.timePerGen[i]      = new TimeSpan(dataBlock.finalLine.timePerGen[i].Ticks / genCount[i]);
                dataBlock.timePerGenMean              += dataBlock.finalLine.timePerGen[i];
                dataBlock.finalLine.distancePerGen[i] /= genCount[i];
            }

            dataBlock.timePerGenMean = new TimeSpan(dataBlock.timePerGenMean.Ticks / maxGen);
        }
Beispiel #3
0
        private void DrawData(ProcessDataBlock dataBlock, int id)
        {
            string graphName = scenarioNames[id];

            chart1.Series.Add(graphName);
            //chart1.Series[graphName].BorderWidth = 3;
            chart1.ChartAreas[0].AxisY.Minimum = 18000;
            chart1.Series[graphName].ChartType = SeriesChartType.Line;
            chart1.Series[graphName].Color     = graphColors[id];


            foreach (double val in dataBlock.finalLine.distancePerGen)
            {
                chart1.Series[graphName].Points.AddY(val);
            }

            AddBarChartPoint(chart2, id, dataBlock.finalLine.finalDist, dataBlock.finalLineStd.finalDist);
            AddBarChartPoint(chart3, id, dataBlock.finalLine.genCount, dataBlock.finalLineStd.genCount);
            AddBarChartPoint(chart4, id, dataBlock.timePerGenMean.TotalSeconds, dataBlock.timePerGenStd);
        }
Beispiel #4
0
        private void CrunchData(ProcessDataBlock dataBlock)
        {
            if (dataBlock.fileNames.Count == 0)
            {
                return;
            }
            // find maximum count of generations
            int maxGen = 0;

            foreach (ProcessDataLine data in dataBlock.dataLines)
            {
                if (data.genCount > maxGen)
                {
                    maxGen = (int)data.genCount;
                }
            }

            CalcMeanData(dataBlock, maxGen);
            CalcStdDeviation(dataBlock, maxGen);
        }
Beispiel #5
0
        private void CalcStdDeviation(ProcessDataBlock dataBlock, int maxGen)
        {
            // initialize finalLineStd
            dataBlock.finalLineStd.finalDist = 0;
            dataBlock.finalLineStd.totalTime = 0;
            dataBlock.finalLineStd.genCount  = 0;
            dataBlock.finalLineStd.timePerGen.Clear();
            dataBlock.finalLineStd.distancePerGen.Clear();
            dataBlock.finalLineStd.timePerGen.Capacity     = maxGen;
            dataBlock.finalLineStd.distancePerGen.Capacity = maxGen;
            dataBlock.timePerGenStd = 0;
            int[] genCount = new int[maxGen];

            int div = dataBlock.dataLines.Count - 1;

            if (div <= 0)
            {
                return;
            }

            for (int i = 0; i < maxGen; ++i)
            {
                dataBlock.finalLineStd.timePerGen.Add(0);
                dataBlock.finalLineStd.distancePerGen.Add(0);
                genCount[i] = 0;
            }

            foreach (ProcessDataLine data in dataBlock.dataLines)
            {
                dataBlock.finalLineStd.finalDist += Varianz(data.finalDist, dataBlock.finalLine.finalDist);
                dataBlock.finalLineStd.totalTime += Varianz(data.totalTime, dataBlock.finalLine.totalTime);
                dataBlock.finalLineStd.genCount  += Varianz(data.genCount, dataBlock.finalLine.genCount);

                TimeSpan prev = new TimeSpan(0);
                for (int i = 0; i < data.genCount; ++i)
                {
                    dataBlock.finalLineStd.timePerGen[i] += Varianz(data.timePerGen[i] - prev, dataBlock.finalLine.timePerGen[i]);
                    prev = data.timePerGen[i];
                    dataBlock.finalLineStd.distancePerGen[i] += Varianz(data.distancePerGen[i], dataBlock.finalLine.distancePerGen[i]);
                    ++genCount[i];
                }
            }

            dataBlock.finalLineStd.finalDist = Math.Sqrt(dataBlock.finalLineStd.finalDist / div);
            dataBlock.finalLineStd.totalTime = Math.Sqrt(dataBlock.finalLineStd.totalTime / div);
            dataBlock.finalLineStd.genCount  = Math.Sqrt(dataBlock.finalLineStd.genCount / div);

            for (int i = 0; i < maxGen; ++i)
            {
                dataBlock.timePerGenStd += Varianz(dataBlock.finalLine.timePerGen[i].TotalSeconds, dataBlock.timePerGenMean.TotalSeconds);

                div = genCount[i] - 1;
                if (div <= 0)
                {
                    dataBlock.finalLineStd.distancePerGen[i] = 0;
                    dataBlock.finalLineStd.timePerGen[i]     = 0;
                    continue;
                }

                dataBlock.finalLineStd.distancePerGen[i] = Math.Sqrt(dataBlock.finalLineStd.distancePerGen[i] / div);
                dataBlock.finalLineStd.timePerGen[i]     = Math.Sqrt(dataBlock.finalLineStd.timePerGen[i] / div);
            }

            div = maxGen - 1;
            if (div <= 0)
            {
                dataBlock.timePerGenStd = 0;
            }
            else
            {
                dataBlock.timePerGenStd = Math.Sqrt(dataBlock.timePerGenStd / div);
            }
        }