Ejemplo n.º 1
0
        /// <summary>
        /// Displays a table comparing a list of fitting results.
        /// </summary>
        /// <param name="FittingResults"></param>
        static void DisplayMultipleFittingResults(List <FittingResult> FittingResults)
        {
            int TableWidth      = Console.WindowWidth;
            int NumberOfRows    = 6; // ??? // number of things we care about displaying... for now let's say...
            int NumberOfColumns = FittingResults.Count + 1;


            String[][] TableStrings = new String[NumberOfRows][];


            for (int i = 0; i < NumberOfRows; i++)
            {
                TableStrings[i] = new String[NumberOfColumns];
                for (int j = 0; j < NumberOfColumns; j++)
                {
                    TableStrings[i][j] = ".";
                }
            }

            //Fill in Row Labels:
            TableStrings[1][0] = "Time Elapsed";
            TableStrings[2][0] = "Number Of Bins Used";
            TableStrings[3][0] = "Number Of Items Not Fitted";
            TableStrings[4][0] = "Total Wasted Length";
            TableStrings[5][0] = "Total Remaining Length";
            //maybe averages and standard deviations and things like that?

            //Fill in Column Labels:
            for (int i = 0; i < FittingResults.Count; i++)
            {
                TableStrings[0][i + 1] = FittingResults[i].FitStrategy.ToString();
            }


            for (int j = 0; j < NumberOfColumns - 1; j++)
            {
                TableStrings[1][j + 1] = FittingResults[j].TimeElapsedInTicks.ToString();
                TableStrings[2][j + 1] = FittingResults[j].NumberOfBinsUsed.ToString();
                TableStrings[3][j + 1] = FittingResults[j].NumberOfItemsNotFitted.ToString();
                TableStrings[4][j + 1] = FittingResults[j].TotalWastedLength.ToString();
                TableStrings[5][j + 1] = FittingResults[j].TotalRemainingLength.ToString();
            }

            ConsoleWriter.PrintLine(TableWidth);
            ConsoleWriter.PrintRowsOfTable(TableStrings, TableWidth);

            TextFileWriter.PrintTableToFile(TableStrings, "");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // Console.SetWindowPosition(-10, 0);
            Console.SetWindowSize(150, 65);
            Console.SetBufferSize(150, 2500);


            Console.WriteLine("Display Problem Setup? ");
            bool DisplayProblemSetupText = String.Equals(Console.ReadLine(), "y", StringComparison.CurrentCultureIgnoreCase);

            Console.WriteLine("Display Detailed Results? ");
            bool DisplayDetailedResults = String.Equals(Console.ReadLine(), "y", StringComparison.CurrentCultureIgnoreCase);

            Console.WriteLine("Number Of Iterations?");
            int NumberOfIterations = Convert.ToInt32(Console.ReadLine());

            while (true)
            {
                Console.WriteLine("");
                Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
                Console.WriteLine("");

                Console.WriteLine("Number of Bins: ");
                int numberOfBins = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Number of Items: ");
                int numberOfItems = Convert.ToInt32(Console.ReadLine());

                Random Random = new Random();

                List <List <FittingResult> > FittingResults = new List <List <FittingResult> >();

                for (int Iteration = 0; Iteration < NumberOfIterations; Iteration++)
                {
                    List <Bin>  Bins  = new List <Bin>();
                    List <Item> Items = new List <Item>();

                    for (int i = 0; i < numberOfBins; i++)
                    {
                        //Bin Bin = new Bin(i, 1.0);
                        Bin Bin = new Bin(i, Random.NextDouble(), Random.NextDouble());

                        Bins.Add(Bin);
                    }


                    for (int i = 0; i < numberOfItems; i++)
                    {
                        Item Item = new Item(i, Random.NextDouble(), Random.NextDouble());
                        Items.Add(Item);
                    }

                    if (DisplayProblemSetupText)
                    {
                        DisplayProblemSetup(Bins, Items);
                    }


                    List <FitStrategy> FitStrategies = new List <FitStrategy>();

                    //Add all the existing strategies.

                    int counter            = 0;
                    int numberofstrategies = 13;
                    foreach (FitStrategy FitStrategyIterator in Enum.GetValues(typeof(FitStrategy)))
                    {
                        if (counter < numberofstrategies)
                        {
                            counter++;
                            FitStrategies.Add(FitStrategyIterator);
                        }
                    }

                    List <FittingResult> FittingResultsPerIteration = FitMultipleStrategies(Bins, Items, FitStrategies);
                    FittingResults.Add(FittingResultsPerIteration);

                    //DisplayMultipleFittingResults(FittingResultsPerIteration);

                    //if (DisplayDetailedResults)
                    //{
                    //    foreach (FittingResult FittingResult in FittingResultsPerIteration)
                    //    {
                    //        DisplaySingleFittingResult(FittingResult);
                    //    }
                    //}
                }

                String[][] TableOfResults = ReturnTableOfStatisticalAnalysisofMultipleIterationsOfMultipleFittingResults(FittingResults);
                int        TableWidth     = Console.WindowWidth;

                ConsoleWriter.PrintLine(TableWidth);
                ConsoleWriter.PrintRowsOfTable(TableOfResults, TableWidth);

                TextFileWriter.PrintTableToFile(TableOfResults, @"X:\Arch&CivilEng\ResearchProjects\PShepherd\EG-AR1161\Aurimas PhD\Code\ffp\output\ffp.csv"); // Replace with appropriate output path location.

                Console.WriteLine("");

                //Console.WriteLine("Press Any Key To Continue: ");
                // string Command = Console.ReadLine();
            }
        }