Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/Policies/BanditPolicy.cs @ 11727

Last change on this file since 11727 was 11727, checked in by gkronber, 8 years ago

#2283: worked on grammatical optimization problem solvers (simple MCTS done)

File size: 911 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Diagnostics;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7
8namespace HeuristicLab.Algorithms.Bandits {
9  public abstract class BanditPolicy : IPolicy {
10    public IEnumerable<int> Actions { get; private set; }
11    private readonly int numInitialActions;
12
13    protected BanditPolicy(int numActions) {
14      this.numInitialActions = numActions;
15      Actions = Enumerable.Range(0, numActions).ToArray();
16    }
17
18    public abstract int SelectAction();
19    public abstract void UpdateReward(int action, double reward);
20
21    public virtual void DisableAction(int action) {
22      Debug.Assert(Actions.Contains(action));
23
24      Actions = Actions.Where(a => a != action).ToArray();
25    }
26
27    public virtual void Reset() {
28      Actions = Enumerable.Range(0, numInitialActions).ToArray();
29    }
30  }
31}
Note: See TracBrowser for help on using the repository browser.