Beispiel #1
0
        public void Probability_Simple_Test()
        {
            var Inputs   = InputBuilder.CreateInputs(MinInputs, MaxInputs, MinWeight, MaxWeight);
            var Selector = new WeightedSelector <string>();

            Selector.Add(Inputs);

            var Helper = new ProbabilityHelpers(Selector, Inputs, Trials, AcceptableDeviation);


            Console.WriteLine("Running {0} trials with {1} items (total weight: {2})",
                              Trials,
                              Selector.ReadOnlyItems.Count,
                              Selector.TotalWeight());

            var ResultCounter = Helper.RunTrialsAndCountResults();

            foreach (var Key in ResultCounter.Keys)
            {
                Helper.ExamineMetricsForKey(Key);
            }

            Assert.IsTrue(ResultCounter.Keys.Count == Inputs.Count,
                          string.Format("Expected {0} outputs, actual: {1}. Details: {2}",
                                        Inputs.Count,
                                        ResultCounter.Keys.Count,
                                        Helper.GetErrorMessage()));
        }
Beispiel #2
0
        public void Probability_ExtremeInputs_Test()
        {
            var Inputs   = InputBuilder.CreateInputs(MinInputs, MaxInputs, MinWeight, MaxWeight);
            var Selector = new WeightedSelector <string>();

            Selector.Add(Inputs);

            var Helper = new ProbabilityHelpers(Selector, Inputs, Trials, AcceptableDeviation);

            Console.WriteLine("Running {0} trials with {1} items (total weight: {2})",
                              Trials,
                              Selector.ReadOnlyItems.Count,
                              Selector.TotalWeight());

            var ResultCounter = Helper.RunTrialsAndCountResults();

            foreach (var Key in ResultCounter.Keys)
            {
                Helper.ExamineMetricsForKey(Key);
            }

            //Note that in this test, a ton of items will never be selected because there are so many.
            //If we did tens of millions of trials that would counter it, but it might take 30s+, which is
            //unecessary.
            Console.WriteLine("Expected {0} outputs, actual: {1}. Details: {2}",
                              Inputs.Count,
                              ResultCounter.Keys.Count,
                              Helper.GetErrorMessage());
        }