Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Operators/Crossovers/SymbolicExpressionGrammar/SymbolicExpressionGrammarCrossover.cs @ 8574

Last change on this file since 8574 was 8574, checked in by jkarder, 12 years ago

#1853:

  • extracted experiment generation from encoding
  • added creators
  • added crossovers
  • added manipulators
  • added support for parameters of type IFixedValueParameter
  • minor code improvements
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.Encodings.ParameterConfigurationEncoding {
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.