1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 |
|
---|
23 | using HeuristicLab.Operators;
|
---|
24 | using HeuristicLab.Random;
|
---|
25 | using HeuristicLab.Data;
|
---|
26 | namespace HeuristicLab.GP.StructureIdentification.Networks {
|
---|
27 | public sealed class OpenParameter : Terminal {
|
---|
28 | public const string OFFSET = "SampleOffset";
|
---|
29 | public const string VARIABLENAME = "Variable";
|
---|
30 |
|
---|
31 | private int minOffset;
|
---|
32 | private int maxOffset;
|
---|
33 |
|
---|
34 | public override string Description {
|
---|
35 | get {
|
---|
36 | return @"";
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 | public OpenParameter()
|
---|
41 | : base() {
|
---|
42 | SetupInitialization();
|
---|
43 | SetupManipulation();
|
---|
44 | }
|
---|
45 |
|
---|
46 | public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() {
|
---|
47 | return new OpenParameterFunctionTree(this);
|
---|
48 | }
|
---|
49 |
|
---|
50 | private void SetupInitialization() {
|
---|
51 | CombinedOperator combinedOp = new CombinedOperator();
|
---|
52 | SequentialProcessor seq = new SequentialProcessor();
|
---|
53 | UniformRandomizer offsetRandomizer = new UniformRandomizer();
|
---|
54 | offsetRandomizer.Min = minOffset;
|
---|
55 | offsetRandomizer.Max = maxOffset + 1;
|
---|
56 | offsetRandomizer.GetVariableInfo("Value").ActualName = OFFSET;
|
---|
57 | offsetRandomizer.Name = "Offset Randomizer";
|
---|
58 |
|
---|
59 | combinedOp.OperatorGraph.AddOperator(seq);
|
---|
60 | combinedOp.OperatorGraph.AddOperator(offsetRandomizer);
|
---|
61 | combinedOp.OperatorGraph.InitialOperator = seq;
|
---|
62 | seq.AddSubOperator(offsetRandomizer);
|
---|
63 | Initializer = combinedOp;
|
---|
64 | }
|
---|
65 |
|
---|
66 | private void SetupManipulation() {
|
---|
67 | // manipulation operator
|
---|
68 | CombinedOperator combinedOp = new CombinedOperator();
|
---|
69 | SequentialProcessor seq = new SequentialProcessor();
|
---|
70 | NormalRandomAdder offsetRandomAdder = new NormalRandomAdder();
|
---|
71 | offsetRandomAdder.Mu = 0.0;
|
---|
72 | offsetRandomAdder.Sigma = 1.0;
|
---|
73 | offsetRandomAdder.GetVariableInfo("Value").ActualName = OFFSET;
|
---|
74 | offsetRandomAdder.Name = "Offset Adder";
|
---|
75 | offsetRandomAdder.GetVariableInfo("MinValue").Local = true;
|
---|
76 | offsetRandomAdder.AddVariable(new HeuristicLab.Core.Variable("MinValue", new DoubleData(minOffset)));
|
---|
77 | offsetRandomAdder.GetVariableInfo("MaxValue").Local = true;
|
---|
78 | offsetRandomAdder.AddVariable(new HeuristicLab.Core.Variable("MaxValue", new DoubleData(maxOffset + 1)));
|
---|
79 |
|
---|
80 | combinedOp.OperatorGraph.AddOperator(seq);
|
---|
81 | combinedOp.OperatorGraph.AddOperator(offsetRandomAdder);
|
---|
82 | combinedOp.OperatorGraph.InitialOperator = seq;
|
---|
83 | seq.AddSubOperator(offsetRandomAdder);
|
---|
84 | Manipulator = combinedOp;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public void SetConstraints(int minSampleOffset, int maxSampleOffset) {
|
---|
88 | this.minOffset = minSampleOffset;
|
---|
89 | this.maxOffset = maxSampleOffset;
|
---|
90 | SetupInitialization();
|
---|
91 | SetupManipulation();
|
---|
92 | }
|
---|
93 | }
|
---|
94 | }
|
---|