Beispiel #1
0
 public override void FillInFromRequest(ActivityRequest request)
 {
     this.ActivityDescriptor = request.FromCategory;
     this.Date  = request.Date;
     this.Score = 1;
     base.FillInFromRequest(request);
 }
Beispiel #2
0
        public static RatingSource FromRequest(ActivityRequest source)
        {
            RatingSource cause = new RatingSource("Request");

            cause.Converted = source;
            return(cause);
        }
        public LayoutChoice_Set MakeLayout(LayoutStack layoutStack)
        {
            Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();

            if (this.SuggestedBadIdea)
            {
                string apology;
                if (this.PredictedValue > 1)
                {
                    // A fun idea that we didn't expect the user to do
                    // We expected the user to get distracted while considering the fun idea
                    apology = "Sorry, I didn't expect you to actually do this! I thought that this suggestion would help you think of a better idea!";
                }
                else
                {
                    // An annoying idea that we didn't expect the user to do
                    // We expected the user to remember how annoying this was and to avoid it and things like it
                    apology = "Sorry, I didn't expect you to actually do this! I thought that this suggestion would remind you to look harder for something better!";
                }
                builder.AddLayout(new TextblockLayout(apology));
            }
            builder.AddLayout(new TextblockLayout(ChosenActivity.Name));
            builder.AddLayout(new TextblockLayout("From " + this.StartDate + " to " + this.EndDate + ", " + ParticipationDurationDividedByAverage + " as long as average. I predict:"));

            GridLayout_Builder nowBuilder = new Horizontal_GridLayout_Builder().Uniform();

            nowBuilder.AddLayout(
                new Vertical_GridLayout_Builder().Uniform()
                .AddLayout(
                    new HelpButtonLayout("Fun (vs average):",
                                         new TextblockLayout("This column shows the amount of happiness you are expected to have while doing this activity at this time, divided by the average amount of happiness you usually have doing other things"),
                                         layoutStack)
                    )
                .AddLayout(coloredRatio(PredictedValue, ComparisonPredictedValue, PredictedCurrentValueStddev))
                .Build()
                );
            nowBuilder.AddLayout(
                new Vertical_GridLayout_Builder().Uniform()
                .AddLayout(
                    new HelpButtonLayout("Future Fun (days):",
                                         new TextblockLayout("This column shows an estimate of the net present value of your happiness at this time after doing this activity, compared to what it usually is. " +
                                                             "This is very similar to computing how many days of happiness you will gain or lose over the next " + Math.Round(UserPreferences.DefaultPreferences.HalfLife.TotalDays / Math.Log(2), 0) +
                                                             " days after doing this."),
                                         layoutStack)
                    )
                .AddLayout(signedColoredValue(ExpectedFutureFun, ComparisonExpectedFutureFun, ExpectedFutureFunStddev))
                .Build()
                );
            nowBuilder.AddLayout(
                new Vertical_GridLayout_Builder().Uniform()
                .AddLayout(
                    new HelpButtonLayout("Future Efficiency (hours):",
                                         new TextblockLayout("This column shows an estimate of the net present value of your efficiency at this time after doing this activity, compared to what it usually is. " +
                                                             "This is very similar to computing how many hours of efficiency you will gain or lose over the next " + Math.Round(UserPreferences.DefaultPreferences.EfficiencyHalflife.TotalDays / Math.Log(2), 0) +
                                                             " days after doing this."),
                                         layoutStack)
                    )
                .AddLayout(signedColoredValue(ExpectedEfficiency, ComparisonExpectedEfficiency, ExpectedEfficiencyStddev))
                .Build()
                );
            builder.AddLayout(nowBuilder.Build());

            builder.AddLayout(new TextblockLayout("If you had done this at " + this.ComparisonDate + ":"));

            GridLayout_Builder laterBuilder = new Horizontal_GridLayout_Builder().Uniform();

            laterBuilder.AddLayout(coloredRatio(ComparisonPredictedValue, 1, 0));
            laterBuilder.AddLayout(signedColoredValue(ComparisonExpectedFutureFun, 1, 0));
            laterBuilder.AddLayout(signedColoredValue(ComparisonExpectedEfficiency, 0, 0));
            builder.AddLayout(laterBuilder.Build());

            ActivityRequest request = new ActivityRequest();

            request.ActivityToBeat = this.ChosenActivity.MakeDescriptor();
            request.Date           = this.StartDate;
            //request.RequestedProcessingTime = TimeSpan.FromSeconds(0.5);
            ActivitiesSuggestion suggestion       = this.engine.MakeRecommendation(request);
            Activity             betterActivity   = this.ActivityDatabase.ResolveDescriptor(suggestion.ActivityDescriptors[0]);
            Prediction           betterPrediction = this.engine.Get_OverallHappiness_ParticipationEstimate(betterActivity, request);
            string       redirectionText;
            Color        redirectionColor;
            Distribution betterFutureHappinessImprovementInDays = this.engine.compute_longtermValue_increase_in_days(betterPrediction.Distribution, this.StartDate, this.StartDate);
            double       improvementInDays = Math.Round(betterFutureHappinessImprovementInDays.Mean - this.ExpectedFutureFun, 1);

            if (improvementInDays <= 0)
            {
                string noIdeasText = "I don't have any better suggestions for things to do at this time.";
                if (ExpectedFutureFun >= 0)
                {
                    if (PredictedValue >= 1)
                    {
                        redirectionText = "Nice! " + noIdeasText; // Happy now, happy later
                    }
                    else
                    {
                        redirectionText = noIdeasText + " Sorry!"; // Happy later, not happy now
                    }
                }
                else
                {
                    if (PredictedValue >= 1)
                    {
                        redirectionText = noIdeasText; // Happy now, not happy later
                    }
                    else
                    {
                        redirectionText = "How about adding a new activity? " + noIdeasText; // Not happy now or later
                    }
                }
                redirectionColor = Color.Green;
            }
            else
            {
                string improvementText = improvementInDays.ToString();
                if (this.Suggested)
                {
                    redirectionText  = "I thought of a better idea: " + betterActivity.Name + ", better by +" + improvementText + " days fun. Sorry for not mentioning this earlier!";
                    redirectionColor = Color.Yellow;
                }
                else
                {
                    if (ExpectedFutureFun >= 0)
                    {
                        redirectionText  = "I suggest that " + betterActivity.Name + " would be even better: +" + improvementText + " days fun.";
                        redirectionColor = Color.Yellow;
                    }
                    else
                    {
                        redirectionText  = "I suggest that " + betterActivity.Name + " would improve your future happiness by " + improvementText + " days.";
                        redirectionColor = Color.Red;
                    }
                }
            }
            builder.AddLayout(new TextblockLayout(redirectionText, redirectionColor));


            return(builder.BuildAnyLayout());
        }
Beispiel #4
0
        public override void PreviewRequest(ActivityRequest newRequest)
        {
            string text = this.textConverter.ConvertToString(newRequest);

            this.addText(text);
        }
Beispiel #5
0
 public virtual void PreviewRequest(ActivityRequest request)
 {
 }
Beispiel #6
0
 public void AddRequest(ActivityRequest newRequest)
 {
     this.PreviewRequest(newRequest);
     this.engine.PutActivityRequestInMemory(newRequest);
 }
Beispiel #7
0
 // adds any additional data based on the fact that this rating was generated by the given ActivityRequest
 public virtual void FillInFromRequest(ActivityRequest request)
 {
     this.Source = RatingSource.FromRequest(request);
 }