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("FC23D1DD-52F8-44CC-8873-1858449F4385")] public class DiscreteIntValueCrossover : SingleSuccessorOperator, IIntValueCrossover, IStochasticOperator { public ILookupParameter RandomParameter { get { return (LookupParameter)Parameters["Random"]; } } public DiscreteIntValueCrossover() { } [StorableConstructor] protected DiscreteIntValueCrossover(StorableConstructorFlag _) : base(_) { } protected DiscreteIntValueCrossover(DiscreteIntValueCrossover original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new DiscreteIntValueCrossover(this, cloner); } public void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range) { ApplyStatic(random, value, other, range); } public static void ApplyStatic(IRandom random, IntValue value, IntValue other, IntValueRange range) { if (random.NextDouble() > 0.5) { value.Value = other.Value; } } } }