using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; using HeuristicLab.Operators; using HeuristicLab.Optimization; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.MetaOptimization { [StorableClass] public class SymbolicExpressionGrammarCrossover : SingleSuccessorOperator, IDoubleValueCrossover, IStochasticOperator { public ILookupParameter RandomParameter { get { return (LookupParameter)Parameters["Random"]; } } public SymbolicExpressionGrammarCrossover() { } [StorableConstructor] protected SymbolicExpressionGrammarCrossover(bool deserializing) : base(deserializing) { } protected SymbolicExpressionGrammarCrossover(SymbolicExpressionGrammarCrossover original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicExpressionGrammarCrossover(this, cloner); } public void Apply(IRandom random, ISymbolicExpressionGrammar value, ISymbolicExpressionGrammar other) { ApplyStatic(random, value, other, range); } public static void ApplyStatic(IRandom random, ISymbolicExpressionGrammar value, ISymbolicExpressionGrammar other) { value.Value = (value.Value + other.Value) / 2; value.Value = range.ApplyStepSize(value.Value); } } }