Beispiel #1
0
        private void UpdateAtIndex(int index)
        {
            ScoreSummary summary = this.ratingSummariesToUpdate[index];

            this.interpolator.RemoveDatapoint(summary);
            summary.Update(this.ratingSummarizer);
            this.interpolator.AddDatapoint(summary);
        }
Beispiel #2
0
        // specifies that at <when> , the input coordinates were <coordinates> and that this is a datapoint we care to track
        public void AddDatapoint(DateTime when, LazyInputs coordinates)
        {
            ScoreSummary summary = new ScoreSummary(when);

            summary.Inputs = coordinates;
            summary.Update(this.ratingSummarizer);
            if (this.ShouldIncludeSummary(summary))
            {
                this.interpolator.AddDatapoint(summary);
                this.ratingSummariesToUpdate.Add(summary);
            }
        }
        public void UpdateRatingsPlot()
        {
            DateTime start = DateTime.Now;

            if (!this.queryStartDateDisplay.IsDateValid() || !this.queryEndDateDisplay.IsDateValid())
            {
                return;
            }
            // draw the RatingProgression
            RatingProgression     ratingProgression = this.yAxisActivity.RatingProgression;
            List <AbsoluteRating> ratings           = ratingProgression.GetRatingsInDiscoveryOrder();
            DateTime         startDate = this.queryStartDateDisplay.GetDate();
            DateTime         endDate   = this.queryEndDateDisplay.GetDate();
            List <Datapoint> points    = new List <Datapoint>();

            // make a plot
            PlotView newPlot = new PlotView();

            newPlot.MinX = 0;
            newPlot.MaxX = endDate.Subtract(startDate).TotalDays;
            newPlot.MinY = 0;
            newPlot.MaxY = 1;

            if (this.xAxisProgression != null)
            {
                this.configureXAxisSubdivisions(newPlot);
            }

            newPlot.YAxisSubdivisions = new List <double> {
                0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1
            };

            // compute the rating at each relevant date
            foreach (AbsoluteRating rating in ratings)
            {
                if (rating.Date != null)
                {
                    double x = this.GetXCoordinate((DateTime)rating.Date);
                    // calculate y
                    double y = rating.Score;
                    // make sure we want to include it in the plot (and therefore the regression line)
                    if (x >= newPlot.MinX && x <= newPlot.MaxX)
                    {
                        points.Add(new Datapoint(x, y, 1));
                    }
                }
            }
            newPlot.AddSeries(points, this.showRatingsTrend, this.showRatings, 0);

            // compute a smoothed version of the ratings so we can show which activities are actually worth doing
            // (for example, sleeping might feel boring but might increase later happiness)
            TimeSpan totalDuration = endDate.Subtract(startDate);
            List <ScoreSummarizer> ratingSummarizers = new List <ScoreSummarizer>();

            ratingSummarizers.Add(this.overallRating_summarizer);
            ratingSummarizers.Add(this.overallEfficiency_summarizer);
            foreach (ExponentialRatingSummarizer ratingSummarizer in ratingSummarizers)
            {
                double           i;
                ScoreSummary     ratingSummary   = new ScoreSummary(endDate);
                List <Datapoint> smoothedRatings = new List <Datapoint>();
                double           maxY            = 0;
                for (i = 1; i >= 0; i -= 0.001)
                {
                    TimeSpan currentDuration = new TimeSpan((long)((double)totalDuration.Ticks * (double)i));
                    DateTime when            = startDate.Add(currentDuration);
                    if (when.CompareTo(ratingSummarizer.EarliestKnownDate) < 0)
                    {
                        break;
                    }
                    ratingSummary.Update(ratingSummarizer, when, endDate);
                    if (ratingSummary.Item.Weight > 0)
                    {
                        double x = this.GetXCoordinate(when);
                        double y = ratingSummary.Item.Mean;
                        if (!double.IsNaN(y))
                        {
                            if (ratingSummarizer == this.overallEfficiency_summarizer)
                            {
                                // rescale so that the typical value for this rating summarizer (1) is moved to match the typical value for the other plotted values (0.5)
                                y /= 2;
                            }
                            if (y > maxY)
                            {
                                maxY = y;
                            }
                            smoothedRatings.Add(new Datapoint(x, y, 1));
                        }
                    }
                }
                smoothedRatings.Reverse();
                // if the plot overflowed, rescale it to fit
                if (maxY > 1)
                {
                    foreach (Datapoint datapoint in smoothedRatings)
                    {
                        datapoint.Output = datapoint.Output / maxY;
                    }
                }
                if (ratingSummarizer == this.overallRating_summarizer)
                {
                    newPlot.AddSeries(smoothedRatings, false, this.showOverallHappiness, 2);
                }
                else
                {
                    newPlot.AddSeries(smoothedRatings, this.showEfficiencyTrend, this.showEfficiency, 3);
                }
            }

            DateTime end = DateTime.Now;

            this.ratingsView.SetContent(new ImageLayout(newPlot, LayoutScore.Get_UsedSpace_LayoutScore(1)));

            System.Diagnostics.Debug.WriteLine("spent " + end.Subtract(start) + " to update ratings plot");
        }
Beispiel #4
0
 private bool ShouldIncludeSummary(ScoreSummary summary)
 {
     return(summary.Item.Weight > 0);
 }