using System; using System.Collections.Generic; using System.Linq; using System.Text; using HeuristicLab.Operators; using HeuristicLab.Optimization; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Core; using HeuristicLab.Parameters; using HeuristicLab.Common; using HeuristicLab.Data; namespace HeuristicLab.Problems.MetaOptimization { [StorableClass] public class DiscreteDoubleValueCrossover : SingleSuccessorOperator, IDoubleValueCrossover, IStochasticOperator { public ILookupParameter RandomParameter { get { return (LookupParameter)Parameters["Random"]; } } public DiscreteDoubleValueCrossover() { } [StorableConstructor] protected DiscreteDoubleValueCrossover(bool deserializing) : base(deserializing) { } protected DiscreteDoubleValueCrossover(DiscreteDoubleValueCrossover original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new DiscreteDoubleValueCrossover(this, cloner); } public void Apply(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) { ApplyStatic(random, value, other, range); } public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) { if (random.NextDouble() > 0.5) { value.Value = other.Value; } } } }