Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/DoubleValue/DiscreteDoubleValueCrossover.cs @ 16996

Last change on this file since 16996 was 16996, checked in by gkronber, 5 years ago

#2520 Update plugin dependencies and references for HL.MetaOptimization for new persistence

File size: 1.3 KB
Line 
1using HeuristicLab.Operators;
2using HeuristicLab.Optimization;
3using HeuristicLab.Core;
4using HeuristicLab.Parameters;
5using HeuristicLab.Common;
6using HeuristicLab.Data;
7using HEAL.Attic;
8
9namespace HeuristicLab.Problems.MetaOptimization {
10  [StorableType("42E25F0F-0DFF-4501-8930-4972D70955E0")]
11  public class DiscreteDoubleValueCrossover : SingleSuccessorOperator, IDoubleValueCrossover, IStochasticOperator {
12    public ILookupParameter<IRandom> RandomParameter {
13      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
14    }
15
16    public DiscreteDoubleValueCrossover() { }
17    [StorableConstructor]
18    protected DiscreteDoubleValueCrossover(StorableConstructorFlag _) : base(_) { }
19    protected DiscreteDoubleValueCrossover(DiscreteDoubleValueCrossover original, Cloner cloner)
20      : base(original, cloner) {
21    }
22    public override IDeepCloneable Clone(Cloner cloner) {
23      return new DiscreteDoubleValueCrossover(this, cloner);
24    }
25
26    public void Apply(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) {
27      ApplyStatic(random, value, other, range);
28    }
29
30    public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) {
31      if (random.NextDouble() > 0.5) {
32        value.Value = other.Value;
33      }
34    }
35  }
36}
Note: See TracBrowser for help on using the repository browser.