- Timestamp:
- 09/22/21 13:55:10 (3 years ago)
- Location:
- branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeVectorInterpreter.cs
r17930 r18058 369 369 Func<DoubleVector, double> vFunc = null) { 370 370 371 var offset = node.Offset; 372 var length = node.Length; 371 // Parameters are interpreted as start and end with wrapping 372 var start = node.Offset; 373 var end = node.Length; 373 374 374 375 DoubleVector SubVector(DoubleVector v) { 375 int index = (int)(offset * v.Count); 376 int count = (int)(length * (v.Count - index)); 377 return v.SubVector(index, count); 378 }; 376 int startIdx = (int)Math.Round(start * v.Count); 377 int endIdx = (int)Math.Round(end * v.Count); 378 int size = v.Count; 379 if (startIdx < endIdx) { 380 return v.SubVector(startIdx, count: endIdx - startIdx); 381 } else { // wrap around 382 var resultVector = DoubleVector.Build.Dense(size: size - (startIdx - endIdx)); 383 v.CopySubVectorTo(resultVector, startIdx, 0, size - startIdx); // copy [startIdx:size] to [0:size-startIdx] 384 v.CopySubVectorTo(resultVector, 0, size - startIdx, endIdx); // copy [0:endIdx] to [size-startIdx:size] 385 return resultVector; 386 } 387 } 379 388 380 389 if (val.IsScalar && sFunc != null) return new EvaluationResult(sFunc(val.Scalar)); … … 385 394 Func<double, double> sFunc = null, 386 395 Func<DoubleVector, DoubleVector> vFunc = null) { 387 var offset = node.Offset; 388 var length = node.Length; 396 // Parameters are interpreted as start and end with wrapping 397 var start = node.Offset; 398 var end = node.Length; 389 399 390 400 DoubleVector SubVector(DoubleVector v) { 391 int index = (int)(offset * v.Count); 392 int count = (int)(length * (v.Count - index)); 393 return v.SubVector(index, count); 394 }; 401 int startIdx = (int)Math.Round(start * v.Count); 402 int endIdx = (int)Math.Round(end * v.Count); 403 int size = v.Count; 404 if (startIdx < endIdx) { 405 return v.SubVector(startIdx, count: endIdx - startIdx); 406 } else { // wrap around 407 var resultVector = DoubleVector.Build.Dense(size: size - (startIdx - endIdx)); 408 v.CopySubVectorTo(resultVector, startIdx, 0, size - startIdx); // copy [startIdx:size] to [0:size-startIdx] 409 v.CopySubVectorTo(resultVector, 0, size - startIdx, endIdx); // copy [0:endIdx] to [size-startIdx:size] 410 return resultVector; 411 } 412 } 395 413 396 414 if (val.IsScalar && sFunc != null) return new EvaluationResult(sFunc(val.Scalar)); -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/WindowedSymbolTreeNode.cs
r17573 r18058 37 37 public double Offset { 38 38 get { return offset; } 39 set { offset = Math.Min(Math.Max(value, 0.0), 1.0); } 39 set { offset = Math.Min(Math.Max(value, 0.0), 1.0); } 40 40 } 41 41 [Storable] … … 88 88 public override string ToString() { 89 89 return Symbol.EnableWindowing 90 ? base.ToString() + $"[{Offset } : {Length}]"90 ? base.ToString() + $"[{Offset:f3} : {Length:f3}]" 91 91 : base.ToString(); 92 92 }
Note: See TracChangeset
for help on using the changeset viewer.