protected virtual void ResetVariables()
 {
     //resets algorithms variables
     this.curNumSteps = 0;
     this.extrinsicReward.Dispose();
     this.extrinsicReward = new StatisticalQuantity(this.UpdateSteps);
 }
Example #2
0
        protected void CreateTestMeasureList()
        {
            //goes through all the parameters
            var testParameters = this.SortedTestParameters.Values.First();

            foreach (var testParameter in testParameters)
            {
                //gets average of rank for each test type
                var rankQuantity = new StatisticalQuantity((uint)this.TestsConfig.MultipleTestTypes.Length);
                foreach (var testType in TestsConfig.MultipleTestTypes)
                {
                    rankQuantity.Value = this.SortedTestParameters[testType].IndexOf(testParameter);
                }

                //creates measure based on this rank avg and adds to list
                var rankMeasure = new TestMeasure
                {
                    Value      = rankQuantity.Mean,
                    StdDev     = rankQuantity.StdDev,
                    Parameters = testParameter,
                    ID         = testParameter.ToString()
                };
                this.TestMeasures.Add(testParameter, rankMeasure);
            }
        }
        public void UpdateCurrentFitness(IPopulation population)
        {
            //gets population std dev
            var popFitness = new StatisticalQuantity();

            popFitness.AddRange(population.Select(agent => agent.Fitness.Value));
            population.Fitness.Value = -popFitness.StdDev;
        }
        public void UpdateCurrentFitness(IPopulation population)
        {
            //gets population avg - x*std_dev
            var popFitness = new StatisticalQuantity();

            popFitness.AddRange(population.Select(agent => agent.Fitness.Value));
            population.Fitness.Value = popFitness.Mean - (this._stdDevTimes * popFitness.StdDev);
        }
        public static void PrintStatisticsToCSV(
            this StatisticalQuantity quantity, string filePath, bool printValuesOnly = false,
            bool printImage = true, ChartType chartType       = ChartType.Line,
            int width       = DEFAULT_IMAGE_WIDTH, int height = DEFAULT_IMAGE_HEIGHT,
            ChartImageFormat imageFormat = ChartImageFormat.Pdf)
        {
            quantity.PrintStatisticsToCSV(filePath, printValuesOnly);

            if (printImage)
            {
                quantity.PrintStatisticsToImage(
                    PathUtil.ReplaceExtension(filePath, imageFormat.ToString().ToLower()),
                    chartType, width, height, imageFormat);
            }
        }
        public static void PrintStatisticsToImage(
            this StatisticalQuantity quantity, string filePath, ChartType chartType,
            int width = DEFAULT_IMAGE_WIDTH, int height = DEFAULT_IMAGE_HEIGHT,
            ChartImageFormat imageFormat = ChartImageFormat.Pdf)
        {
            if ((quantity.Samples == null) || (quantity.Samples.Length == 0))
            {
                return;
            }

            //creates chart
            var title = Path.GetFileNameWithoutExtension(filePath);

            new StatisticsCollection {
                { title, quantity }
            }.CreateAndPrintChart(
                filePath, title, chartType, width, height, imageFormat);
        }
Example #7
0
        public List <ITestParameters> SelectBestMeasures(int stdDevTimes)
        {
            //creates quantity from all tests fitness
            var fitnessQuantity = new StatisticalQuantity((uint)this.testMeasures.Count);

            foreach (var testMeasure in this.testMeasures.Values)
            {
                fitnessQuantity.Value = testMeasure.Value;
            }

            //determines the minimum fitness threshold to consider the best test measures
            var minThreshold = fitnessQuantity.Mean + (stdDevTimes * fitnessQuantity.StdDev);

            //returns only those parameters of tests which belong to the given threshold
            return((from testMeasure in this.testMeasures.Values
                    where testMeasure.Value >= minThreshold
                    select testMeasure.Parameters).ToList());
        }
        protected virtual StatisticsCollection GetPopulationStatsCollectionAvg(IPopulation population)
        {
            if ((population == null) || (population.Count == 0))
            {
                return(null);
            }
            var popStatsCollectionAvg = new StatisticsCollection();

            //for each agent statistic
            foreach (var statKey in population[0].StatisticsCollection.Keys)
            {
                //average statistic between all agents
                var stat = StatisticalQuantity.GetQuantitiesAverage(
                    population.Select(ag => ag.StatisticsCollection[statKey]).ToList());

                popStatsCollectionAvg.Add(statKey, stat);
            }
            return(popStatsCollectionAvg);
        }
 public override void Reset()
 {
     base.Reset();
     this.IntrinsicReward = new StatisticalQuantity();
 }
 public override void Reset()
 {
     this.ExtrinsicReward = new StatisticalQuantity();
 }
 public override void Reset()
 {
     base.Reset();
     this.NumBackups = new StatisticalQuantity();
     this.ClearUpdatedList();
 }