Last change
on this file since 13398 was
12955,
checked in by gkronber, 9 years ago
|
#2471: implemented deterministic BFS and DFS for iterated symbolic expression construction
|
File size:
1.7 KB
|
Rev | Line | |
---|
[12909] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using HeuristicLab.Common;
|
---|
| 5 | using HeuristicLab.Core;
|
---|
| 6 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
| 7 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 8 | using HeuristicLab.Random;
|
---|
| 9 |
|
---|
| 10 | namespace HeuristicLab.Algorithms.IteratedSymbolicExpressionConstruction {
|
---|
| 11 | [StorableClass]
|
---|
| 12 | [Item("RandomSymbolicExpressionConstructionPolicy", "")]
|
---|
| 13 | public class RandomSymbolicExpressionConstructionPolicy : SymbolicExpressionConstructionPolicyBase {
|
---|
| 14 |
|
---|
| 15 | public RandomSymbolicExpressionConstructionPolicy()
|
---|
| 16 | : base() {
|
---|
| 17 | }
|
---|
| 18 |
|
---|
[12923] | 19 | protected override int Select(IReadOnlyList<object> followStates, IRandom random) {
|
---|
| 20 | var idxs = Enumerable.Range(0, followStates.Count);
|
---|
| 21 | return idxs.SampleRandom(random);
|
---|
[12909] | 22 | }
|
---|
| 23 |
|
---|
[12923] | 24 | public sealed override void Update(IEnumerable<object> stateSequence, double quality) {
|
---|
[12909] | 25 | // ignore
|
---|
| 26 | }
|
---|
| 27 |
|
---|
[12955] | 28 | protected override object CreateState(ISymbolicExpressionTreeNode root, List<ISymbol> actionSequence, ISymbolicExpressionTreeNode parent, int childIdx) {
|
---|
[12909] | 29 | return null; // doesn't use state information
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | #region IItem
|
---|
| 33 | protected RandomSymbolicExpressionConstructionPolicy(RandomSymbolicExpressionConstructionPolicy original, Cloner cloner)
|
---|
| 34 | : base(original, cloner) {
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | [StorableConstructor]
|
---|
| 38 | protected RandomSymbolicExpressionConstructionPolicy(bool deserializing) : base(deserializing) { }
|
---|
| 39 |
|
---|
| 40 | public override HeuristicLab.Common.IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {
|
---|
| 41 | return new RandomSymbolicExpressionConstructionPolicy(this, cloner);
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | #endregion
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.