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 DiscreteIntValueCrossover : SingleSuccessorOperator, IIntValueCrossover, IStochasticOperator { public ILookupParameter RandomParameter { get { return (LookupParameter)Parameters["Random"]; } } public DiscreteIntValueCrossover() { } [StorableConstructor] protected DiscreteIntValueCrossover(bool deserializing) : base(deserializing) { } 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; } } } }