1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Operators;
|
---|
6 | using HeuristicLab.Optimization;
|
---|
7 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
8 | using HeuristicLab.Core;
|
---|
9 | using HeuristicLab.Parameters;
|
---|
10 | using HeuristicLab.Common;
|
---|
11 | using HeuristicLab.Data;
|
---|
12 | using HEAL.Attic;
|
---|
13 |
|
---|
14 | namespace 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 | }
|
---|