Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Threading.Tasks;
|
---|
6 | using HeuristicLab.Common;
|
---|
7 | using HeuristicLab.Problems.GrammaticalOptimization;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.Algorithms.Bandits.GrammarPolicies {
|
---|
10 | public class RandomPolicy : GrammarPolicy {
|
---|
11 | public RandomPolicy(IProblem problem, bool useCanonicalRepresentation)
|
---|
12 | : base(problem, useCanonicalRepresentation) {
|
---|
13 | }
|
---|
14 |
|
---|
15 | public override bool TrySelect(Random random, string curState, IEnumerable<string> afterStates, out int selectedStateIdx) {
|
---|
16 | // never fail => allows re-visits of terminal states
|
---|
17 | selectedStateIdx = random.Next(afterStates.Count());
|
---|
18 | return true;
|
---|
19 | }
|
---|
20 | }
|
---|
21 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.