1 | using HeuristicLab.Operators;
|
---|
2 | using HeuristicLab.Optimization;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Parameters;
|
---|
5 | using HeuristicLab.Common;
|
---|
6 | using HeuristicLab.Data;
|
---|
7 | using HEAL.Attic;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.Problems.MetaOptimization {
|
---|
10 | [StorableType("FC23D1DD-52F8-44CC-8873-1858449F4385")]
|
---|
11 | public class DiscreteIntValueCrossover : SingleSuccessorOperator, IIntValueCrossover, IStochasticOperator {
|
---|
12 | public ILookupParameter<IRandom> RandomParameter {
|
---|
13 | get { return (LookupParameter<IRandom>)Parameters["Random"]; }
|
---|
14 | }
|
---|
15 |
|
---|
16 | public DiscreteIntValueCrossover() { }
|
---|
17 | [StorableConstructor]
|
---|
18 | protected DiscreteIntValueCrossover(StorableConstructorFlag _) : base(_) { }
|
---|
19 | protected DiscreteIntValueCrossover(DiscreteIntValueCrossover original, Cloner cloner)
|
---|
20 | : base(original, cloner) {
|
---|
21 | }
|
---|
22 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
23 | return new DiscreteIntValueCrossover(this, cloner);
|
---|
24 | }
|
---|
25 |
|
---|
26 | public void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range) {
|
---|
27 | ApplyStatic(random, value, other, range);
|
---|
28 | }
|
---|
29 |
|
---|
30 | public static void ApplyStatic(IRandom random, IntValue value, IntValue other, IntValueRange range) {
|
---|
31 | if (random.NextDouble() > 0.5) {
|
---|
32 | value.Value = other.Value;
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|
36 | }
|
---|