Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/GrammarPolicies/RandomPolicy.cs @ 11770

Last change on this file since 11770 was 11770, checked in by gkronber, 9 years ago

#2283: worked on generic sequential search alg with bandit policy as parameter

File size: 765 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, ReadonlySequence curState, IEnumerable<ReadonlySequence> afterStates, out ReadonlySequence selectedState) {
16      // never fail => allows re-visits of terminal states
17      selectedState = afterStates.SelectRandom(random);
18      return true;
19    }
20  }
21}
Note: See TracBrowser for help on using the repository browser.