Changeset 5373 for trunk/sources/HeuristicLab.Problems.DataAnalysis
- Timestamp:
- 01/25/11 16:51:30 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3
- Files:
-
- 1 added
- 3 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
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.