Last change
on this file since 13777 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
|
Rev | Line | |
---|
[11732] | 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 |
|
---|
[11742] | 8 | namespace HeuristicLab.Algorithms.Bandits.BanditPolicies {
|
---|
| 9 | public class MeanAndVariancePolicyActionInfo : IBanditPolicyActionInfo {
|
---|
[11732] | 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; } }
|
---|
[12893] | 14 | public double MaxReward { get; private set; }
|
---|
[11732] | 15 | public double RewardVariance { get { return estimator.Variance; } }
|
---|
[11747] | 16 | public double Value {
|
---|
| 17 | get {
|
---|
[11832] | 18 | return AvgReward;
|
---|
[11747] | 19 | }
|
---|
| 20 | }
|
---|
[11732] | 21 |
|
---|
| 22 | public void UpdateReward(double reward) {
|
---|
[12893] | 23 | MaxReward = Math.Max(MaxReward, reward);
|
---|
[11732] | 24 | estimator.UpdateReward(reward);
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | public void Reset() {
|
---|
[12893] | 28 | MaxReward = double.NegativeInfinity;
|
---|
[11732] | 29 | estimator.Reset();
|
---|
| 30 | }
|
---|
[12290] | 31 |
|
---|
| 32 | public override string ToString() {
|
---|
| 33 | return string.Format("{0:N3} {1,3}", AvgReward, Tries);
|
---|
| 34 | }
|
---|
[11732] | 35 | }
|
---|
| 36 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.