Example #1
0
        protected override void Run(CancellationToken token)
        {
            var items   = Problem.Items;
            var bin     = Problem.BinShape;
            var sorting = new[] { SortingMethodParameter.Value.Value };

            if (sorting[0] == SortingMethod.All)
            {
                sorting = Enum.GetValues(typeof(SortingMethod)).Cast <SortingMethod>().Where(x => x != SortingMethod.All).ToArray();
            }
            var fitting = new[] { fittingMethodParameter.Value.Value };

            if (fitting[0] == FittingMethod.All)
            {
                fitting = Enum.GetValues(typeof(FittingMethod)).Cast <FittingMethod>().Where(x => x != FittingMethod.All).ToArray();
            }
            var result = GetBest(bin, items, sorting, fitting, token);

            if (result == null)
            {
                throw new InvalidOperationException("No result obtained!");
            }

            Results.Add(new Result("Best Solution",
                                   "The best found solution",
                                   result.Item1));
            Results.Add(new Result("Best Solution Quality",
                                   "The quality of the best found solution according to the evaluator",
                                   new DoubleValue(result.Item2)));

            var binUtil   = new BinUtilizationEvaluator();
            var packRatio = new PackingRatioEvaluator();

            Results.Add(new Result("Best Solution Bin Count",
                                   "The number of bins in the best found solution",
                                   new IntValue(result.Item1.NrOfBins)));
            Results.Add(new Result("Best Solution Bin Utilization",
                                   "The utilization given in percentage as calculated by the BinUtilizationEvaluator (total used space / total available space)",
                                   new PercentValue(Math.Round(binUtil.Evaluate(result.Item1), 3))));

            if (result.Item3.HasValue && sorting.Length > 1)
            {
                Results.Add(new Result("Best Sorting Method",
                                       "The sorting method that found the best solution",
                                       new EnumValue <SortingMethod>(result.Item3.Value)));
            }
            if (result.Item4.HasValue && fitting.Length > 1)
            {
                Results.Add(new Result("Best Fitting Method",
                                       "The fitting method that found the best solution",
                                       new EnumValue <FittingMethod>(result.Item4.Value)));
            }
        }
Example #2
0
        protected ProblemBase()
            : base()
        {
            var defaultEvaluator = new PackingRatioEvaluator();

            Parameters.Add(new ValueParameter <IDecoder <TSol> >("Decoder", "The decoder translates a permutation to a packing solution candidiates"));
            Parameters.Add(new ValueParameter <IEvaluator>(SolutionEvaluatorParameterName, "The evaluator calculates qualities of solution candidates", defaultEvaluator));
            Parameters.Add(new FixedValueParameter <BoolValue>(UseStackingConstraintsParameterName, "A flag that determines if stacking constraints are considered when solving the problem.", new BoolValue(false)));
            Parameters.Add(new ValueParameter <ReadOnlyItemList <PackingItem> >("Items", "The items which must be packed into bins"));
            Parameters.Add(new ValueParameter <PackingShape>("BinShape", "The size of bins into which items must be packed"));
            Parameters.Add(new OptionalValueParameter <Solution>("BestKnownSolution", "The best solution found so far"));
            Parameters.Add(new FixedValueParameter <IntValue>("LowerBound", "A lower bound for the number of bins that is necessary to pack all items"));

            Load(defaultInstance);
        }
Example #3
0
 protected PackingRatioEvaluator(PackingRatioEvaluator original, Cloner cloner)
     : base(original, cloner)
 {
 }
 protected PackingRatioEvaluator(PackingRatioEvaluator original, Cloner cloner)
   : base(original, cloner) {
 }