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 | |
---|
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 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.