Last change
on this file since 11727 was
11727,
checked in by gkronber, 10 years ago
|
#2283: worked on grammatical optimization problem solvers (simple MCTS done)
|
File size:
911 bytes
|
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 | 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.