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 {
|
---|
9 | // stores information that is relevant for most of the policies
|
---|
10 | public class DefaultPolicyActionInfo : IPolicyActionInfo {
|
---|
11 | public bool Disabled { get { return Tries == -1; } }
|
---|
12 | public double SumReward { get; private set; }
|
---|
13 | public double MaxReward { get; private set; }
|
---|
14 | public int Tries { get; private set; }
|
---|
15 |
|
---|
16 | public DefaultPolicyActionInfo() {
|
---|
17 | MaxReward = double.NegativeInfinity;
|
---|
18 | }
|
---|
19 |
|
---|
20 | public void UpdateReward(double reward) {
|
---|
21 | Debug.Assert(!Disabled);
|
---|
22 |
|
---|
23 | Tries++;
|
---|
24 | SumReward += reward;
|
---|
25 | MaxReward = Math.Max(MaxReward, reward);
|
---|
26 | }
|
---|
27 | public void Disable() {
|
---|
28 | this.Tries = -1;
|
---|
29 | this.SumReward = 0.0;
|
---|
30 | }
|
---|
31 | public void Reset() {
|
---|
32 | SumReward = 0.0;
|
---|
33 | Tries = 0;
|
---|
34 | MaxReward = 0.0;
|
---|
35 | }
|
---|
36 | public void PrintStats() {
|
---|
37 | Console.WriteLine("avg reward {0,5:F2} disabled {1}", SumReward / Tries, Disabled);
|
---|
38 | }
|
---|
39 | }
|
---|
40 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.