Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/IntValue/AverageIntValueCrossover.cs @ 16574

Last change on this file since 16574 was 16574, checked in by gkronber, 6 years ago

#2520: changed HeuristicLab.MetaOptimization addon to compile with new HL.Persistence

File size: 1.4 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;
12using HEAL.Attic;
13
14namespace HeuristicLab.Problems.MetaOptimization {
15  [StorableType("FF6DCDF5-434C-4D47-8D67-5BD52BAB2D01")]
16  public class AverageIntValueCrossover : SingleSuccessorOperator, IIntValueCrossover, IStochasticOperator {
17    public ILookupParameter<IRandom> RandomParameter {
18      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
19    }
20
21    public AverageIntValueCrossover() { }
22    [StorableConstructor]
23    protected AverageIntValueCrossover(StorableConstructorFlag _) : base(_) { }
24    protected AverageIntValueCrossover(AverageIntValueCrossover original, Cloner cloner)
25      : base(original, cloner) {
26    }
27    public override IDeepCloneable Clone(Cloner cloner) {
28      return new AverageIntValueCrossover(this, cloner);
29    }
30
31    public void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range) {
32      ApplyStatic(random, value, other, range);
33    }
34
35    public static void ApplyStatic(IRandom random, IntValue value, IntValue other, IntValueRange range) {
36      value.Value = (value.Value + other.Value) / 2;
37    }
38  }
39}
Note: See TracBrowser for help on using the repository browser.