public static void Main(string[] args) { var task = new LPTask () { C = DenseVector.OfEnumerable (new [] { 1.0, -3, -5, 1 }), B = DenseVector.OfEnumerable (new [] { 5.0, 9 }), M = 2, N = 4, A = DenseMatrix.OfArray (new [,] { { 1.0, 4, 4, 1 }, { 1.0, 7, 8, 2 }, }), Jb = new List<int>{ 0, 2 } }; var result = task.SolveSimplex (); for (int i = 0; i < task.M; i++) Console.WriteLine (task.Jb[i]); Console.WriteLine (result); Console.WriteLine ("VALUE"); var s = 0.0; for (int i = 0; i < task.M; i++) s += task.C [task.Jb [i]] * result [i]; Console.WriteLine (s); }
public static void Main(string[] args) { var task = new LPTask() { C = DenseVector.OfEnumerable(new [] { 1.0, -3, -5, 1 }), B = DenseVector.OfEnumerable(new [] { 5.0, 9 }), M = 2, N = 4, A = DenseMatrix.OfArray(new [, ] { { 1.0, 4, 4, 1 }, { 1.0, 7, 8, 2 }, }), Jb = new List <int> { 0, 2 } }; var result = task.SolveSimplex(); for (int i = 0; i < task.M; i++) { Console.WriteLine(task.Jb[i]); } Console.WriteLine(result); Console.WriteLine("VALUE"); var s = 0.0; for (int i = 0; i < task.M; i++) { s += task.C [task.Jb [i]] * result [i]; } Console.WriteLine(s); }
static void Main(string[] args) { string[] defaults = { "op", "myData.txt", "myDataout.txt" }; do { var command = new string[3]; defaults.CopyTo(command, 0); Console.WriteLine("Enter the command:"); string[] userCommand = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < userCommand.Length; i++) { command[i] = userCommand[i].Trim(); } ITask task = null; switch (command[0].ToLower()) { case "lp": { task = new LPTask(); break; } case "ilp": { task = new ILPTask(); break; } case "ja": { task = new JohnsonTask(); break; } case "op": { task = new OPTask(); break; } default: { Console.WriteLine("Uncorrect command"); break; } } try { task.ReadDataFromTxt(command[1]); } catch (Exception e) { task = null; Console.WriteLine("Some errors occurred, please check your input and try again."); } if (task != null) { task.Resolve(); task.WriteResultToTxt(command[2]); Console.WriteLine("Work has been finished successfully!"); } Console.WriteLine("Press any key to continue or Esc to exit...\n"); if (Console.ReadKey(true).Key == ConsoleKey.Escape) { break; } } while (true); }