Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/DoubleValue/AverageDoubleValueCrossover.cs @ 6421

Last change on this file since 6421 was 6017, checked in by cneumuel, 14 years ago

#1215

  • fixed import of existing algorithm
  • moved operators in subfolders
  • extended tests for SymbolicExpressionGrammar
File size: 1.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Operators;
6using HeuristicLab.Optimization;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8using HeuristicLab.Core;
9using HeuristicLab.Parameters;
10using HeuristicLab.Common;
11using HeuristicLab.Data;
12
13namespace HeuristicLab.Problems.MetaOptimization {
14  [StorableClass]
15  public class AverageDoubleValueCrossover : SingleSuccessorOperator, IDoubleValueCrossover, IStochasticOperator {
16    public ILookupParameter<IRandom> RandomParameter {
17      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
18    }
19
20    public AverageDoubleValueCrossover() { }
21    [StorableConstructor]
22    protected AverageDoubleValueCrossover(bool deserializing) : base(deserializing) { }
23    protected AverageDoubleValueCrossover(AverageDoubleValueCrossover original, Cloner cloner)
24      : base(original, cloner) {
25    }
26    public override IDeepCloneable Clone(Cloner cloner) {
27      return new AverageDoubleValueCrossover(this, cloner);
28    }
29
30    public void Apply(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) {
31      ApplyStatic(random, value, other, range);
32    }
33
34    public static void ApplyStatic(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range) {
35      value.Value = (value.Value + other.Value) / 2;
36      value.Value = range.ApplyStepSize(value.Value);
37    }
38  }
39}
Note: See TracBrowser for help on using the repository browser.