- Timestamp:
- 07/29/09 18:28:45 (15 years ago)
- Location:
- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3
- Files:
-
- 2 added
- 1 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/AlgorithmBase.cs
r2161 r2210 36 36 using HeuristicLab.Evolutionary; 37 37 using HeuristicLab.Modeling; 38 using HeuristicLab.GP.Interfaces; 38 39 39 40 namespace HeuristicLab.GP.StructureIdentification { … … 419 420 Model model = new Model(); 420 421 Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true); 421 model.Data = bestModelScope.GetVariableValue<I FunctionTree>("FunctionTree", false);422 model.Data = bestModelScope.GetVariableValue<IGeneticProgrammingModel>("FunctionTree", false); 422 423 model.Dataset = ds; 423 424 model.TargetVariable = ds.GetVariableName(bestModelScope.GetVariableValue<IntData>("TargetVariable", true).Data); -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Constant.cs
r2202 r2210 30 30 using HeuristicLab.Operators; 31 31 using HeuristicLab.Random; 32 using HeuristicLab.GP.Interfaces; 32 33 33 34 namespace HeuristicLab.GP.StructureIdentification { 34 35 public sealed class Constant : Terminal { 35 36 public const string VALUE = "Value"; 36 private BakedFunctionTree constantNodeTemplate;37 37 38 38 public override string Description { … … 48 48 public Constant() 49 49 : base() { 50 DoubleData valueData = new DoubleData();51 constantNodeTemplate = new BakedFunctionTree(this);52 constantNodeTemplate.AddVariable(new HeuristicLab.Core.Variable(VALUE, valueData));53 54 50 SetupInitialization(); 55 51 SetupManipulation(); … … 57 53 58 54 public override IFunctionTree GetTreeNode() { 59 return (IFunctionTree)constantNodeTemplate.Clone();55 return new ConstantFunctionTree(this); 60 56 } 61 57 -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs
r2130 r2210 28 28 using HeuristicLab.Operators; 29 29 using HeuristicLab.DataAnalysis; 30 using HeuristicLab.GP.Interfaces; 30 31 31 32 namespace HeuristicLab.GP.StructureIdentification { … … 34 35 : base() { 35 36 AddVariableInfo(new VariableInfo("TreeEvaluator", "The evaluator that should be used to evaluate the expression tree", typeof(ITreeEvaluator), VariableKind.In)); 36 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IFunctionTree), VariableKind.In)); 37 AddVariableInfo(new VariableInfo("TreeSize", "Size (number of nodes) of the tree to evaluate", typeof(IntData), VariableKind.In)); 37 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IGeneticProgrammingModel), VariableKind.In)); 38 38 AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In)); 39 39 AddVariableInfo(new VariableInfo("TargetVariable", "Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In)); … … 51 51 int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data; 52 52 Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true); 53 I FunctionTree functionTree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);53 IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, true); 54 54 double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data; 55 int treeSize = scope.GetVariableValue<IntData>("TreeSize", true).Data;56 55 double totalEvaluatedNodes = scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data; 57 56 int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data; … … 61 60 bool useEstimatedValues = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, true).Data; 62 61 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 63 evaluator.PrepareForEvaluation(dataset, targetVariable, trainingStart, trainingEnd, punishmentFactor, functionTree);62 evaluator.PrepareForEvaluation(dataset, targetVariable, trainingStart, trainingEnd, punishmentFactor, gpModel.FunctionTree); 64 63 65 64 double[] backupValues = null; … … 86 85 87 86 // update the value of total evaluated nodes 88 scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (end - start);87 scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + gpModel.Size * (end - start); 89 88 return null; 90 89 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableEvaluationImpactCalculator.cs
r2165 r2210 28 28 using HeuristicLab.DataAnalysis; 29 29 using System.Linq; 30 using HeuristicLab.GP.Interfaces; 30 31 31 32 namespace HeuristicLab.GP.StructureIdentification { … … 35 36 : base() { 36 37 AddVariableInfo(new VariableInfo("TreeEvaluator", "The evaluator that should be used to evaluate the expression tree", typeof(ITreeEvaluator), VariableKind.In)); 37 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(I FunctionTree), VariableKind.In));38 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IGeneticProgrammingModel), VariableKind.In)); 38 39 AddVariableInfo(new VariableInfo("TreeSize", "Size (number of nodes) of the tree to evaluate", typeof(IntData), VariableKind.In)); 39 40 AddVariableInfo(new VariableInfo("PunishmentFactor", "Punishment factor for invalid estimations", typeof(DoubleData), VariableKind.In)); … … 43 44 protected override double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, int start, int end) { 44 45 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 45 I FunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);46 IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, true); 46 47 double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data; 47 evaluator.PrepareForEvaluation(dataset, targetVariable, start, end, punishmentFactor, tree);48 evaluator.PrepareForEvaluation(dataset, targetVariable, start, end, punishmentFactor, gpModel.FunctionTree); 48 49 49 50 double[] result = new double[end - start]; -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableQualityImpactCalculator.cs
r2165 r2210 28 28 using HeuristicLab.DataAnalysis; 29 29 using System.Linq; 30 using HeuristicLab.GP.Interfaces; 30 31 31 32 namespace HeuristicLab.GP.StructureIdentification { … … 35 36 : base() { 36 37 AddVariableInfo(new VariableInfo("TreeEvaluator", "The evaluator that should be used to evaluate the expression tree", typeof(ITreeEvaluator), VariableKind.In)); 37 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(I FunctionTree), VariableKind.In));38 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IGeneticProgrammingModel), VariableKind.In)); 38 39 AddVariableInfo(new VariableInfo("TreeSize", "Size (number of nodes) of the tree to evaluate", typeof(IntData), VariableKind.In)); 39 40 AddVariableInfo(new VariableInfo("PunishmentFactor", "Punishment factor for invalid estimations", typeof(DoubleData), VariableKind.In)); … … 42 43 protected override double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, int start, int end) { 43 44 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 44 I FunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);45 IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, true); 45 46 double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data; 46 evaluator.PrepareForEvaluation(dataset, targetVariable, start, end, punishmentFactor, tree);47 evaluator.PrepareForEvaluation(dataset, targetVariable, start, end, punishmentFactor, gpModel.FunctionTree); 47 48 48 49 double[,] result = new double[end - start, 2]; -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjector.cs
r2202 r2210 29 29 using HeuristicLab.Constraints; 30 30 using StructId = HeuristicLab.GP.StructureIdentification; 31 using HeuristicLab.GP.Interfaces; 31 32 32 33 namespace HeuristicLab.GP.StructureIdentification { -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/GreaterThan.cs
r2202 r2210 35 35 36 36 public GreaterThan() : base() { } 37 37 38 } 38 39 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj
r2202 r2210 86 86 <Compile Include="Average.cs" /> 87 87 <Compile Include="BakedTreeEvaluator.cs" /> 88 <Compile Include="BaseClasses\BinaryFunction.cs" />89 <Compile Include="BaseClasses\Terminal.cs" />90 <Compile Include="BaseClasses\UnaryFunction.cs" />91 88 <Compile Include="Constant.cs" /> 92 89 <Compile Include="AlgorithmBase.cs" /> 90 <Compile Include="ConstantFunctionTree.cs" /> 93 91 <Compile Include="Evaluators\SimpleGPEvaluatorBase.cs" /> 92 <Compile Include="VariableFunctionTree.cs" /> 94 93 <Compile Include="TreeEvaluatorBase.cs" /> 95 94 <Compile Include="HL2TreeEvaluator.cs" /> … … 168 167 <Name>HeuristicLab.Evolutionary-3.2</Name> 169 168 </ProjectReference> 169 <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj"> 170 <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project> 171 <Name>HeuristicLab.GP.Interfaces-3.3</Name> 172 </ProjectReference> 170 173 <ProjectReference Include="..\..\HeuristicLab.GP\3.3\HeuristicLab.GP-3.3.csproj"> 171 174 <Project>{1F1CF3ED-374C-4288-995B-93F6B872F571}</Project> … … 221 224 <None Include="HeuristicLab.snk" /> 222 225 <None Include="Properties\AssemblyInfo.frame" /> 226 </ItemGroup> 227 <ItemGroup> 228 <Folder Include="BaseClasses\" /> 223 229 </ItemGroup> 224 230 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLabGPStructureIdentificationPlugin.cs
r1927 r2210 34 34 [Dependency(Dependency = "HeuristicLab.Evolutionary-3.2")] 35 35 [Dependency(Dependency = "HeuristicLab.GP-3.3")] 36 [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")] 36 37 [Dependency(Dependency = "HeuristicLab.Logging-3.2")] 37 38 [Dependency(Dependency = "HeuristicLab.Modeling-3.2")] -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ITreeEvaluator.cs
r2034 r2210 28 28 using System.Diagnostics; 29 29 using HeuristicLab.DataAnalysis; 30 using HeuristicLab.GP.Interfaces; 30 31 31 32 namespace HeuristicLab.GP.StructureIdentification { -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ModelAnalyzerExporter.cs
r2174 r2210 25 25 using System.Text; 26 26 using HeuristicLab.Data; 27 using HeuristicLab.GP.Interfaces; 27 28 28 29 namespace HeuristicLab.GP.StructureIdentification { … … 120 121 121 122 public static string ExportToHL2(this Constant constant, IFunctionTree tree) { 122 HeuristicLab.Core.IItem constantItem = tree.GetLocalVariable(Constant.VALUE).Value; 123 double value; 124 if (constantItem is ConstrainedDoubleData) { 125 value = ((ConstrainedDoubleData)constantItem).Data; 126 } else { 127 value = ((DoubleData)constantItem).Data; 128 } 123 double value = ((ConstantFunctionTree)tree).Value; 129 124 return "[T]Constant(" + value.ToString("r") + ";0;0)"; 130 125 } … … 135 130 136 131 public static string ExportToHL2(this Differential differential, IFunctionTree tree) { 137 HeuristicLab.Core.IItem weightItem = tree.GetLocalVariable(Differential.WEIGHT).Value; 138 double weight; 139 if (weightItem is ConstrainedDoubleData) { 140 weight = ((ConstrainedDoubleData)weightItem).Data; 141 } else { 142 weight = ((DoubleData)weightItem).Data; 143 } 144 var index = tree.GetLocalVariable(Differential.INDEX).Value; 145 var offset = ((ConstrainedDoubleData)tree.GetLocalVariable(Differential.OFFSET).Value).Data; 146 147 return "[T]Differential(" + weight.ToString("r") + ";" + index + ";" + -offset + ")"; 132 var varTree = (VariableFunctionTree)tree; 133 return "[T]Differential(" + varTree.Weight.ToString("r") + ";" + varTree.VariableName + ";" + -varTree.SampleOffset + ")"; 148 134 } 149 135 … … 189 175 190 176 public static string ExportToHL2(this Variable variable, IFunctionTree tree) { 191 HeuristicLab.Core.IItem weightItem = tree.GetLocalVariable(Differential.WEIGHT).Value; 192 double weight; 193 if (weightItem is ConstrainedDoubleData) { 194 weight = ((ConstrainedDoubleData)weightItem).Data; 195 } else { 196 weight = ((DoubleData)weightItem).Data; 197 } 198 string index = ((StringData)tree.GetLocalVariable(Variable.INDEX).Value).Data; 199 double offset = ((ConstrainedIntData)tree.GetLocalVariable(Variable.OFFSET).Value).Data; 200 201 return "[T]Variable(" + weight.ToString("r") + ";" + index + ";" + -offset + ")"; 177 var varTree = (VariableFunctionTree)tree; 178 return "[T]Variable(" + varTree.Weight.ToString("r") + ";" + varTree.VariableName + ";" + -varTree.SampleOffset + ")"; 202 179 } 203 180 -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs
r2161 r2210 159 159 StandardCrossOver crossover = new StandardCrossOver(); 160 160 crossover.Name = "Crossover"; 161 crossover.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";162 161 return crossover; 163 162 } … … 166 165 ProbabilisticTreeCreator treeCreator = new ProbabilisticTreeCreator(); 167 166 treeCreator.Name = "Tree generator"; 168 treeCreator.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";169 167 treeCreator.GetVariableInfo("MinTreeSize").ActualName = "MinInitialTreeSize"; 170 168 return treeCreator; … … 183 181 StochasticMultiBranch multibranch = new StochasticMultiBranch(); 184 182 FullTreeShaker fullTreeShaker = new FullTreeShaker(); 185 fullTreeShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";186 183 fullTreeShaker.GetVariableInfo("ShakingFactor").ActualName = "FullTreeShakingFactor"; 187 184 188 185 OnePointShaker onepointShaker = new OnePointShaker(); 189 onepointShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";190 186 onepointShaker.GetVariableInfo("ShakingFactor").ActualName = "OnePointShakingFactor"; 191 187 ChangeNodeTypeManipulation changeNodeTypeManipulation = new ChangeNodeTypeManipulation(); 192 changeNodeTypeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";193 188 CutOutNodeManipulation cutOutNodeManipulation = new CutOutNodeManipulation(); 194 cutOutNodeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";195 189 DeleteSubTreeManipulation deleteSubTreeManipulation = new DeleteSubTreeManipulation(); 196 deleteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";197 190 SubstituteSubTreeManipulation substituteSubTreeManipulation = new SubstituteSubTreeManipulation(); 198 substituteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";199 191 200 192 IOperator[] manipulators = new IOperator[] { -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolTable.cs
r1529 r2210 26 26 using HeuristicLab.Core; 27 27 using System.Xml; 28 using HeuristicLab.GP.Interfaces; 28 29 29 30 namespace HeuristicLab.GP.StructureIdentification { -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolicExpressionExporter.cs
r1529 r2210 25 25 using System.Text; 26 26 using HeuristicLab.Data; 27 using HeuristicLab.GP.Interfaces; 27 28 28 29 namespace HeuristicLab.GP.StructureIdentification { … … 125 126 126 127 public static string ExportToScheme(this Constant constant, IFunctionTree tree) { 127 return tree.GetLocalVariable(Constant.VALUE).Value.ToString();128 return ((ConstantFunctionTree)tree).Value.ToString("r"); 128 129 } 129 130 … … 173 174 174 175 public static string ExportToScheme(this Variable variable, IFunctionTree tree) { 175 return "(variable " + tree.GetLocalVariable(Variable.WEIGHT).Value + " " + 176 tree.GetLocalVariable(Variable.INDEX).Value + " " + tree.GetLocalVariable(Variable.OFFSET).Value + ")"; 176 var varTree = (VariableFunctionTree)tree; 177 return "(variable " + varTree.Weight.ToString("r") + " " + 178 varTree.VariableName + " " + varTree.SampleOffset + ")"; 177 179 } 178 180 public static string ExportToScheme(this Differential differential, IFunctionTree tree) { 179 return "(differential " + tree.GetLocalVariable(Differential.WEIGHT).Value + " " + 180 tree.GetLocalVariable(Differential.INDEX).Value + " " + tree.GetLocalVariable(Differential.OFFSET).Value + ")"; 181 var varTree = (VariableFunctionTree)tree; 182 return "(differential " + varTree.Weight.ToString("r") + " " + 183 varTree.VariableName + " " + varTree.SampleOffset + ")"; 181 184 } 182 185 -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/TreeEvaluatorBase.cs
r2202 r2210 29 29 using HeuristicLab.DataAnalysis; 30 30 using HeuristicLab.Data; 31 using HeuristicLab.GP.Interfaces; 31 32 32 33 namespace HeuristicLab.GP.StructureIdentification { … … 45 46 public byte arity; 46 47 public byte symbol; 47 public IFunction function;48 48 } 49 49 … … 61 61 minValue = mean - punishmentFactor * range; 62 62 63 BakedFunctionTree bakedTree = functionTree as BakedFunctionTree; 64 if (bakedTree == null) throw new ArgumentException("TreeEvaluators can only evaluate BakedFunctionTrees"); 65 66 List<LightWeightFunction> linearRepresentation = bakedTree.LinearRepresentation; 67 codeArr = new Instr[linearRepresentation.Count]; 63 codeArr = new Instr[functionTree.GetSize()]; 68 64 int i = 0; 69 foreach ( LightWeightFunction f in linearRepresentation) {70 codeArr[i++] = TranslateToInstr( f);65 foreach (IFunctionTree tree in IteratePrefix(functionTree)) { 66 codeArr[i++] = TranslateToInstr(tree); 71 67 } 72 68 } 73 69 74 private Instr TranslateToInstr(LightWeightFunction f) { 70 private IEnumerable<IFunctionTree> IteratePrefix(IFunctionTree functionTree) { 71 List<IFunctionTree> prefixForm = new List<IFunctionTree>(); 72 prefixForm.Add(functionTree); 73 foreach (IFunctionTree subTree in functionTree.SubTrees) { 74 prefixForm.AddRange(IteratePrefix(subTree)); 75 } 76 return prefixForm; 77 } 78 79 private Instr TranslateToInstr(IFunctionTree tree) { 75 80 Instr instr = new Instr(); 76 instr.arity = f.arity;77 instr.symbol = EvaluatorSymbolTable.MapFunction( f.functionType);81 instr.arity = (byte)tree.SubTrees.Count; 82 instr.symbol = EvaluatorSymbolTable.MapFunction(tree.Function); 78 83 switch (instr.symbol) { 79 84 case EvaluatorSymbolTable.DIFFERENTIAL: 80 85 case EvaluatorSymbolTable.VARIABLE: { 81 instr.i_arg0 = (short)dataset.GetVariableIndex((((StringData)f.localData[1].Value).Data)); // var 82 instr.d_arg0 = ((DoubleData)f.localData[0].Value).Data; // weight 83 instr.i_arg1 = (short)((ConstrainedIntData)f.localData[2].Value).Data; // sample-offset 86 VariableFunctionTree varTree = (VariableFunctionTree)tree; 87 instr.i_arg0 = (short)dataset.GetVariableIndex(varTree.VariableName); 88 instr.d_arg0 = varTree.Weight; 89 instr.i_arg1 = (short)varTree.SampleOffset; 84 90 break; 85 91 } 86 92 case EvaluatorSymbolTable.CONSTANT: { 87 instr.d_arg0 = ((DoubleData)f.localData[0].Value).Data; // value 93 ConstantFunctionTree constTree = (ConstantFunctionTree)tree; 94 instr.d_arg0 = constTree.Value; 88 95 break; 89 96 } 90 97 case EvaluatorSymbolTable.UNKNOWN: { 91 instr.function = f.functionType; 92 break; 98 throw new NotSupportedException("Unknown function symbol: " + instr.symbol); 93 99 } 94 100 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Variable.cs
r2202 r2210 30 30 using HeuristicLab.Random; 31 31 using HeuristicLab.Operators; 32 using HeuristicLab.GP.Interfaces; 32 33 33 34 namespace HeuristicLab.GP.StructureIdentification { … … 35 36 public const string WEIGHT = "Weight"; 36 37 public const string OFFSET = "SampleOffset"; 37 public const string INDEX = "Variable"; 38 39 private BakedFunctionTree variableNodeTemplate; 38 public const string VARIABLENAME = "Variable"; 40 39 41 40 private int minOffset; … … 50 49 } 51 50 52 public override IEnumerable<string> LocalParameterNames {53 get {54 return new string[] { WEIGHT, OFFSET, INDEX };55 }56 }57 58 51 public override IFunctionTree GetTreeNode() { 59 return (IFunctionTree)variableNodeTemplate.Clone();52 return new VariableFunctionTree(this); 60 53 } 61 54 62 55 public Variable() 63 56 : base() { 64 //AddVariableInfo(new VariableInfo(INDEX, "The variable name", typeof(StringData), VariableKind.None));65 //GetVariableInfo(INDEX).Local = true;66 //AddVariableInfo(new VariableInfo(WEIGHT, "Weight is multiplied to the feature value", typeof(DoubleData), VariableKind.None));67 //GetVariableInfo(WEIGHT).Local = true;68 //AddVariableInfo(new VariableInfo(OFFSET, "SampleOffset is added to the sample index", typeof(ConstrainedIntData), VariableKind.None));69 //GetVariableInfo(OFFSET).Local = true;70 variableNodeTemplate = new BakedFunctionTree(this);71 72 DoubleData weight = new DoubleData();73 variableNodeTemplate.AddVariable(new HeuristicLab.Core.Variable(WEIGHT, weight));74 75 StringData variable = new StringData();76 variableNodeTemplate.AddVariable(new HeuristicLab.Core.Variable(INDEX, variable));77 78 ConstrainedIntData sampleOffset = new ConstrainedIntData();79 variableNodeTemplate.AddVariable(new HeuristicLab.Core.Variable(OFFSET, sampleOffset));80 81 57 SetupInitialization(); 82 58 SetupManipulation(); … … 87 63 SequentialProcessor seq = new SequentialProcessor(); 88 64 UniformItemChooser variableRandomizer = new UniformItemChooser(); 89 variableRandomizer.GetVariableInfo("Value").ActualName = INDEX;65 variableRandomizer.GetVariableInfo("Value").ActualName = VARIABLENAME; 90 66 variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables"; 91 67 variableRandomizer.Name = "Variable randomizer"; … … 117 93 SequentialProcessor seq = new SequentialProcessor(); 118 94 UniformItemChooser variableRandomizer = new UniformItemChooser(); 119 variableRandomizer.GetVariableInfo("Value").ActualName = INDEX;95 variableRandomizer.GetVariableInfo("Value").ActualName = VARIABLENAME; 120 96 variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables"; 121 97 variableRandomizer.Name = "Variable randomizer"; … … 143 119 144 120 public void SetConstraints(int minSampleOffset, int maxSampleOffset) { 145 ConstrainedIntData offset = (ConstrainedIntData)variableNodeTemplate.GetLocalVariable(OFFSET).Value;146 IntBoundedConstraint offsetConstraint = new IntBoundedConstraint();147 121 this.minOffset = minSampleOffset; 148 122 this.maxOffset = maxSampleOffset; 149 offsetConstraint.LowerBound = minSampleOffset;150 offsetConstraint.LowerBoundEnabled = true;151 offsetConstraint.LowerBoundIncluded = true;152 offsetConstraint.UpperBound = maxSampleOffset;153 offsetConstraint.UpperBoundEnabled = true;154 offsetConstraint.UpperBoundIncluded = true;155 offset.AddConstraint(offsetConstraint);156 157 //ConstrainedIntData index = GetVariableValue<ConstrainedIntData>(INDEX, null, false);158 //IntBoundedConstraint indexConstraint = new IntBoundedConstraint();159 //minIndex = minInputIndex;160 //maxIndex = maxInputIndex;161 //indexConstraint.LowerBound = minInputIndex;162 //indexConstraint.LowerBoundEnabled = true;163 //indexConstraint.LowerBoundIncluded = true;164 //indexConstraint.UpperBound = maxInputIndex;165 //indexConstraint.UpperBoundEnabled = true;166 //indexConstraint.UpperBoundIncluded = true;167 //index.AddConstraint(indexConstraint);168 169 123 SetupInitialization(); 170 124 SetupManipulation();
Note: See TracChangeset
for help on using the changeset viewer.