public void VisualizeSolution(IMatrix <int> matrix, ISolution solution)
            {
                var text     = new StringBuilder();
                var splitted = new SplittedMatrix(matrix, solution);
                var index    = new Index2D();

                for (int i = 0; i < splitted.Size(0); i++) //строка разбитой матрицы
                {
                    if (i != 0)
                    {
                        text.AppendLine();
                    }
                    for (index.I = splitted.CellLow(i, 0); index.I <= splitted.CellHigh(i, 0); index.I++) //строка исходной матрицы, попавшая в строку разбитой матрицы
                    {
                        for (int j = 0; j < splitted.Size(1); j++)                                        //столбец разбитой матрицы
                        {
                            if (j != 0)
                            {
                                text.AppendFormat("    ");
                            }

                            for (index.J = splitted.CellLow(j, 1); index.J <= splitted.CellHigh(j, 1); index.J++) //столбец исходной матрицы, попавший в столбец разбитой матрицы
                            {
                                text.AppendFormat("{0,3} ", matrix[index]);
                            }
                        }
                        text.AppendLine();
                    }
                }

                MessageBox.Show(text.ToString());
            }
Exemplo n.º 2
0
        public ISolution Run(IMatrix <int> matrix)
        {
            var startSolution = auxilary.Run(matrix);

            int[] x = startSolution[0].ToArray();
            int[] y = startSolution[1].ToArray();

            var solution = new ArraySolution(x, y);
            var m        = new SplittedMatrix(matrix, solution);

            while (true)
            {
                bool result = false;

                for (int I = 0; I < x.Length; I++)
                {
                    for (int J = 0; J < y.Length; J++)
                    {
                        result |= LocalProcedure(x, y, m, I, J);
                    }
                }

                if (!result)
                {
                    break;
                }
            }

            return(solution);
        }
 public SolutionVisualizerForm(SplittedMatrix splittedMatrix, IMatrix<int> matrix, ISolution solution, int min, int max, double criterion)
 {
     InitParameters(splittedMatrix, matrix, solution);
     SetSizeOfBitmap();
     SetMinMax(min, max);
     SetBoundOfValuesOfMatrix(min, max);
     SetCriterion(criterion);
     settingsEvent();
 }
 public SolutionVisualizerForm(SplittedMatrix splittedMatrix, IMatrix <int> matrix, ISolution solution, int min, int max, double criterion)
 {
     InitParameters(splittedMatrix, matrix, solution);
     SetSizeOfBitmap();
     SetMinMax(min, max);
     SetBoundOfValuesOfMatrix(min, max);
     SetCriterion(criterion);
     settingsEvent();
 }
Exemplo n.º 5
0
            public void VisualizeSolution(IMatrix <int> matrix, ISolution solution)
            {
                var max       = CoreUtilities.Utilities.Max(matrix);
                var min       = CoreUtilities.Utilities.Min(matrix);
                var criterion = MinMaxCriterium.Calculate(matrix, solution);

                var splitted           = new SplittedMatrix(matrix, solution);
                var solutionVisualizer =
                    new SolutionVisualizerForm(splitted, matrix,
                                               solution, min, max, criterion);

                solutionVisualizer.Draw();
                solutionVisualizer.Show();
            }
        private void InitParameters(SplittedMatrix splittedMatrix, IMatrix <int> matrix, ISolution solution)
        {
            Name = "SolutionVisualizerForm";
            Text = "     Visualizer of solution";
            this.splittedMatrix = splittedMatrix;
            this.matrix         = matrix;
            this.solution       = solution;
            int rows    = matrix.Size(1);
            int columns = matrix.Size(0);
            int minSize = rows < columns ? rows : columns;

            zoomShift                = 1 + minSize / 400;
            coefficient              = 255.0 / CoreUtilities.Utilities.Max(matrix);
            modeOfDrawing            = Mode.Matrix;
            ModeChangeButton.Visible = true;
            settingsEvent            = SetZoom;
            settingsEvent           += SetSolutionSize;
            settingsEvent           += SetStep;
            settingsEvent           += SetBitmap;
            settingsEvent           += InitSumInBlocks;
            settingsEvent           += SetBoundOfValuesOfBlocks;
            settingsEvent           += SetSumInBlocks;
        }
 private void InitParameters(SplittedMatrix splittedMatrix, IMatrix<int> matrix, ISolution solution)
 {
     Name = "SolutionVisualizerForm";
     Text = "     Visualizer of solution";
     this.splittedMatrix = splittedMatrix;
     this.matrix = matrix;
     this.solution = solution;
     int rows = matrix.Size(1);
     int columns = matrix.Size(0);
     int minSize = rows < columns ? rows : columns;
     zoomShift = 1 + minSize / 400;
     coefficient = 255.0 / CoreUtilities.Utilities.Max(matrix);
     modeOfDrawing = Mode.Matrix;
     ModeChangeButton.Visible = true;
     settingsEvent = SetZoom;
     settingsEvent += SetSolutionSize;
     settingsEvent += SetStep;
     settingsEvent += SetBitmap;
     settingsEvent += InitSumInBlocks;
     settingsEvent += SetBoundOfValuesOfBlocks;
     settingsEvent += SetSumInBlocks;
 }