Changeset 2202 for branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Constant.cs
- Timestamp:
- 07/28/09 19:24:23 (15 years ago)
- Location:
- branches/GP-Refactoring-713
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Constant.cs
r2174 r2202 32 32 33 33 namespace HeuristicLab.GP.StructureIdentification { 34 public sealed class Constant : FunctionBase{34 public sealed class Constant : Terminal { 35 35 public const string VALUE = "Value"; 36 private BakedFunctionTree constantNodeTemplate; 36 37 37 38 public override string Description { … … 39 40 } 40 41 42 public override IEnumerable<string> LocalParameterNames { 43 get { 44 return new string[] { VALUE }; 45 } 46 } 47 41 48 public Constant() 42 49 : base() { 43 AddVariableInfo(new VariableInfo(VALUE, "The constant value", typeof(DoubleData), VariableKind.None));44 GetVariableInfo(VALUE).Local = true;45 46 50 DoubleData valueData = new DoubleData(); 47 // initialize a default range for the contant value 48 HeuristicLab.Core.Variable value = new HeuristicLab.Core.Variable(VALUE, valueData); 49 AddVariable(value); 51 constantNodeTemplate = new BakedFunctionTree(this); 52 constantNodeTemplate.AddVariable(new HeuristicLab.Core.Variable(VALUE, valueData)); 50 53 51 54 SetupInitialization(); 52 55 SetupManipulation(); 56 } 53 57 54 // constant can't have suboperators55 AddConstraint(new NumberOfSubOperatorsConstraint(0, 0));58 public override IFunctionTree GetTreeNode() { 59 return (IFunctionTree)constantNodeTemplate.Clone(); 56 60 } 57 61 58 62 private void SetupInitialization() { 59 63 // initialization operator 60 AddVariableInfo(new VariableInfo(INITIALIZATION, "Initialization operator-graph for constants", typeof(IOperatorGraph), VariableKind.None));61 GetVariableInfo(INITIALIZATION).Local = false;62 64 CombinedOperator combinedOp = new CombinedOperator(); 63 65 SequentialProcessor initSeq = new SequentialProcessor(); … … 70 72 combinedOp.OperatorGraph.InitialOperator = initSeq; 71 73 initSeq.AddSubOperator(randomizer); 72 AddVariable(new HeuristicLab.Core.Variable(INITIALIZATION, combinedOp));74 Initializer = combinedOp; 73 75 } 74 76 75 77 private void SetupManipulation() { 76 78 // manipulation operator 77 AddVariableInfo(new VariableInfo(MANIPULATION, "Manipulation operator-graph for constants", typeof(IOperatorGraph), VariableKind.None));78 GetVariableInfo(MANIPULATION).Local = false;79 79 CombinedOperator combinedOp = new CombinedOperator(); 80 80 SequentialProcessor manipulationSeq = new SequentialProcessor(); … … 87 87 combinedOp.OperatorGraph.InitialOperator = manipulationSeq; 88 88 manipulationSeq.AddSubOperator(valueAdder); 89 AddVariable(new HeuristicLab.Core.Variable(MANIPULATION, combinedOp));89 Manipulator = combinedOp; 90 90 } 91 91 }
Note: See TracChangeset
for help on using the changeset viewer.