Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Algorithms.Bandits/Policies/RandomPolicy.cs @ 13585

Last change on this file since 13585 was 11806, checked in by gkronber, 10 years ago

#2283: separated value-states from done-states in GenericGrammarPolicy and removed disabling of actions from bandit policies

File size: 715 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Diagnostics;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7using HeuristicLab.Common;
8
9namespace HeuristicLab.Algorithms.Bandits.BanditPolicies {
10  public class RandomPolicy : IBanditPolicy {
11
12    public override string ToString() {
13      return "RandomPolicy";
14    }
15
16    public int SelectAction(Random random, IEnumerable<IBanditPolicyActionInfo> actionInfos) {
17      return actionInfos
18        .Select((aInfo, idx) => Tuple.Create(aInfo, idx))
19        .SelectRandom(random).Item2;
20    }
21
22    public IBanditPolicyActionInfo CreateActionInfo() {
23      return new DefaultPolicyActionInfo();
24    }
25  }
26}
Note: See TracBrowser for help on using the repository browser.