public static void Graph() { List <string> unformatedLP = FileHandler.ReadLP(); //Sets size of array coordindates = new double[unformatedLP.Count(), 2]; //Loops through all the constraints for (int i = 1; i < unformatedLP.Count() - 1; i++) { //Splits the equation string[] tempEquation = unformatedLP[i].Split(' '); //Gets the coordinates of the constraints if (Convert.ToDouble(tempEquation[0]) != 0 && Convert.ToDouble(tempEquation[1]) != 0) { coordindates[i - 1, 0] = Convert.ToDouble(tempEquation[tempEquation.Count() - 1]) / Convert.ToDouble(tempEquation[0]); coordindates[i - 1, 1] = Convert.ToDouble(tempEquation[tempEquation.Count() - 1]) / Convert.ToDouble(tempEquation[1]); } } //double[] bvs = linearProgram.GetBasicVariables(); //coordindates[coordindates.GetLength(0) - 1, 0] = bvs[1]; //coordindates[coordindates.GetLength(0) - 1, 1] = bvs[2]; frmGraph graph = new frmGraph(coordindates); //Opens the Form graph.ShowDialog(); }
public Duality(LinearProgram optimalSoltution) { OptimalSoltution = optimalSoltution; originalLP = new LpFormatter(FileHandler.ReadLP(), Algorithm.Dual).GetLinearProgram(); }
//New Main Menu with file,Alg& sensitivity ananlysis selection public static void Menu() { GetInputAndOutputFiles(); //TODO Move this to different place #region Stuff to Move List <String> unformatedLP = FileHandler.ReadLP(); foreach (var item in unformatedLP) { Console.WriteLine(item); } #endregion bool done = false; do { try { Console.WriteLine(@" IP SOLVER ________________________________________________________ PLEASE SELECT AN ALGORITHM 1.PRIMAL 2.TWO PHASE 3.DUAL 4.BRANCH & BOUND 5.CUTTING PLANE "); int userinput = int.Parse(Console.ReadLine()); Algorithm menu = (Algorithm)userinput; switch (menu) { case Algorithm.Primal: linearProgram = new LpFormatter(unformatedLP, Algorithm.Primal).GetLinearProgram(); linearProgram.DisplayCanonicalForm(); PrimalSimplex simplex = new PrimalSimplex(linearProgram); linearProgram = simplex.Solve(); break; case Algorithm.TwoPhase: linearProgram = new LpFormatter(unformatedLP, Algorithm.TwoPhase).GetLinearProgram(); linearProgram.IsTwoPhase = true; TwoPhase twoPhase = new TwoPhase(linearProgram); linearProgram.DisplayCanonicalForm(); linearProgram = twoPhase.Solve(); break; case Algorithm.Dual: linearProgram = new LpFormatter(unformatedLP, Algorithm.Dual).GetLinearProgram(); linearProgram.DisplayCanonicalForm(); Dual dual = new Dual(linearProgram); linearProgram = dual.Solve(); break; case Algorithm.BranchAndBound: linearProgram = new LpFormatter(unformatedLP, Algorithm.Dual).GetLinearProgram(); linearProgram.DisplayCanonicalForm(); Dual bbDual = new Dual(linearProgram); linearProgram = bbDual.Solve(); BranchAndBound BB = new BranchAndBound(linearProgram); linearProgram = BB.Solve(); break; case Algorithm.CuttingPlane: linearProgram = new LpFormatter(unformatedLP, Algorithm.Dual).GetLinearProgram(); linearProgram.DisplayCanonicalForm(); Dual cutDual = new Dual(linearProgram); linearProgram = cutDual.Solve(); CuttingPlane cutingPlane = new CuttingPlane(linearProgram); linearProgram = cutingPlane.Solve(); break; default: break; } //todo check for input errors, set done to false if there arent any done = true; } catch (FormatException) { done = false; Console.WriteLine("Invalid Input"); } } while (!done); if (LpTools.CheckIfIPIsSolved(linearProgram)) { linearProgram.DisplaySolution(); } else { Console.WriteLine("No Solution!"); Console.ReadKey(); } Console.Clear(); if (LpTools.CheckIfIPIsSolved(linearProgram)) { do { SensitivityAnalysisMenu(); } while (true); } }