source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/Policies/MeanAndVariancePolicyActionInfo.cs @ 11732

Last change on this file since 11732 was 11732, checked in by gkronber, 5 years ago

#2283: refactoring and bug fixes

File size: 1.1 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 {
9  public class MeanAndVariancePolicyActionInfo : IPolicyActionInfo {
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
18    public void UpdateReward(double reward) {
19      Debug.Assert(!Disabled);
20      estimator.UpdateReward(reward);
21    }
22
23    public void Disable() {
24      disabled = true;
25    }
26
27    public void Reset() {
28      disabled = false;
29      estimator.Reset();
30    }
31
32    public void PrintStats() {
33      Console.WriteLine("avg reward {0,5:F2} disabled {1}", AvgReward, Disabled);
34    }
35  }
36}
Note: See TracBrowser for help on using the repository browser.