Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Algorithms.Bandits/ActionInfos/MeanAndVariancePolicyActionInfo.cs @ 13264

Last change on this file since 13264 was 12893, checked in by gkronber, 9 years ago

#2283: experiments on grammatical optimization algorithms (maxreward instead of avg reward, ...)

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.BanditPolicies {
9  public class MeanAndVariancePolicyActionInfo : IBanditPolicyActionInfo {
10    private OnlineMeanAndVarianceEstimator estimator = new OnlineMeanAndVarianceEstimator();
11    public int Tries { get { return estimator.N; } }
12    public double SumReward { get { return estimator.Sum; } }
13    public double AvgReward { get { return estimator.Avg; } }
14    public double MaxReward { get; private set; }
15    public double RewardVariance { get { return estimator.Variance; } }
16    public double Value {
17      get {
18        return AvgReward;
19      }
20    }
21
22    public void UpdateReward(double reward) {
23      MaxReward = Math.Max(MaxReward, reward);
24      estimator.UpdateReward(reward);
25    }
26
27    public void Reset() {
28      MaxReward = double.NegativeInfinity;
29      estimator.Reset();
30    }
31
32    public override string ToString() {
33      return string.Format("{0:N3} {1,3}", AvgReward, Tries);
34    }
35  }
36}
Note: See TracBrowser for help on using the repository browser.