private void TestCATSParam() { int dimentionIterator = 2; int startDimention = 16; int maxDimention = 64; int iterationsCount = 100; int maxCats = 80; UI_progress.Maximum = (int)(iterationsCount * 3 * 4); MultipleSolution solution = new MultipleSolution(CSOAlgorithm.Goal.Minimize, iterationsCount); for (int dimentionIteration = startDimention; dimentionIteration < maxDimention + 1; dimentionIteration *= dimentionIterator) //choose dim { for (int curCats = 10; curCats < maxCats; curCats *= 2) //choose SRD { CSOAlgorithm algorithm = new CSOAlgorithm ( dimentionIteration, curCats, SMP, 1.2, CDC, MR, C, MAX_VELOSITY, SPC, R, SOLUTION_SPACE, CSOAlgorithm.Goal.Minimize ); for (int i = 0; i < iterationsCount; i++) //Repeat 100tests on dim,SRD { UI_progress.PerformStep(); Solution stepSolution = stepSolution = algorithm.RunCSO(ITERATONS, UI_progress, true); //solution.AddFV(dimentionIteration, stepSolution.BestFV); //solution.AddVector(dimentionIteration, stepSolution.BestPosition); solution.AddIterations(dimentionIteration, stepSolution.Iterations); //solution.AddStepFV(dimentionIteration, i, stepSolution.FitnessValues); } } Logger.LogIt(dimentionIteration + " Finished"); } }
private void MultyStartProgramm() { const int dimentionIteratior = 2; const int startDimention = 2; const int maxDimention = 64; const int iterationsCount = 100; UI_progress.Maximum = (int)(iterationsCount * (Math.Sqrt(maxDimention))); //Probably new solution class need to be created MultipleSolution solution = new MultipleSolution(CSOAlgorithm.Goal.Minimize, iterationsCount); for (int dimentionIteration = startDimention; dimentionIteration < maxDimention + 1; dimentionIteration *= dimentionIteratior) { CSOAlgorithm algorithm = new CSOAlgorithm ( dimentionIteration, SWARM_SIZE, SMP, SRD, CDC, MR, C, MAX_VELOSITY, SPC, R, SOLUTION_SPACE, CSOAlgorithm.Goal.Minimize ); for (int i = 0; i < iterationsCount; i++) { UI_progress.PerformStep(); Solution stepSolution = stepSolution = algorithm.RunCSO(ITERATONS, UI_progress, true); solution.AddFV(dimentionIteration, stepSolution.BestFV); solution.AddVector(dimentionIteration, stepSolution.BestPosition); solution.AddIterations(dimentionIteration, stepSolution.Iterations); solution.AddStepFV(dimentionIteration, i, stepSolution.FitnessValues); } } Logger.LogIt("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); for (int dimentionIteration = startDimention; dimentionIteration < maxDimention + 1; dimentionIteration *= dimentionIteratior) { Logger.LogIt("DIMENTIONS: " + dimentionIteration); Logger.LogIt("Лучшее достигнутое значение функции: " + Math.Round(solution.GetBestFV(dimentionIteration), 3)); OutputChart.Series["Best FV"].Points.AddXY(dimentionIteration, solution.GetBestFV(dimentionIteration)); Logger.LogIt("Среднее значение целевой функции: " + Math.Round(solution.GetMedianFV(dimentionIteration), 3)); Logger.LogIt("Среднеквадратическое отклониение: " + Math.Round(solution.GetFVMQD(dimentionIteration), 3)); MedianFVChart.Series["Median FV"].Points.AddXY(dimentionIteration, solution.GetMedianFV(dimentionIteration)); double centerFV = solution.GetMedianFV(dimentionIteration); double err = solution.GetFVMQD(dimentionIteration); MedianFVChart.Series["CKO"].Points.AddXY(dimentionIteration, centerFV, centerFV - err, centerFV + err); MedianFVChart.ChartAreas[0].RecalculateAxesScale(); Logger.LogIt("Лучшая точность локализации: " + Math.Round(solution.GetLocalisationOppraximation(dimentionIteration).Min(), 3)); LocalizationChart.Series["Localisation"].Points.AddXY(dimentionIteration, solution.GetLocalisationOppraximation(dimentionIteration).Min()); //MAX? Logger.LogIt("Средняя точность локализации: " + Math.Round(solution.GetMedian_dX(dimentionIteration), 3)); Logger.LogIt("Среднеквадратическое отклониение локализации: " + Math.Round(solution.Get_dXMQD(dimentionIteration), 3)); mediandXchart.Series["Avg. localization"].Points.AddXY(dimentionIteration, solution.GetMedian_dX(dimentionIteration)); double centerdX = solution.GetMedian_dX(dimentionIteration); double errdx = solution.Get_dXMQD(dimentionIteration); mediandXchart.Series["CKO"].Points.AddXY(dimentionIteration, centerdX, centerdX - errdx, centerdX + errdx); mediandXchart.ChartAreas[0].RecalculateAxesScale(); Logger.LogIt("Вероятность локализации по F: " + Math.Round(solution.FProbability(dimentionIteration), 3)); fProbabilityChart.Series["L.Probability"].Points.AddXY(dimentionIteration, solution.FProbability(dimentionIteration)); Logger.LogIt("Вероятность локализации по X: " + Math.Round(solution.XProbability(dimentionIteration), 3)); dXProbabilityChart.Series["X.Probability"].Points.AddXY(dimentionIteration, solution.XProbability(dimentionIteration)); Logger.LogIt("Максимальное число итераций: " + solution.MaximumIterations(dimentionIteration)); MaxIterationsChart.Series["Maximum It."].Points.AddXY(dimentionIteration, solution.MaximumIterations(dimentionIteration)); Logger.LogIt("Среднее число итераций: " + solution.AverageIterationNumber(dimentionIteration)); Logger.LogIt("Среднеквадратическое отклониение числа итераций: " + Math.Round(solution.GetMMQD(dimentionIteration), 3)); AverageIterationsChart.Series["Average It."].Points.AddXY(dimentionIteration, solution.AverageIterationNumber(dimentionIteration)); double centerM = solution.AverageIterationNumber(dimentionIteration); double errM = solution.GetMMQD(dimentionIteration); AverageIterationsChart.Series["CKO"].Points.AddXY(dimentionIteration, centerM, centerM - errM, centerM + errM); AverageIterationsChart.ChartAreas[0].RecalculateAxesScale(); int BestIterationId = solution.BestIterationId(dimentionIteration); string chartId = "M=" + dimentionIteration; DecreaseFV2_chart.Series[chartId].IsValueShownAsLabel = false; DecreaseFV2_chart.Series[chartId].MarkerStep = 20; for (int i = 0; i < solution.dimention_iteration_fvs[dimentionIteration][BestIterationId].Count; i++) { DecreaseFV2_chart.Series[chartId].Points.AddXY(i, solution.dimention_iteration_fvs[dimentionIteration][BestIterationId][i]); } Logger.LogIt("_______________________________________________________________"); } OutputChart.Series["Best FV"].SmartLabelStyle.Enabled = true; OutputChart.ChartAreas[0].AxisX.IsLogarithmic = true; OutputChart.ChartAreas[0].AxisX.LogarithmBase = 2; OutputChart.Series["Best FV"].IsValueShownAsLabel = false; MedianFVChart.ChartAreas[0].AxisX.IsLogarithmic = true; MedianFVChart.ChartAreas[0].AxisX.LogarithmBase = 2; MedianFVChart.Series["CKO"]["PixelPointWidth"] = "20"; MedianFVChart.Series["CKO"].Color = Color.Black; MedianFVChart.Series["Median FV"].IsValueShownAsLabel = false; LocalizationChart.ChartAreas[0].AxisX.IsLogarithmic = true; LocalizationChart.ChartAreas[0].AxisX.LogarithmBase = 2; LocalizationChart.Series["Localisation"].IsValueShownAsLabel = false; mediandXchart.ChartAreas[0].AxisX.IsLogarithmic = true; mediandXchart.ChartAreas[0].AxisX.LogarithmBase = 2; mediandXchart.Series["CKO"]["PixelPointWidth"] = "20"; mediandXchart.Series["CKO"].Color = Color.Black; mediandXchart.Series["Avg. localization"].IsValueShownAsLabel = false; fProbabilityChart.ChartAreas[0].AxisX.IsLogarithmic = true; fProbabilityChart.Series["L.Probability"]["PixelPointWidth"] = "15"; fProbabilityChart.ChartAreas[0].AxisX.LogarithmBase = 2; fProbabilityChart.ChartAreas[0].AxisY.Maximum = 1; dXProbabilityChart.ChartAreas[0].AxisX.IsLogarithmic = true; dXProbabilityChart.ChartAreas[0].AxisX.LogarithmBase = 2; dXProbabilityChart.ChartAreas[0].AxisY.Maximum = 1; MaxIterationsChart.ChartAreas[0].AxisX.IsLogarithmic = true; MaxIterationsChart.ChartAreas[0].AxisX.LogarithmBase = 2; AverageIterationsChart.ChartAreas[0].AxisX.IsLogarithmic = true; AverageIterationsChart.ChartAreas[0].AxisX.LogarithmBase = 2; AverageIterationsChart.Series["CKO"]["PixelPointWidth"] = "20"; AverageIterationsChart.Series["CKO"].Color = Color.Black; SRD_acc_chart.ChartAreas[0].AxisY.Maximum = 0.01; }