예제 #1
0
        public TransportTask clone()
        {
            TransportTask res = new TransportTask(n, m);

            Buffer.BlockCopy(vectorN, 0, res.vectorN, 0, sizeof(int) * n);
            Buffer.BlockCopy(vectorM, 0, res.vectorM, 0, sizeof(int) * m);
            for (int i = 0; i < n; i++)
            {
                Buffer.BlockCopy(matrix[i], 0, res.matrix[i], 0, sizeof(int) * m);
            }
            return(res);
        }
예제 #2
0
        private String generateMessage(TransportTask task)
        {
            StringBuilder str = new StringBuilder("");

            str.AppendLine(generateTask(task));

            Solver sol = new NorthWestCornerSolver(task);

            str.AppendLine(generateSolve(sol.solve(), "Решение методом северо-западного угла:"));

            sol = new MinElementSolver(task);
            str.AppendLine(generateSolve(sol.solve(), "Решение методом минимального элемента:"));

            sol = new VogelApproximationSolver(task);
            str.AppendLine(generateSolve(sol.solve(), "Решение методом аппроксимации Фогеля:"));

            sol = new DifferentialsSolver(task);
            str.AppendLine(generateSolve(sol.solve(), "Решение методом дифференциальных рент"));


            return(str.ToString());
        }
예제 #3
0
        private String generateTask(TransportTask task)
        {
            StringBuilder str = new StringBuilder("");

            str.AppendLine("Задача:");
            str.Append(formatStr("", 4));
            for (int j = 0; j < task.m; j++)
            {
                str.Append(formatStr(task.vectorM[j].ToString(), 4));
            }
            str.AppendLine();
            for (int i = 0; i < task.n; i++)
            {
                str.Append(formatStr(task.vectorN[i].ToString(), 4));
                for (int j = 0; j < task.m; j++)
                {
                    str.Append(formatStr(task.matrix[i][j].ToString(), 4));
                }
                str.AppendLine();
            }

            return(str.ToString());
        }
예제 #4
0
        private TransportTask parse(String str)
        {
            String[] numbers = str.Split(new char[] { ' ', '\n', '\r' });
            int      k       = 0;

            last(numbers, ref k);
            int n = Int32.Parse(numbers[k]);

            k++;
            last(numbers, ref k);
            int m = Int32.Parse(numbers[k]);

            k++;
            TransportTask task = new TransportTask(n, m);

            for (int j = 0; j < m; j++)
            {
                last(numbers, ref k);
                task.vectorM[j] = Int32.Parse(numbers[k]);
                k++;
            }
            for (int i = 0; i < n; i++)
            {
                task.matrix[i] = new int[m];
                last(numbers, ref k);
                task.vectorN[i] = Int32.Parse(numbers[k]);
                k++;
                for (int j = 0; j < m; j++)
                {
                    last(numbers, ref k);
                    task.matrix[i][j] = Int32.Parse(numbers[k]);
                    k++;
                }
            }
            return(task);
        }
예제 #5
0
 public DifferentialsSolver(TransportTask task)
 {
     this.task       = task.clone();
     this.workedArea = this.task.clone();
 }
예제 #6
0
 public VogelApproximationSolver(TransportTask task)
 {
     this.task = task.clone();
 }
예제 #7
0
 public MinElementSolver(TransportTask task)
 {
     this.task = task.clone();
 }
예제 #8
0
        private void start_Click(object sender, EventArgs e)
        {
            TransportTask task = parse(input.Text);

            MessageBox.Show(generateMessage(task));
        }
예제 #9
0
 public NorthWestCornerSolver(TransportTask task)
 {
     this.task = task.clone();
 }