Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/RandomPolicy.cs @ 13757

Last change on this file since 13757 was 11793, checked in by gkronber, 10 years ago

#2283 fixed compile errors and refactoring

File size: 738 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Common;
7using HeuristicLab.Problems.GrammaticalOptimization;
8
9namespace 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.