Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/29/14 11:02:36 (8 years ago)
Author:
gkronber
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/Policies/BanditPolicy.cs

    r11711 r11727  
    11using System;
    22using System.Collections.Generic;
     3using System.Diagnostics;
    34using System.Linq;
    45using System.Text;
     
    78namespace HeuristicLab.Algorithms.Bandits {
    89  public abstract class BanditPolicy : IPolicy {
    9     public int NumActions { get; private set; }
    10     public BanditPolicy(int numActions) {
    11       this.NumActions = numActions;
     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();
    1216    }
    1317
    1418    public abstract int SelectAction();
    1519    public abstract void UpdateReward(int action, double reward);
    16     public abstract void Reset();
     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    }
    1730  }
    1831}
Note: See TracChangeset for help on using the changeset viewer.