Exemple #1
0
 static void Main(string[] args)
 {
     UserInterfaceHandler.Menu();
 }
Exemple #2
0
        public void DisplaySolution()
        {
            double[] answers = GetBasicVariables();

            double zValue = answers[0];

            Console.WriteLine("Optimal Solutions\n-----------------\nZ = + " + zValue);

            int countAnswers = 1;

            //Displays the X's
            for (int i = 0; i < CountX; i++)
            {
                bool isY = false;

                foreach (var item in ColY)
                {
                    if (item + 1 == i)
                    {
                        isY = true;
                    }
                }

                if (isY == true)
                {
                    Console.WriteLine("X" + (i + 1) + " = " + answers[countAnswers] * -1);
                }
                else
                {
                    Console.WriteLine("X" + (i + 1) + " = " + answers[countAnswers]);
                }

                countAnswers++;
            }

            //Displaye the S's
            for (int i = 0; i < CountS; i++)
            {
                Console.WriteLine("S" + (i + 1) + " = " + answers[countAnswers]);
                countAnswers++;
            }

            //Displaye the E's
            for (int i = 0; i < CountE; i++)
            {
                Console.WriteLine("E" + (i + 1) + " = " + answers[countAnswers]);
                countAnswers++;
            }

            //Displaye the A's
            for (int i = 0; i < CountA; i++)
            {
                Console.WriteLine("A" + (i + 1) + " = " + answers[countAnswers]);
                countAnswers++;
            }

            Console.WriteLine();

            //Calls the method that saves the soution
            FileHandler.SaveSolution(zValue, answers);

            Console.WriteLine("The solution has been saved!");

            //Checks if it can draw a graph
            if (CountX == 2)
            {
                //Draws graph
                UserInterfaceHandler.Graph();
            }
            else
            {
                Console.WriteLine("This LP has more than two variables, cannot draw this graph");
            }

            Console.ReadKey();
        }