Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/SymbolicExpressionGrammar/SymbolicExpressionGrammarCrossover.cs @ 6017

Last change on this file since 6017 was 6017, checked in by cneumuel, 14 years ago

#1215

  • fixed import of existing algorithm
  • moved operators in subfolders
  • extended tests for SymbolicExpressionGrammar
File size: 1.5 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
4using HeuristicLab.Operators;
5using HeuristicLab.Optimization;
6using HeuristicLab.Parameters;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8
9namespace HeuristicLab.Problems.MetaOptimization {
10  [StorableClass]
11  public class SymbolicExpressionGrammarCrossover : SingleSuccessorOperator, IDoubleValueCrossover, IStochasticOperator {
12    public ILookupParameter<IRandom> RandomParameter {
13      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
14    }
15
16    public SymbolicExpressionGrammarCrossover() { }
17    [StorableConstructor]
18    protected SymbolicExpressionGrammarCrossover(bool deserializing) : base(deserializing) { }
19    protected SymbolicExpressionGrammarCrossover(SymbolicExpressionGrammarCrossover original, Cloner cloner)
20      : base(original, cloner) {
21    }
22    public override IDeepCloneable Clone(Cloner cloner) {
23      return new SymbolicExpressionGrammarCrossover(this, cloner);
24    }
25
26    public void Apply(IRandom random, ISymbolicExpressionGrammar value, ISymbolicExpressionGrammar other) {
27      ApplyStatic(random, value, other, range);
28    }
29
30    public static void ApplyStatic(IRandom random, ISymbolicExpressionGrammar value, ISymbolicExpressionGrammar other) {
31      value.Value = (value.Value + other.Value) / 2;
32      value.Value = range.ApplyStepSize(value.Value);
33    }
34  }
35}
Note: See TracBrowser for help on using the repository browser.