Esempio n. 1
0
        private void StartAlgorithm_Execute()
        {
            try
            {
                IAlgorithm algorithm;

                if (!CheckContainerSize())
                {
                    throw new InvalidContainerSizeException("Container is not big enough to contain biggest object. Enlarge the container.");
                }

                if (Dimensionality == AlgorithmDimensionality.TwoDimensional)
                {
                    Container2D startingContainer = containerFactory.Create(algorithmProperties, ContainerWidth, ContainerHeight);
                    algorithm = factory.Create(algorithmProperties, startingContainer);
                }
                else
                {
                    Container3D startingContainer = containerFactory.Create(algorithmProperties, ContainerWidth, ContainerHeight, ContainerDepth);
                    algorithm = factory.Create(algorithmProperties, startingContainer);
                }

                stopwatch.Reset();

                var sortedObjects = SortingHelper.Sort(objectsToPack, ObjectOrdering);

                stopwatch.Start();
                algorithm.Execute(sortedObjects);
                stopwatch.Stop();

                var endResults = algorithm.CreateResults();

                ExecutionTime                     = stopwatch.ElapsedMilliseconds;
                Quality                           = endResults.Quality;
                ContainersUsed                    = endResults.ContainersUsed;
                ObjectAmount                      = endResults.ObjectCount;
                ObjectTotalFullfilment            = endResults.ObjectsTotalFulfillment;
                ContainerFulfillment              = endResults.ContainerFulfillment;
                AverageFulfillmentRatio           = endResults.AverageFulfillmentRatio;
                FulfillmentRatioStandardDeviation = endResults.FulfillmentRatioStandardDeviation;
                WorstFulfillment                  = endResults.WorstFulfillment;

                System.Windows.MessageBox.Show("Program successfully packed input object set.", "End of packing.");
            }
            catch (Exception err)
            {
                System.Windows.MessageBox.Show("Error during executing algorithm: " + err.Message, "Error");
            }
        }
Esempio n. 2
0
        private static void RunAlgorithm()
        {
            IFigure           startingContainer;
            IAlgorithm        algorithm;
            Stopwatch         stopwatch        = new Stopwatch();
            IContainerFactory containerFactory = new ContainerFactory();
            IAlgorithmFactory factory          = new AlgorithmFactory();



            if (Properties.Dimensionality == AlgorithmDimensionality.TwoDimensional)
            {
                startingContainer = containerFactory.Create(Properties, ContainerWidth, ContainerHeight);
                algorithm         = factory.Create(Properties, startingContainer);
            }
            else
            {
                startingContainer = containerFactory.Create(Properties, ContainerWidth, ContainerHeight, ContainerDepth);
                algorithm         = factory.Create(Properties, startingContainer);
            }

            ObjectSet objectsToPack = LoadObjectSet();

            if (!CheckContainerSize(objectsToPack))
            {
                throw new InvalidContainerSizeException("Container is not big enough to contain biggest object. Enlarge the container.");
            }


            stopwatch.Reset();

            var sortedObjects = SortingHelper.Sort(objectsToPack, Ordering);

            stopwatch.Start();
            algorithm.Execute(sortedObjects);
            stopwatch.Stop();

            var endResults = algorithm.CreateResults();

            endResults.ExecutionTime = stopwatch.ElapsedMilliseconds;

            WriteResiltsToCsv(endResults, startingContainer);
        }