Changeset 17726
- Timestamp:
- 08/26/20 16:43:25 (4 years ago)
- Location:
- branches/3040_VectorBasedGP
- Files:
-
- 7 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj
r17502 r17726 141 141 <Compile Include="Plugin.cs" /> 142 142 <Compile Include="SingleObjective\ConstantOptimizationAnalyzer.cs" /> 143 <Compile Include="SingleObjective\Evaluators\VectorUnrollingNonlinearLeastSquaresConstantOptimizationEvaluator.cs" /> 143 144 <Compile Include="SingleObjective\Evaluators\NonlinearLeastSquaresConstantOptimizationEvaluator.cs" /> 144 145 <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" /> -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/VectorUnrollingNonlinearLeastSquaresConstantOptimizationEvaluator.cs
r17725 r17726 30 30 using HeuristicLab.Parameters; 31 31 using HEAL.Attic; 32 using DoubleVector = MathNet.Numerics.LinearAlgebra.Vector<double>; 32 33 33 34 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 34 [StorableType(" 24B68851-036D-4446-BD6F-3823E9028FF4")]35 [Item(" NonlinearLeastSquaresOptimizer", "")]36 public class NonlinearLeastSquaresConstantOptimizationEvaluator : SymbolicRegressionConstantOptimizationEvaluator {35 [StorableType("5F8DB251-C6F7-40AC-BC30-3C55AF655A2F")] 36 [Item("VectorUnrollingNonlinearLeastSquaresConstantOptimizationEvaluator", "")] 37 public class VectorUnrollingNonlinearLeastSquaresConstantOptimizationEvaluator : SymbolicRegressionConstantOptimizationEvaluator { 37 38 38 39 private const string ConstantOptimizationIterationsName = "ConstantOptimizationIterations"; … … 51 52 #endregion 52 53 53 public NonlinearLeastSquaresConstantOptimizationEvaluator()54 public VectorUnrollingNonlinearLeastSquaresConstantOptimizationEvaluator() 54 55 : base() { 55 56 Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptimizationIterationsName, "Determines how many iterations should be calculated while optimizing the constant of a symbolic expression tree(0 indicates other or default stopping criterion).", new IntValue(10))); 56 57 } 57 58 58 protected NonlinearLeastSquaresConstantOptimizationEvaluator(NonlinearLeastSquaresConstantOptimizationEvaluator original, Cloner cloner)59 protected VectorUnrollingNonlinearLeastSquaresConstantOptimizationEvaluator(VectorUnrollingNonlinearLeastSquaresConstantOptimizationEvaluator original, Cloner cloner) 59 60 : base(original, cloner) { 60 61 } 61 62 public override IDeepCloneable Clone(Cloner cloner) { 62 return new NonlinearLeastSquaresConstantOptimizationEvaluator(this, cloner);63 return new VectorUnrollingNonlinearLeastSquaresConstantOptimizationEvaluator(this, cloner); 63 64 } 64 65 [StorableConstructor] 65 protected NonlinearLeastSquaresConstantOptimizationEvaluator(StorableConstructorFlag _) : base(_) { }66 protected VectorUnrollingNonlinearLeastSquaresConstantOptimizationEvaluator(StorableConstructorFlag _) : base(_) { } 66 67 67 68 protected override ISymbolicExpressionTree OptimizeConstants( 68 69 ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows, 69 70 CancellationToken cancellationToken = default(CancellationToken), EvaluationsCounter counter = null) { 70 return OptimizeTree(tree, 71 return OptimizeTree(tree, (SymbolicDataAnalysisExpressionTreeVectorInterpreter)SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, 71 72 problemData, rows, 72 73 ApplyLinearScalingParameter.ActualValue.Value, ConstantOptimizationIterations, UpdateVariableWeights, … … 76 77 public static ISymbolicExpressionTree OptimizeTree( 77 78 ISymbolicExpressionTree tree, 79 SymbolicDataAnalysisExpressionTreeVectorInterpreter interpreter, 78 80 IRegressionProblemData problemData, IEnumerable<int> rows, 79 81 bool applyLinearScaling, int maxIterations, bool updateVariableWeights, 80 82 CancellationToken cancellationToken = default(CancellationToken), EvaluationsCounter counter = null, Action<double[], double, object> iterationCallback = null) { 83 84 var vectorLengths = problemData.Dataset.DoubleVectorVariables 85 .SelectMany(var => problemData.Dataset.GetDoubleVectorValues(var, rows)) 86 .Select(v => v.Count); 87 var vectorlength = vectorLengths.First(); 88 if (vectorLengths.Any(l => l != vectorlength)) 89 throw new InvalidOperationException("All vectors must be of same length."); 90 var evaluationTraces = interpreter.GetIntermediateNodeValues(tree, problemData.Dataset, rows); 91 var evaluationTrace = evaluationTraces.First(); // assume all vector lengths are the same 92 81 93 82 94 // numeric constants in the tree become variables for constant opt … … 85 97 // variable name, variable value (for factor vars) and lag as a DataForVariable object. 86 98 // A dictionary is used to find parameters 87 bool success = TreeToAutoDiffTermConverter.TryConvertToAutoDiff( 88 tree, updateVariableWeights, applyLinearScaling, 99 bool success = VectorUnrollingTreeToAutoDiffTermConverter.TryConvertToAutoDiff( 100 tree, evaluationTrace, 101 updateVariableWeights, applyLinearScaling, 89 102 out var parameters, out var initialConstants, out var func, out var func_grad); 90 103 if (!success) … … 114 127 } else if (ds.VariableHasType<string>(info.variableName)) { 115 128 x[row, col] = ds.GetStringValue(info.variableName, r) == info.variableValue ? 1 : 0; 129 } else if (ds.VariableHasType<DoubleVector>(info.variableName)) { 130 x[row, col] = ds.GetDoubleVectorValue(info.variableName, r)[info.index]; 116 131 } else throw new InvalidProgramException("found a variable of unknown type"); 117 132 col++; … … 182 197 } 183 198 184 private static alglib.ndimensional_pfunc CreatePFunc( TreeToAutoDiffTermConverter.ParametricFunction func) {199 private static alglib.ndimensional_pfunc CreatePFunc(VectorUnrollingTreeToAutoDiffTermConverter.ParametricFunction func) { 185 200 return (double[] c, double[] x, ref double fx, object o) => { 186 201 fx = func(c, x); … … 190 205 } 191 206 192 private static alglib.ndimensional_pgrad CreatePGrad( TreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad) {207 private static alglib.ndimensional_pgrad CreatePGrad(VectorUnrollingTreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad) { 193 208 return (double[] c, double[] x, ref double fx, double[] grad, object o) => { 194 209 var tuple = func_grad(c, x); … … 201 216 202 217 public static bool CanOptimizeConstants(ISymbolicExpressionTree tree) { 203 return TreeToAutoDiffTermConverter.IsCompatible(tree);218 return VectorUnrollingTreeToAutoDiffTermConverter.IsCompatible(tree); 204 219 } 205 220 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/VectorUnrollingTreeToAutoDiffTermConverter.cs
r17725 r17726 25 25 using System.Runtime.Serialization; 26 26 using AutoDiff; 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 29 29 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 30 public class TreeToAutoDiffTermConverter {31 public class VectorUnrollingTreeToAutoDiffTermConverter { 31 32 public delegate double ParametricFunction(double[] vars, double[] @params); 32 33 … … 38 39 public readonly string variableValue; // for factor vars 39 40 public readonly int lag; 40 41 public DataForVariable(string varName, string varValue, int lag) { 41 public readonly int index; // for vectors 42 43 public DataForVariable(string varName, string varValue, int lag, int index) { 42 44 this.variableName = varName; 43 45 this.variableValue = varValue; 44 46 this.lag = lag; 47 this.index = index; 45 48 } 46 49 … … 50 53 return other.variableName.Equals(this.variableName) && 51 54 other.variableValue.Equals(this.variableValue) && 52 other.lag == this.lag; 55 other.lag == this.lag && 56 other.index == this.index; 53 57 } 54 58 55 59 public override int GetHashCode() { 56 return variableName.GetHashCode() ^ variableValue.GetHashCode() ^ lag ;60 return variableName.GetHashCode() ^ variableValue.GetHashCode() ^ lag ^ index; 57 61 } 58 62 } … … 101 105 #endregion 102 106 103 public static bool TryConvertToAutoDiff(ISymbolicExpressionTree tree, bool makeVariableWeightsVariable, bool addLinearScalingTerms, 107 public static bool TryConvertToAutoDiff(ISymbolicExpressionTree tree, 108 IDictionary<ISymbolicExpressionTreeNode, SymbolicDataAnalysisExpressionTreeVectorInterpreter.EvaluationResult> evaluationTrace, 109 bool makeVariableWeightsVariable, bool addLinearScalingTerms, 104 110 out List<DataForVariable> parameters, out double[] initialConstants, 105 111 out ParametricFunction func, … … 107 113 108 114 // use a transformator object which holds the state (variable list, parameter list, ...) for recursive transformation of the tree 109 var transformator = new TreeToAutoDiffTermConverter(makeVariableWeightsVariable, addLinearScalingTerms); 110 AutoDiff.Term term; 115 var transformator = new VectorUnrollingTreeToAutoDiffTermConverter(evaluationTrace, 116 makeVariableWeightsVariable, addLinearScalingTerms); 117 Term term; 111 118 try { 112 term = transformator.ConvertToAutoDiff(tree.Root.GetSubtree(0)) ;119 term = transformator.ConvertToAutoDiff(tree.Root.GetSubtree(0)).Single(); 113 120 var parameterEntries = transformator.parameters.ToArray(); // guarantee same order for keys and values 114 121 var compiledTerm = term.Compile(transformator.variables.ToArray(), … … 128 135 } 129 136 137 private readonly IDictionary<ISymbolicExpressionTreeNode, SymbolicDataAnalysisExpressionTreeVectorInterpreter.EvaluationResult> evaluationTrace; 130 138 // state for recursive transformation of trees 131 private readonly 132 List<double> initialConstants; 139 private readonly List<double> initialConstants; 133 140 private readonly Dictionary<DataForVariable, AutoDiff.Variable> parameters; 134 141 private readonly List<AutoDiff.Variable> variables; … … 136 143 private readonly bool addLinearScalingTerms; 137 144 138 private TreeToAutoDiffTermConverter(bool makeVariableWeightsVariable, bool addLinearScalingTerms) { 145 private VectorUnrollingTreeToAutoDiffTermConverter(IDictionary<ISymbolicExpressionTreeNode, SymbolicDataAnalysisExpressionTreeVectorInterpreter.EvaluationResult> evaluationTrace, 146 bool makeVariableWeightsVariable, bool addLinearScalingTerms) { 147 this.evaluationTrace = evaluationTrace; 139 148 this.makeVariableWeightsVariable = makeVariableWeightsVariable; 140 149 this.addLinearScalingTerms = addLinearScalingTerms; … … 144 153 } 145 154 146 private AutoDiff.Term ConvertToAutoDiff(ISymbolicExpressionTreeNode node) { 147 if (node.Symbol is Constant) { 155 private IList<AutoDiff.Term> ConvertToAutoDiff(ISymbolicExpressionTreeNode node) { 156 IList<Term> BinaryOp(Func<Term, Term, Term> binaryOp, Func<Term, Term> singleElementOp, params IList<Term>[] terms) { 157 if (terms.Length == 1) return terms[0].Select(singleElementOp).ToList(); 158 return terms.Aggregate((acc, vectorizedTerm) => acc.Zip(vectorizedTerm, binaryOp).ToList()); 159 } 160 IList<Term> BinaryOp2(Func<Term, Term, Term> binaryOp, params IList<Term>[] terms) { 161 return terms.Aggregate((acc, vectorizedTerm) => acc.Zip(vectorizedTerm, binaryOp).ToList()); 162 } 163 IList<Term> UnaryOp(Func<Term, Term> unaryOp, IList<Term> term) { 164 return term.Select(unaryOp).ToList(); 165 } 166 167 var evaluationResult = evaluationTrace[node]; 168 169 if (node.Symbol is Constant) { // assume scalar constant 148 170 initialConstants.Add(((ConstantTreeNode)node).Value); 149 171 var var = new AutoDiff.Variable(); 150 172 variables.Add(var); 151 return var;173 return new Term[] { var }; 152 174 } 153 175 if (node.Symbol is Variable || node.Symbol is BinaryFactorVariable) { … … 156 178 // factor variable values are only 0 or 1 and set in x accordingly 157 179 var varValue = factorVarNode != null ? factorVarNode.VariableValue : string.Empty; 158 var par = FindOrCreateParameter(parameters, varNode.VariableName, varValue); 180 var pars = evaluationResult.IsVector 181 ? Enumerable.Range(0, evaluationResult.Vector.Count).Select(i => FindOrCreateParameter(parameters, varNode.VariableName, varValue, index: i)) 182 : FindOrCreateParameter(parameters, varNode.VariableName, varValue).ToEnumerable(); 159 183 160 184 if (makeVariableWeightsVariable) { … … 162 186 var w = new AutoDiff.Variable(); 163 187 variables.Add(w); 164 return AutoDiff.TermBuilder.Product(w, par);188 return pars.Select(par => AutoDiff.TermBuilder.Product(w, par)).ToList(); 165 189 } else { 166 return varNode.Weight * par;190 return pars.Select(par => varNode.Weight * par).ToList(); 167 191 } 168 192 } … … 179 203 products.Add(AutoDiff.TermBuilder.Product(wVar, par)); 180 204 } 181 return AutoDiff.TermBuilder.Sum(products);182 } 183 if (node.Symbol is LaggedVariable) {184 var varNode = node as LaggedVariableTreeNode;185 var par = FindOrCreateParameter(parameters, varNode.VariableName, string.Empty, varNode.Lag);186 187 if (makeVariableWeightsVariable) {188 initialConstants.Add(varNode.Weight);189 var w = new AutoDiff.Variable();190 variables.Add(w);191 return AutoDiff.TermBuilder.Product(w, par);192 } else {193 return varNode.Weight * par;194 }195 }205 return new[] { AutoDiff.TermBuilder.Sum(products) }; 206 } 207 //if (node.Symbol is LaggedVariable) { 208 // var varNode = node as LaggedVariableTreeNode; 209 // var par = FindOrCreateParameter(parameters, varNode.VariableName, string.Empty, varNode.Lag); 210 211 // if (makeVariableWeightsVariable) { 212 // initialConstants.Add(varNode.Weight); 213 // var w = new AutoDiff.Variable(); 214 // variables.Add(w); 215 // return AutoDiff.TermBuilder.Product(w, par); 216 // } else { 217 // return varNode.Weight * par; 218 // } 219 //} 196 220 if (node.Symbol is Addition) { 197 List<AutoDiff.Term> terms = new List<Term>(); 198 foreach (var subTree in node.Subtrees) { 199 terms.Add(ConvertToAutoDiff(subTree)); 200 } 201 return AutoDiff.TermBuilder.Sum(terms); 221 var terms = node.Subtrees.Select(ConvertToAutoDiff).ToArray(); 222 return BinaryOp((a, b) => a + b, a => a, terms); 202 223 } 203 224 if (node.Symbol is Subtraction) { 204 List<AutoDiff.Term> terms = new List<Term>(); 205 for (int i = 0; i < node.SubtreeCount; i++) { 206 AutoDiff.Term t = ConvertToAutoDiff(node.GetSubtree(i)); 207 if (i > 0) t = -t; 208 terms.Add(t); 209 } 210 if (terms.Count == 1) return -terms[0]; 211 else return AutoDiff.TermBuilder.Sum(terms); 225 var terms = node.Subtrees.Select(ConvertToAutoDiff).ToArray(); 226 return BinaryOp((a, b) => a - b, a => -a, terms); 212 227 } 213 228 if (node.Symbol is Multiplication) { 214 List<AutoDiff.Term> terms = new List<Term>(); 215 foreach (var subTree in node.Subtrees) { 216 terms.Add(ConvertToAutoDiff(subTree)); 217 } 218 if (terms.Count == 1) return terms[0]; 219 else return terms.Aggregate((a, b) => new AutoDiff.Product(a, b)); 229 var terms = node.Subtrees.Select(ConvertToAutoDiff).ToArray(); 230 return BinaryOp((a, b) => a * b, a => a, terms); 220 231 } 221 232 if (node.Symbol is Division) { 222 List<AutoDiff.Term> terms = new List<Term>(); 223 foreach (var subTree in node.Subtrees) { 224 terms.Add(ConvertToAutoDiff(subTree)); 225 } 226 if (terms.Count == 1) return 1.0 / terms[0]; 227 else return terms.Aggregate((a, b) => new AutoDiff.Product(a, 1.0 / b)); 233 var terms = node.Subtrees.Select(ConvertToAutoDiff).ToArray(); 234 return BinaryOp((a, b) => a / b, a => 1.0 / a, terms); 228 235 } 229 236 if (node.Symbol is Absolute) { 230 var x1 = ConvertToAutoDiff(node.GetSubtree(0));231 return abs(x1);232 } 233 if (node.Symbol is AnalyticQuotient) {234 var x1 = ConvertToAutoDiff(node.GetSubtree(0));235 var x2 = ConvertToAutoDiff(node.GetSubtree(1));236 return x1 / (TermBuilder.Power(1 + x2 * x2, 0.5));237 }237 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 238 return UnaryOp(abs, term); 239 } 240 //if (node.Symbol is AnalyticQuotient) { 241 // var x1 = ConvertToAutoDiff(node.GetSubtree(0)); 242 // var x2 = ConvertToAutoDiff(node.GetSubtree(1)); 243 // return x1 / (TermBuilder.Power(1 + x2 * x2, 0.5)); 244 //} 238 245 if (node.Symbol is Logarithm) { 239 return AutoDiff.TermBuilder.Log(240 ConvertToAutoDiff(node.GetSubtree(0)));246 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 247 return UnaryOp(TermBuilder.Log, term); 241 248 } 242 249 if (node.Symbol is Exponential) { 243 return AutoDiff.TermBuilder.Exp(244 ConvertToAutoDiff(node.GetSubtree(0)));250 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 251 return UnaryOp(TermBuilder.Exp, term); 245 252 } 246 253 if (node.Symbol is Square) { 247 return AutoDiff.TermBuilder.Power(248 ConvertToAutoDiff(node.GetSubtree(0)), 2.0);254 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 255 return UnaryOp(t => TermBuilder.Power(t, 2.0), term); 249 256 } 250 257 if (node.Symbol is SquareRoot) { 251 return AutoDiff.TermBuilder.Power(252 ConvertToAutoDiff(node.GetSubtree(0)), 0.5);258 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 259 return UnaryOp(t => TermBuilder.Power(t, 0.5), term); 253 260 } 254 261 if (node.Symbol is Cube) { 255 return AutoDiff.TermBuilder.Power(256 ConvertToAutoDiff(node.GetSubtree(0)), 3.0);262 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 263 return UnaryOp(t => TermBuilder.Power(t, 3.0), term); 257 264 } 258 265 if (node.Symbol is CubeRoot) { 259 return cbrt(ConvertToAutoDiff(node.GetSubtree(0))); 266 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 267 return UnaryOp(cbrt, term); 260 268 } 261 269 if (node.Symbol is Sine) { 262 return sin(263 ConvertToAutoDiff(node.GetSubtree(0)));270 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 271 return UnaryOp(sin, term); 264 272 } 265 273 if (node.Symbol is Cosine) { 266 return cos(267 ConvertToAutoDiff(node.GetSubtree(0)));274 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 275 return UnaryOp(cos, term); 268 276 } 269 277 if (node.Symbol is Tangent) { 270 return tan(271 ConvertToAutoDiff(node.GetSubtree(0)));278 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 279 return UnaryOp(tan, term); 272 280 } 273 281 if (node.Symbol is HyperbolicTangent) { 274 return tanh(275 ConvertToAutoDiff(node.GetSubtree(0)));282 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 283 return UnaryOp(tanh, term); 276 284 } 277 285 if (node.Symbol is Erf) { 278 return erf(279 ConvertToAutoDiff(node.GetSubtree(0)));286 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 287 return UnaryOp(erf, term); 280 288 } 281 289 if (node.Symbol is Norm) { 282 return norm(283 ConvertToAutoDiff(node.GetSubtree(0)));290 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 291 return UnaryOp(norm, term); 284 292 } 285 293 if (node.Symbol is StartSymbol) { … … 291 299 variables.Add(alpha); 292 300 var t = ConvertToAutoDiff(node.GetSubtree(0)); 293 return t * alpha + beta; 301 if (t.Count > 1) throw new InvalidOperationException("Tree Result must be scalar value"); 302 return new[] { t[0] * alpha + beta }; 294 303 } else return ConvertToAutoDiff(node.GetSubtree(0)); 295 304 } 305 if (node.Symbol is Sum) { 306 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 307 return new[] { TermBuilder.Sum(term) }; 308 } 309 if (node.Symbol is Mean) { 310 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 311 return new[] { TermBuilder.Sum(term) / term.Count }; 312 } 313 if (node.Symbol is StandardDeviation) { 314 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 315 var mean = TermBuilder.Sum(term) / term.Count; 316 var ssd = TermBuilder.Sum(term.Select(t => TermBuilder.Power(t - mean, 2.0))); 317 return new[] { TermBuilder.Power(ssd / term.Count, 0.5) }; 318 } 319 if (node.Symbol is Length) { 320 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 321 return new[] { TermBuilder.Constant(term.Count) }; 322 } 323 //if (node.Symbol is Min) { 324 //} 325 //if (node.Symbol is Max) { 326 //} 327 if (node.Symbol is Variance) { 328 var term = node.Subtrees.Select(ConvertToAutoDiff).Single(); 329 var mean = TermBuilder.Sum(term) / term.Count; 330 var ssd = TermBuilder.Sum(term.Select(t => TermBuilder.Power(t - mean, 2.0))); 331 return new[] { ssd / term.Count }; 332 } 333 //if (node.Symbol is Skewness) { 334 //} 335 //if (node.Symbol is Kurtosis) { 336 //} 337 //if (node.Symbol is EuclideanDistance) { 338 //} 339 //if (node.Symbol is Covariance) { 340 //} 341 342 296 343 throw new ConversionException(); 297 344 } … … 301 348 // each binary indicator is only necessary once. So we only create a parameter if this combination is not yet available 302 349 private static Term FindOrCreateParameter(Dictionary<DataForVariable, AutoDiff.Variable> parameters, 303 string varName, string varValue = "", int lag = 0 ) {304 var data = new DataForVariable(varName, varValue, lag );350 string varName, string varValue = "", int lag = 0, int index = -1) { 351 var data = new DataForVariable(varName, varValue, lag, index); 305 352 306 353 AutoDiff.Variable par = null; … … 319 366 !(n.Symbol is Variable) && 320 367 !(n.Symbol is BinaryFactorVariable) && 321 !(n.Symbol is FactorVariable) &&322 !(n.Symbol is LaggedVariable) &&368 //!(n.Symbol is FactorVariable) && 369 //!(n.Symbol is LaggedVariable) && 323 370 !(n.Symbol is Constant) && 324 371 !(n.Symbol is Addition) && … … 338 385 !(n.Symbol is StartSymbol) && 339 386 !(n.Symbol is Absolute) && 340 !(n.Symbol is AnalyticQuotient) &&387 //!(n.Symbol is AnalyticQuotient) && 341 388 !(n.Symbol is Cube) && 342 !(n.Symbol is CubeRoot) 389 !(n.Symbol is CubeRoot) && 390 !(n.Symbol is Sum) && 391 !(n.Symbol is Mean) && 392 !(n.Symbol is StandardDeviation) && 393 !(n.Symbol is Length) && 394 //!(n.Symbol is Min) && 395 //!(n.Symbol is Max) && 396 !(n.Symbol is Variance) 397 //!(n.Symbol is Skewness) && 398 //!(n.Symbol is Kurtosis) && 399 //!(n.Symbol is EuclideanDistance) && 400 //!(n.Symbol is Covariance) 343 401 select n).Any(); 344 402 return !containsUnknownSymbol; -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r17593 r17726 161 161 </Compile> 162 162 <Compile Include="Converters\LinearModelToTreeConverter.cs" /> 163 <Compile Include="Converters\VectorUnrollingTreeToAutoDiffTermConverter.cs" /> 163 164 <Compile Include="Converters\VectorTreeSimplifier.cs" /> 164 165 <Compile Include="Converters\TreeSimplifier.cs" /> … … 253 254 <Compile Include="Symbols\Kurtosis.cs" /> 254 255 <Compile Include="Symbols\Skewness.cs" /> 256 <Compile Include="Symbols\SubVector.cs" /> 255 257 <Compile Include="Symbols\WindowedSymbolTreeNode.cs" /> 256 258 <Compile Include="Symbols\WindowedSymbol.cs" /> -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/IWindowedSymbol.cs
r17573 r17726 24 24 25 25 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 26 [StorableType("BB96C8EF-4DB8-4892-B3A3-358F34C06AD6")]27 26 /// <summary> 28 27 /// Any symbol that can use a window (e.g. partial aggregation of a vector) 29 28 /// </summary> 29 [StorableType("BB96C8EF-4DB8-4892-B3A3-358F34C06AD6")] 30 30 public interface IWindowedSymbol : ISymbol { 31 31 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs
r17554 r17726 87 87 Skewness = 60, 88 88 Kurtosis = 61, 89 EuclideanDistance = 62 89 EuclideanDistance = 62, 90 90 Covariance = 63, 91 SubVector = 64, 91 92 92 93 } … … 156 157 public const byte EuclideanDistance = (byte)OpCode.EuclideanDistance; 157 158 public const byte Covariance = (byte)OpCode.Covariance; 159 public const byte SubVector = (byte)OpCode.SubVector; 158 160 159 161 … … 223 225 { typeof(EuclideanDistance), OpCodes.EuclideanDistance }, 224 226 { typeof(Covariance), OpCodes.Covariance }, 227 { typeof(SubVector), OpCodes.SubVector }, 225 228 }; 226 229 -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeVectorInterpreter.cs
r17721 r17726 253 253 } else 254 254 yield return double.NaN; 255 state.Reset(); 256 } 257 } 258 259 public IEnumerable<Dictionary<ISymbolicExpressionTreeNode, EvaluationResult>> GetIntermediateNodeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) { 260 var state = PrepareInterpreterState(tree, dataset); 261 262 foreach (var rowEnum in rows) { 263 int row = rowEnum; 264 var traceDict = new Dictionary<ISymbolicExpressionTreeNode, EvaluationResult>(); 265 var result = Evaluate(dataset, ref row, state, traceDict); 266 traceDict.Add(tree.Root.GetSubtree(0), result); // Add StartSymbol 267 yield return traceDict; 255 268 state.Reset(); 256 269 } … … 353 366 } 354 367 355 private static EvaluationResult AggregateApply(EvaluationResult val, WindowedSymbolTreeNode node,368 private static EvaluationResult WindowedAggregateApply(EvaluationResult val, WindowedSymbolTreeNode node, 356 369 Func<double, double> sFunc = null, 357 370 Func<DoubleVector, double> vFunc = null) { … … 370 383 return EvaluationResult.NaN; 371 384 } 385 private static EvaluationResult WindowedFunctionApply(EvaluationResult val, IWindowedSymbolTreeNode node, 386 Func<double, double> sFunc = null, 387 Func<DoubleVector, DoubleVector> vFunc = null) { 388 var offset = node.Offset; 389 var length = node.Length; 390 391 DoubleVector SubVector(DoubleVector v) { 392 int index = (int)(offset * v.Count); 393 int count = (int)(length * (v.Count - index)); 394 return v.SubVector(index, count); 395 }; 396 397 if (val.IsScalar && sFunc != null) return new EvaluationResult(sFunc(val.Scalar)); 398 if (val.IsVector && vFunc != null) return new EvaluationResult(vFunc(SubVector(val.Vector))); 399 return EvaluationResult.NaN; 400 } 401 372 402 private static EvaluationResult AggregateMultipleApply(EvaluationResult lhs, EvaluationResult rhs, 373 403 Func<DoubleVector, DoubleVector, (DoubleVector, DoubleVector)> lengthStrategy, … … 404 434 } 405 435 406 public virtual EvaluationResult Evaluate(IDataset dataset, ref int row, InterpreterState state) { 436 437 public virtual EvaluationResult Evaluate(IDataset dataset, ref int row, InterpreterState state, 438 IDictionary<ISymbolicExpressionTreeNode, EvaluationResult> traceDict = null) { 439 440 void TraceEvaluation(Instruction instr, EvaluationResult result) { 441 traceDict?.Add(instr.dynamicNode, result); 442 } 443 407 444 Instruction currentInstr = state.NextInstruction(); 408 445 switch (currentInstr.opCode) { 409 446 case OpCodes.Add: { 410 var cur = Evaluate(dataset, ref row, state );447 var cur = Evaluate(dataset, ref row, state, traceDict); 411 448 for (int i = 1; i < currentInstr.nArguments; i++) { 412 var op = Evaluate(dataset, ref row, state );449 var op = Evaluate(dataset, ref row, state, traceDict); 413 450 cur = ArithmeticApply(cur, op, 414 451 (lhs, rhs) => ApplyVectorLengthStrategy(DifferentVectorLengthStrategy, lhs, rhs, 0.0), … … 418 455 (v1, v2) => v1 + v2); 419 456 } 457 TraceEvaluation(currentInstr, cur); 420 458 return cur; 421 459 } 422 460 case OpCodes.Sub: { 423 var cur = Evaluate(dataset, ref row, state );461 var cur = Evaluate(dataset, ref row, state, traceDict); 424 462 for (int i = 1; i < currentInstr.nArguments; i++) { 425 var op = Evaluate(dataset, ref row, state );463 var op = Evaluate(dataset, ref row, state, traceDict); 426 464 cur = ArithmeticApply(cur, op, 427 465 (lhs, rhs) => ApplyVectorLengthStrategy(DifferentVectorLengthStrategy, lhs, rhs, 0.0), … … 431 469 (v1, v2) => v1 - v2); 432 470 } 471 TraceEvaluation(currentInstr, cur); 433 472 return cur; 434 473 } 435 474 case OpCodes.Mul: { 436 var cur = Evaluate(dataset, ref row, state );475 var cur = Evaluate(dataset, ref row, state, traceDict); 437 476 for (int i = 1; i < currentInstr.nArguments; i++) { 438 var op = Evaluate(dataset, ref row, state );477 var op = Evaluate(dataset, ref row, state, traceDict); 439 478 cur = ArithmeticApply(cur, op, 440 479 (lhs, rhs) => ApplyVectorLengthStrategy(DifferentVectorLengthStrategy, lhs, rhs, 1.0), … … 444 483 (v1, v2) => v1.PointwiseMultiply(v2)); 445 484 } 485 TraceEvaluation(currentInstr, cur); 446 486 return cur; 447 487 } 448 488 case OpCodes.Div: { 449 var cur = Evaluate(dataset, ref row, state );489 var cur = Evaluate(dataset, ref row, state, traceDict); 450 490 for (int i = 1; i < currentInstr.nArguments; i++) { 451 var op = Evaluate(dataset, ref row, state );491 var op = Evaluate(dataset, ref row, state, traceDict); 452 492 cur = ArithmeticApply(cur, op, 453 493 (lhs, rhs) => ApplyVectorLengthStrategy(DifferentVectorLengthStrategy, lhs, rhs, 1.0), … … 457 497 (v1, v2) => v1 / v2); 458 498 } 499 TraceEvaluation(currentInstr, cur); 459 500 return cur; 460 501 } 461 502 case OpCodes.Absolute: { 462 var cur = Evaluate(dataset, ref row, state); 463 return FunctionApply(cur, Math.Abs, DoubleVector.Abs); 503 var cur = Evaluate(dataset, ref row, state, traceDict); 504 cur = FunctionApply(cur, Math.Abs, DoubleVector.Abs); 505 TraceEvaluation(currentInstr, cur); 506 return cur; 464 507 } 465 508 case OpCodes.Tanh: { 466 var cur = Evaluate(dataset, ref row, state); 467 return FunctionApply(cur, Math.Tanh, DoubleVector.Tanh); 509 var cur = Evaluate(dataset, ref row, state, traceDict); 510 cur = FunctionApply(cur, Math.Tanh, DoubleVector.Tanh); 511 TraceEvaluation(currentInstr, cur); 512 return cur; 468 513 } 469 514 case OpCodes.Cos: { 470 var cur = Evaluate(dataset, ref row, state); 471 return FunctionApply(cur, Math.Cos, DoubleVector.Cos); 515 var cur = Evaluate(dataset, ref row, state, traceDict); 516 cur = FunctionApply(cur, Math.Cos, DoubleVector.Cos); 517 TraceEvaluation(currentInstr, cur); 518 return cur; 472 519 } 473 520 case OpCodes.Sin: { 474 var cur = Evaluate(dataset, ref row, state); 475 return FunctionApply(cur, Math.Sin, DoubleVector.Sin); 521 var cur = Evaluate(dataset, ref row, state, traceDict); 522 cur = FunctionApply(cur, Math.Sin, DoubleVector.Sin); 523 TraceEvaluation(currentInstr, cur); 524 return cur; 476 525 } 477 526 case OpCodes.Tan: { 478 var cur = Evaluate(dataset, ref row, state); 479 return FunctionApply(cur, Math.Tan, DoubleVector.Tan); 527 var cur = Evaluate(dataset, ref row, state, traceDict); 528 cur = FunctionApply(cur, Math.Tan, DoubleVector.Tan); 529 TraceEvaluation(currentInstr, cur); 530 return cur; 480 531 } 481 532 case OpCodes.Square: { 482 var cur = Evaluate(dataset, ref row, state );483 returnFunctionApply(cur,533 var cur = Evaluate(dataset, ref row, state, traceDict); 534 cur = FunctionApply(cur, 484 535 s => Math.Pow(s, 2), 485 536 v => v.PointwisePower(2)); 537 TraceEvaluation(currentInstr, cur); 538 return cur; 486 539 } 487 540 case OpCodes.Cube: { 488 var cur = Evaluate(dataset, ref row, state );489 returnFunctionApply(cur,541 var cur = Evaluate(dataset, ref row, state, traceDict); 542 cur = FunctionApply(cur, 490 543 s => Math.Pow(s, 3), 491 544 v => v.PointwisePower(3)); 545 TraceEvaluation(currentInstr, cur); 546 return cur; 492 547 } 493 548 case OpCodes.Power: { 494 var x = Evaluate(dataset, ref row, state );495 var y = Evaluate(dataset, ref row, state );496 returnArithmeticApply(x, y,549 var x = Evaluate(dataset, ref row, state, traceDict); 550 var y = Evaluate(dataset, ref row, state, traceDict); 551 var cur = ArithmeticApply(x, y, 497 552 (lhs, rhs) => lhs.Count < rhs.Count 498 553 ? CutLonger(lhs, rhs) … … 502 557 (v1, s2) => v1.PointwisePower(Math.Round(s2)), 503 558 (v1, v2) => v1.PointwisePower(DoubleVector.Round(v2))); 559 TraceEvaluation(currentInstr, cur); 560 return cur; 504 561 } 505 562 case OpCodes.SquareRoot: { 506 var cur = Evaluate(dataset, ref row, state );507 returnFunctionApply(cur,563 var cur = Evaluate(dataset, ref row, state, traceDict); 564 cur = FunctionApply(cur, 508 565 s => Math.Sqrt(s), 509 566 v => DoubleVector.Sqrt(v)); 567 TraceEvaluation(currentInstr, cur); 568 return cur; 510 569 } 511 570 case OpCodes.CubeRoot: { 512 var cur = Evaluate(dataset, ref row, state );513 returnFunctionApply(cur,571 var cur = Evaluate(dataset, ref row, state, traceDict); 572 cur = FunctionApply(cur, 514 573 s => s < 0 ? -Math.Pow(-s, 1.0 / 3.0) : Math.Pow(s, 1.0 / 3.0), 515 574 v => v.Map(s => s < 0 ? -Math.Pow(-s, 1.0 / 3.0) : Math.Pow(s, 1.0 / 3.0))); 575 TraceEvaluation(currentInstr, cur); 576 return cur; 516 577 } 517 578 case OpCodes.Root: { 518 var x = Evaluate(dataset, ref row, state );519 var y = Evaluate(dataset, ref row, state );520 returnArithmeticApply(x, y,579 var x = Evaluate(dataset, ref row, state, traceDict); 580 var y = Evaluate(dataset, ref row, state, traceDict); 581 var cur = ArithmeticApply(x, y, 521 582 (lhs, rhs) => lhs.Count < rhs.Count 522 583 ? CutLonger(lhs, rhs) … … 526 587 (v1, s2) => v1.PointwisePower(1.0 / Math.Round(s2)), 527 588 (v1, v2) => v1.PointwisePower(1.0 / DoubleVector.Round(v2))); 589 TraceEvaluation(currentInstr, cur); 590 return cur; 528 591 } 529 592 case OpCodes.Exp: { 530 var cur = Evaluate(dataset, ref row, state );531 returnFunctionApply(cur,593 var cur = Evaluate(dataset, ref row, state, traceDict); 594 cur = FunctionApply(cur, 532 595 s => Math.Exp(s), 533 596 v => DoubleVector.Exp(v)); 597 TraceEvaluation(currentInstr, cur); 598 return cur; 534 599 } 535 600 case OpCodes.Log: { 536 var cur = Evaluate(dataset, ref row, state );537 returnFunctionApply(cur,601 var cur = Evaluate(dataset, ref row, state, traceDict); 602 cur = FunctionApply(cur, 538 603 s => Math.Log(s), 539 604 v => DoubleVector.Log(v)); 605 TraceEvaluation(currentInstr, cur); 606 return cur; 540 607 } 541 608 case OpCodes.Sum: { 542 var cur = Evaluate(dataset, ref row, state );543 return AggregateApply(cur, (WindowedSymbolTreeNode)currentInstr.dynamicNode,609 var cur = Evaluate(dataset, ref row, state, traceDict); 610 cur = AggregateApply(cur, 544 611 s => s, 545 612 v => v.Sum()); 613 TraceEvaluation(currentInstr, cur); 614 return cur; 546 615 } 547 616 case OpCodes.Mean: { 548 var cur = Evaluate(dataset, ref row, state );549 returnAggregateApply(cur,617 var cur = Evaluate(dataset, ref row, state, traceDict); 618 cur = AggregateApply(cur, 550 619 s => s, 551 620 v => Statistics.Mean(v)); 621 TraceEvaluation(currentInstr, cur); 622 return cur; 552 623 } 553 624 case OpCodes.StandardDeviation: { 554 var cur = Evaluate(dataset, ref row, state );555 returnAggregateApply(cur,625 var cur = Evaluate(dataset, ref row, state, traceDict); 626 cur = AggregateApply(cur, 556 627 s => 0, 557 628 v => Statistics.PopulationStandardDeviation(v)); 629 TraceEvaluation(currentInstr, cur); 630 return cur; 558 631 } 559 632 case OpCodes.Length: { 560 var cur = Evaluate(dataset, ref row, state );561 returnAggregateApply(cur,633 var cur = Evaluate(dataset, ref row, state, traceDict); 634 cur = AggregateApply(cur, 562 635 s => 1, 563 636 v => v.Count); 637 TraceEvaluation(currentInstr, cur); 638 return cur; 564 639 } 565 640 case OpCodes.Min: { 566 var cur = Evaluate(dataset, ref row, state );567 returnAggregateApply(cur,641 var cur = Evaluate(dataset, ref row, state, traceDict); 642 cur = AggregateApply(cur, 568 643 s => s, 569 644 v => Statistics.Minimum(v)); 645 TraceEvaluation(currentInstr, cur); 646 return cur; 570 647 } 571 648 case OpCodes.Max: { 572 var cur = Evaluate(dataset, ref row, state );573 returnAggregateApply(cur,649 var cur = Evaluate(dataset, ref row, state, traceDict); 650 cur = AggregateApply(cur, 574 651 s => s, 575 652 v => Statistics.Maximum(v)); 653 TraceEvaluation(currentInstr, cur); 654 return cur; 576 655 } 577 656 case OpCodes.Variance: { 578 var cur = Evaluate(dataset, ref row, state );579 returnAggregateApply(cur,657 var cur = Evaluate(dataset, ref row, state, traceDict); 658 cur = AggregateApply(cur, 580 659 s => 0, 581 660 v => Statistics.PopulationVariance(v)); 661 TraceEvaluation(currentInstr, cur); 662 return cur; 582 663 } 583 664 case OpCodes.Skewness: { 584 var cur = Evaluate(dataset, ref row, state );585 returnAggregateApply(cur,665 var cur = Evaluate(dataset, ref row, state, traceDict); 666 cur = AggregateApply(cur, 586 667 s => double.NaN, 587 668 v => Statistics.PopulationSkewness(v)); 669 TraceEvaluation(currentInstr, cur); 670 return cur; 588 671 } 589 672 case OpCodes.Kurtosis: { 590 var cur = Evaluate(dataset, ref row, state );591 returnAggregateApply(cur,673 var cur = Evaluate(dataset, ref row, state, traceDict); 674 cur = AggregateApply(cur, 592 675 s => double.NaN, 593 676 v => Statistics.PopulationKurtosis(v)); 677 TraceEvaluation(currentInstr, cur); 678 return cur; 594 679 } 595 680 case OpCodes.EuclideanDistance: { 596 var x1 = Evaluate(dataset, ref row, state );597 var x2 = Evaluate(dataset, ref row, state );598 returnAggregateMultipleApply(x1, x2,681 var x1 = Evaluate(dataset, ref row, state, traceDict); 682 var x2 = Evaluate(dataset, ref row, state, traceDict); 683 var cur = AggregateMultipleApply(x1, x2, 599 684 (lhs, rhs) => ApplyVectorLengthStrategy(DifferentVectorLengthStrategy, lhs, rhs, 0.0), 600 685 (s1, s2) => s1 - s2, … … 602 687 (v1, s2) => Math.Sqrt((v1 - s2).PointwisePower(2).Sum()), 603 688 (v1, v2) => Math.Sqrt((v1 - v2).PointwisePower(2).Sum())); 689 TraceEvaluation(currentInstr, cur); 690 return cur; 604 691 } 605 692 case OpCodes.Covariance: { 606 var x1 = Evaluate(dataset, ref row, state );607 var x2 = Evaluate(dataset, ref row, state );608 returnAggregateMultipleApply(x1, x2,693 var x1 = Evaluate(dataset, ref row, state, traceDict); 694 var x2 = Evaluate(dataset, ref row, state, traceDict); 695 var cur = AggregateMultipleApply(x1, x2, 609 696 (lhs, rhs) => ApplyVectorLengthStrategy(DifferentVectorLengthStrategy, lhs, rhs, 0.0), 610 697 (s1, s2) => 0, … … 612 699 (v1, s2) => 0, 613 700 (v1, v2) => Statistics.PopulationCovariance(v1, v2)); 701 TraceEvaluation(currentInstr, cur); 702 return cur; 703 } 704 case OpCodes.SubVector: { 705 var cur = Evaluate(dataset, ref row, state, traceDict); 706 return WindowedFunctionApply(cur, (WindowedSymbolTreeNode)currentInstr.dynamicNode, 707 s => s, 708 v => v); 614 709 } 615 710 case OpCodes.Variable: { 616 711 if (row < 0 || row >= dataset.Rows) return EvaluationResult.NaN; 617 712 var variableTreeNode = (VariableTreeNode)currentInstr.dynamicNode; 618 if (currentInstr.data is IList<double> doubleList) 619 return new EvaluationResult(doubleList[row] * variableTreeNode.Weight); 620 if (currentInstr.data is IList<DoubleVector> doubleVectorList) 621 return new EvaluationResult(doubleVectorList[row] * variableTreeNode.Weight); 713 if (currentInstr.data is IList<double> doubleList) { 714 var cur = new EvaluationResult(doubleList[row] * variableTreeNode.Weight); 715 TraceEvaluation(currentInstr, cur); 716 return cur; 717 } 718 if (currentInstr.data is IList<DoubleVector> doubleVectorList) { 719 var cur = new EvaluationResult(doubleVectorList[row] * variableTreeNode.Weight); 720 TraceEvaluation(currentInstr, cur); 721 return cur; 722 } 622 723 throw new NotSupportedException($"Unsupported type of variable: {currentInstr.data.GetType().GetPrettyName()}"); 623 724 } … … 625 726 if (row < 0 || row >= dataset.Rows) return EvaluationResult.NaN; 626 727 var factorVarTreeNode = currentInstr.dynamicNode as BinaryFactorVariableTreeNode; 627 return new EvaluationResult(((IList<string>)currentInstr.data)[row] == factorVarTreeNode.VariableValue ? factorVarTreeNode.Weight : 0); 728 var cur = new EvaluationResult(((IList<string>)currentInstr.data)[row] == factorVarTreeNode.VariableValue ? factorVarTreeNode.Weight : 0); 729 TraceEvaluation(currentInstr, cur); 730 return cur; 628 731 } 629 732 case OpCodes.FactorVariable: { 630 733 if (row < 0 || row >= dataset.Rows) return EvaluationResult.NaN; 631 734 var factorVarTreeNode = currentInstr.dynamicNode as FactorVariableTreeNode; 632 return new EvaluationResult(factorVarTreeNode.GetValue(((IList<string>)currentInstr.data)[row])); 735 var cur = new EvaluationResult(factorVarTreeNode.GetValue(((IList<string>)currentInstr.data)[row])); 736 TraceEvaluation(currentInstr, cur); 737 return cur; 633 738 } 634 739 case OpCodes.Constant: { 635 740 var constTreeNode = (ConstantTreeNode)currentInstr.dynamicNode; 636 return new EvaluationResult(constTreeNode.Value); 741 var cur = new EvaluationResult(constTreeNode.Value); 742 TraceEvaluation(currentInstr, cur); 743 return cur; 637 744 } 638 745 -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/SubVector.cs
r17725 r17726 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;25 24 using HEAL.Attic; 26 25 27 26 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 28 [StorableType(" C6C245BF-C44A-4207-A268-55641483F27F")]29 [Item("Su m", "Symbol that represents thesum function.")]30 public sealed class Su m: WindowedSymbol {27 [StorableType("4E9511C6-0FA4-496D-9610-35D9F779F899")] 28 [Item("SubVector", "Symbol that represents SubVector sum function.")] 29 public sealed class SubVector : WindowedSymbol { 31 30 private const int minimumArity = 1; 32 31 private const int maximumArity = 1; … … 40 39 41 40 [StorableConstructor] 42 private Su m(StorableConstructorFlag _) : base(_) { }43 private Su m(Sumoriginal, Cloner cloner) : base(original, cloner) { }41 private SubVector(StorableConstructorFlag _) : base(_) { } 42 private SubVector(SubVector original, Cloner cloner) : base(original, cloner) { } 44 43 public override IDeepCloneable Clone(Cloner cloner) { 45 return new Su m(this, cloner);44 return new SubVector(this, cloner); 46 45 } 47 public Su m() : base("Sum", "Symbol that represents the sumfunction.") { }46 public SubVector() : base("SubVector", "Symbol that represents the SubVector function.") { } 48 47 } 49 48 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Sum.cs
r17573 r17726 28 28 [StorableType("C6C245BF-C44A-4207-A268-55641483F27F")] 29 29 [Item("Sum", "Symbol that represents the sum function.")] 30 public sealed class Sum : WindowedSymbol {30 public sealed class Sum : Symbol { 31 31 private const int minimumArity = 1; 32 32 private const int maximumArity = 1; -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/WindowedSymbol.cs
r17573 r17726 130 130 if (value != manipulatorLengthSigma) { 131 131 manipulatorLengthSigma = value; 132 OnChanged(EventArgs.Empty); ;132 OnChanged(EventArgs.Empty); 133 133 } 134 134 }
Note: See TracChangeset
for help on using the changeset viewer.