Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Diagnostics;
|
---|
4 | using System.Linq;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 |
|
---|
8 | namespace 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.