Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/ActionInfos/BernoulliPolicyActionInfo.cs @ 13792

Last change on this file since 13792 was 11849, checked in by gkronber, 10 years ago

#2283: solution reorganization

File size: 1001 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Diagnostics;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7using HeuristicLab.Common;
8
9namespace HeuristicLab.Algorithms.Bandits.BanditPolicies {
10  public class BernoulliPolicyActionInfo : IBanditPolicyActionInfo {
11    public int NumSuccess { get; private set; }
12    public int NumFailure { get; private set; }
13    public int Tries { get { return NumSuccess + NumFailure; } }
14    public double Value {
15      get {
16        return NumSuccess / (double)(Tries);
17      }
18    }
19    public void UpdateReward(double reward) {
20      //Debug.Assert(reward.IsAlmost(0.0) || reward.IsAlmost(1.0));
21
22      //if (reward.IsAlmost(1.0)) NumSuccess++;
23      if (reward > 0) NumSuccess++;
24      else NumFailure++;
25    }
26    public void Reset() {
27      NumSuccess = 0;
28      NumFailure = 0;
29    }
30    public void PrintStats() {
31      Console.WriteLine("expected value {0,5:F2}", Value);
32    }
33  }
34}
Note: See TracBrowser for help on using the repository browser.