1 | using HeuristicLab.Common;
|
---|
2 | using HeuristicLab.Core;
|
---|
3 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
4 | using HeuristicLab.Operators;
|
---|
5 | using HeuristicLab.Optimization;
|
---|
6 | using HeuristicLab.Parameters;
|
---|
7 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
8 |
|
---|
9 | namespace 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 | }
|
---|