Free cookie consent management tool by TermsFeed Policy Generator

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, 9 years ago

#2283: refactoring and bug fixes

File size: 708 bytes
RevLine 
[11708]1using System;
2using System.Collections.Generic;
[11727]3using System.Diagnostics;
[11708]4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
[11727]7using HeuristicLab.Common;
[11708]8
9namespace HeuristicLab.Algorithms.Bandits {
[11732]10  public class RandomPolicy : IPolicy {
[11727]11
[11732]12    public override string ToString() {
13      return "RandomPolicy";
[11708]14    }
15
[11732]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;
[11708]21    }
[11732]22
23    public IPolicyActionInfo CreateActionInfo() {
24      return new EmptyPolicyActionInfo();
[11708]25    }
26  }
27}
Note: See TracBrowser for help on using the repository browser.