source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/Policies/RandomPolicy.cs @ 11732

Last change on this file since 11732 was 11732, checked in by gkronber, 6 years ago

#2283: refactoring and bug fixes

File size: 708 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 {
10  public class RandomPolicy : IPolicy {
11
12    public override string ToString() {
13      return "RandomPolicy";
14    }
15
16    public int SelectAction(Random random, IEnumerable<IPolicyActionInfo> actionInfos) {
17      return actionInfos
18        .Select((a, i) => Tuple.Create(a, i))
19        .Where(p => !p.Item1.Disabled)
20        .SelectRandom(random).Item2;
21    }
22
23    public IPolicyActionInfo CreateActionInfo() {
24      return new EmptyPolicyActionInfo();
25    }
26  }
27}
Note: See TracBrowser for help on using the repository browser.