using HeuristicLab.Operators; using HeuristicLab.Optimization; using HeuristicLab.Core; using HeuristicLab.Parameters; using HeuristicLab.Common; using HeuristicLab.Data; using HEAL.Attic; namespace HeuristicLab.Problems.MetaOptimization { [StorableType("75E138C6-228B-4501-AE53-D23BCA90AF51")] public class AverageDoubleValueCrossover : SingleSuccessorOperator, IDoubleValueCrossover, IStochasticOperator { public ILookupParameter RandomParameter { get { return (LookupParameter)Parameters["Random"]; } } public AverageDoubleValueCrossover() { } [StorableConstructor] protected AverageDoubleValueCrossover(StorableConstructorFlag _) : base(_) { } protected AverageDoubleValueCrossover(AverageDoubleValueCrossover original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new AverageDoubleValueCrossover(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) { value.Value = (value.Value + other.Value) / 2; value.Value = range.ApplyStepSize(value.Value); } } }