Changeset 5373
- Timestamp:
- 01/25/11 16:51:30 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 added
- 7 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj
r5163 r5373 12 12 <AssemblyName>HeuristicLab.Analysis-3.3</AssemblyName> 13 13 <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> 14 <TargetFrameworkProfile></TargetFrameworkProfile> 14 <TargetFrameworkProfile> 15 </TargetFrameworkProfile> 15 16 <FileAlignment>512</FileAlignment> 16 17 <SignAssembly>true</SignAssembly> … … 131 132 <Compile Include="QualityAnalysis\BestAverageWorstQualityCalculator.cs" /> 132 133 <Compile Include="QualityAnalysis\BestQualityMemorizer.cs" /> 134 <Compile Include="QualityAnalysis\QualityDistributionAnalyzer.cs" /> 133 135 <Compile Include="QualityAnalysis\QualityAnalyzer.cs" /> 134 136 <Compile Include="QualityAnalysis\QualityDifferenceCalculator.cs" /> -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj
r5163 r5373 129 129 <Compile Include="Interfaces\ISymbolicExpressionTreeCreator.cs" /> 130 130 <Compile Include="Interfaces\ISymbolicExpressionTreeCrossover.cs" /> 131 <Compile Include="Interfaces\ISymbolicExpressionTreeNode.cs" /> 131 132 <Compile Include="Manipulators\ChangeNodeTypeManipulation.cs" /> 132 133 <Compile Include="Interfaces\ISymbolicExpressionTreeManipulator.cs" /> -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs
r5287 r5373 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 30 using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols; … … 76 77 77 78 protected override void RecalculateEstimatedValues() { 78 int minLag = 0; 79 var laggedTreeNodes = Model.SymbolicExpressionTree.IterateNodesPrefix().OfType<LaggedVariableTreeNode>(); 80 if (laggedTreeNodes.Any()) 81 minLag = laggedTreeNodes.Min(node => node.Lag); 79 int minLag = GetMinimumLagFromTree(Model.SymbolicExpressionTree.Root); 82 80 IEnumerable<double> calculatedValues = 83 81 from x in Model.GetEstimatedValues(ProblemData, 0 - minLag, ProblemData.Dataset.Rows) … … 93 91 yield return estimatedValues[row]; 94 92 } 93 94 protected int GetMinimumLagFromTree(SymbolicExpressionTreeNode node) { 95 if (node == null) return 0; 96 int lag = 0; 97 98 var laggedTreeNode = node as ILaggedTreeNode; 99 if (laggedTreeNode != null) lag += laggedTreeNode.Lag; 100 if (node.Symbol is Derivative) lag -= 4; 101 102 int subtreeLag = 0; 103 foreach (var subtree in node.SubTrees) { 104 subtreeLag = Math.Min(subtreeLag, GetMinimumLagFromTree(subtree)); 105 } 106 return lag + subtreeLag; 107 } 95 108 } 96 109 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/HeuristicLab.Problems.DataAnalysis.Views-3.3.csproj
r5163 r5373 205 205 <DependentUpon>LaggedVariableView.cs</DependentUpon> 206 206 </Compile> 207 <Compile Include="Symbolic\Symbols\TimeLagView.cs"> 208 <SubType>UserControl</SubType> 209 </Compile> 210 <Compile Include="Symbolic\Symbols\TimeLagView.Designer.cs"> 211 <DependentUpon>TimeLagView.cs</DependentUpon> 212 </Compile> 207 213 <Compile Include="Symbolic\Symbols\VariableView.cs"> 208 214 <SubType>UserControl</SubType> -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj
r5333 r5373 108 108 </ItemGroup> 109 109 <ItemGroup> 110 <Compile Include="Symbolic\Symbols\Derivative.cs" /> 111 <Compile Include="Symbolic\Symbols\Integral.cs" /> 112 <Compile Include="Symbolic\Symbols\TimeLag.cs" /> 110 113 <Compile Include="Symbolic\TypeCoherentExpressionGrammar.cs" /> 111 114 <Compile Include="Symbolic\Symbols\Power.cs" /> … … 133 136 <Compile Include="Evaluators\SimpleVarianceAccountedForEvaluator.cs" /> 134 137 <Compile Include="HeuristicLabProblemsDataAnalysisPlugin.cs" /> 138 <Compile Include="Interfaces\ILaggedTreeNode.cs" /> 135 139 <Compile Include="Interfaces\ISingleObjectiveDataAnalysisProblem.cs" /> 136 140 <Compile Include="Interfaces\IDataAnalysisModel.cs" /> … … 151 155 <Compile Include="Symbolic\SymbolicSimplifier.cs" /> 152 156 <Compile Include="Symbolic\Symbols\Addition.cs" /> 157 <Compile Include="Symbolic\Symbols\LaggedSymbol.cs" /> 153 158 <Compile Include="Symbolic\Symbols\Constant.cs" /> 154 159 <Compile Include="Symbolic\Symbols\ConstantTreeNode.cs" /> 160 <Compile Include="Symbolic\Symbols\LaggedTreeNode.cs" /> 155 161 <Compile Include="Symbolic\Symbols\LaggedVariable.cs" /> 156 162 <Compile Include="Symbolic\Symbols\LaggedVariableTreeNode.cs" /> -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/FullFunctionalExpressionGrammar.cs
r5288 r5373 61 61 var or = new Or(); 62 62 var not = new Not(); 63 64 var timeLag = new TimeLag(); 65 timeLag.InitialFrequency = 0.0; 66 var integral = new Integral(); 67 integral.InitialFrequency = 0.0; 68 var derivative = new Derivative(); 69 derivative.InitialFrequency = 0.0; 70 63 71 var constant = new Constant(); 64 72 constant.MinValue = -20; … … 68 76 laggedVariable.InitialFrequency = 0.0; 69 77 70 var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, pow, exp, @if, gt, lt, and, or, not, constant, variableSymbol, laggedVariable }; 71 var unaryFunctionSymbols = new List<Symbol>() { sin, cos, tan, log, exp, not }; 78 var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, pow, exp, @if, gt, lt, and, or, not, timeLag, integral, derivative, constant, variableSymbol, laggedVariable }; 79 var unaryFunctionSymbols = new List<Symbol>() { sin, cos, tan, log, exp, not, timeLag, integral, derivative }; 80 72 81 var binaryFunctionSymbols = new List<Symbol>() { pow, gt, lt }; 73 82 var functionSymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or }; -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs
r5288 r5373 67 67 68 68 public const byte Power = 22; 69 public const byte TimeLag = 23; 70 public const byte Integral = 24; 71 public const byte Derivative = 25; 69 72 } 70 73 … … 92 95 { typeof(Argument), OpCodes.Arg }, 93 96 { typeof(Power),OpCodes.Power}, 97 { typeof(TimeLag), OpCodes.TimeLag}, 98 { typeof(Integral), OpCodes.Integral}, 99 {typeof(Derivative), OpCodes.Derivative}, 94 100 }; 95 101 private const int ARGUMENT_STACK_SIZE = 1024; … … 244 250 else return -1.0; 245 251 } 252 case OpCodes.TimeLag: { 253 var timeLagTreeNode = (LaggedTreeNode)currentInstr.dynamicNode; 254 if (row + timeLagTreeNode.Lag < 0 || row + timeLagTreeNode.Lag >= dataset.Rows) 255 return double.NaN; 256 257 row += timeLagTreeNode.Lag; 258 double result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); 259 row -= timeLagTreeNode.Lag; 260 return result; 261 } 262 case OpCodes.Integral: { 263 int nextPc = pc; 264 var timeLagTreeNode = (LaggedTreeNode)currentInstr.dynamicNode; 265 if (row + timeLagTreeNode.Lag < 0 || row + timeLagTreeNode.Lag >= dataset.Rows) 266 return double.NaN; 267 double sum = 0.0; 268 for (int i = 0; i < Math.Abs(timeLagTreeNode.Lag); i++) { 269 row += Math.Sign(timeLagTreeNode.Lag); 270 sum += Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); 271 pc = nextPc; 272 } 273 row -= timeLagTreeNode.Lag; 274 sum += Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); 275 return sum; 276 } 277 278 //mkommend: derivate calculation taken from: 279 //http://www.holoborodko.com/pavel/numerical-methods/numerical-derivative/smooth-low-noise-differentiators/ 280 //one sided smooth differentiatior, N = 4 281 // y' = 1/8h (f_i + 2f_i-1, -2 f_i-3 - f_i-4) 282 case OpCodes.Derivative: { 283 if (row - 4 < 0) return double.NaN; 284 int nextPc = pc; 285 double f_0 = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); ; row--; 286 pc = nextPc; 287 double f_1 = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); ; row -= 2; 288 pc = nextPc; 289 double f_3 = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); ; row--; 290 pc = nextPc; 291 double f_4 = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); ; 292 row += 4; 293 294 return (f_0 + 2 * f_1 - 2 * f_3 - f_4) / 8; // h = 1 295 } 246 296 case OpCodes.Call: { 247 297 // evaluate sub-trees -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Integral.cs
r5052 r5373 29 29 [StorableConstructor] 30 30 private Integral(bool deserializing) : base(deserializing) { } 31 pr otectedIntegral(Integral original, Cloner cloner) : base(original, cloner) { }31 private Integral(Integral original, Cloner cloner) : base(original, cloner) { } 32 32 public override IDeepCloneable Clone(Cloner cloner) { return new Integral(this, cloner); } 33 33
Note: See TracChangeset
for help on using the changeset viewer.