source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/BanditPolicies/RandomPolicy.cs @ 11742

Last change on this file since 11742 was 11742, checked in by gkronber, 7 years ago

#2283 refactoring

File size: 755 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        .Where(p => !p.Item1.Disabled)
20        .SelectRandom(random).Item2;
21    }
22
23    public IBanditPolicyActionInfo CreateActionInfo() {
24      return new DefaultPolicyActionInfo();
25    }
26  }
27}
Note: See TracBrowser for help on using the repository browser.