source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/BanditPolicies/MeanAndVariancePolicyActionInfo.cs @ 11742

Last change on this file since 11742 was 11742, checked in by gkronber, 6 years ago

#2283 refactoring

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Diagnostics;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7
8namespace HeuristicLab.Algorithms.Bandits.BanditPolicies {
9  public class MeanAndVariancePolicyActionInfo : IBanditPolicyActionInfo {
10    private bool disabled;
11    public bool Disabled { get { return disabled; } }
12    private OnlineMeanAndVarianceEstimator estimator = new OnlineMeanAndVarianceEstimator();
13    public int Tries { get { return estimator.N; } }
14    public double SumReward { get { return estimator.Sum; } }
15    public double AvgReward { get { return estimator.Avg; } }
16    public double RewardVariance { get { return estimator.Variance; } }
17    public double Value { get { return AvgReward; } }
18
19    public void UpdateReward(double reward) {
20      Debug.Assert(!Disabled);
21      estimator.UpdateReward(reward);
22    }
23
24    public void Disable() {
25      disabled = true;
26    }
27
28    public void Reset() {
29      disabled = false;
30      estimator.Reset();
31    }
32
33    public void PrintStats() {
34      Console.WriteLine("avg reward {0,5:F2} disabled {1}", AvgReward, Disabled);
35    }
36  }
37}
Note: See TracBrowser for help on using the repository browser.