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); }
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()); }
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()); }
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); }
public DifferentialsSolver(TransportTask task) { this.task = task.clone(); this.workedArea = this.task.clone(); }
public VogelApproximationSolver(TransportTask task) { this.task = task.clone(); }
public MinElementSolver(TransportTask task) { this.task = task.clone(); }
private void start_Click(object sender, EventArgs e) { TransportTask task = parse(input.Text); MessageBox.Show(generateMessage(task)); }
public NorthWestCornerSolver(TransportTask task) { this.task = task.clone(); }