Changeset 13300 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisModelComplexityCalculator.cs
 Timestamp:
 11/19/15 14:15:19 (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisModelComplexityCalculator.cs
r13241 r13300 42 42 return 2; 43 43 } 44 case OpCodes.Add: { 45 double complexity = 0; 46 for (int i = 0; i < node.SubtreeCount; i++) { 47 complexity += CalculateComplexity(node.GetSubtree(i)); 48 } 49 return complexity; 50 } 44 case OpCodes.Add: 51 45 case OpCodes.Sub: { 52 46 double complexity = 0; … … 56 50 return complexity; 57 51 } 58 case OpCodes.Mul: { 59 double complexity = 1; 60 for (int i = 0; i < node.SubtreeCount; i++) { 61 var nodeComplexity = CalculateComplexity(node.GetSubtree(i)); 62 complexity *= nodeComplexity + 1; 63 } 64 return complexity; 65 } 52 case OpCodes.Mul: 66 53 case OpCodes.Div: { 67 54 double complexity = 1; … … 72 59 return complexity; 73 60 } 74 case OpCodes.Sin: { 75 double complexity = CalculateComplexity(node.GetSubtree(0)); 76 return Math.Pow(2.0, complexity); 77 } 78 case OpCodes.Cos: { 79 double complexity = CalculateComplexity(node.GetSubtree(0)); 80 return Math.Pow(2.0, complexity); 81 } 82 case OpCodes.Tan: { 83 double complexity = CalculateComplexity(node.GetSubtree(0)); 84 return Math.Pow(2.0, complexity); 85 } 86 case OpCodes.Exp: { 87 double complexity = CalculateComplexity(node.GetSubtree(0)); 88 return Math.Pow(2.0, complexity); 89 } 61 case OpCodes.Sin: 62 case OpCodes.Cos: 63 case OpCodes.Tan: 64 case OpCodes.Exp: 90 65 case OpCodes.Log: { 91 66 double complexity = CalculateComplexity(node.GetSubtree(0)); … … 100 75 return complexity * complexity * complexity; 101 76 } 102 case OpCodes.Power: { 77 case OpCodes.Power: 78 case OpCodes.Root: { 103 79 double complexity = CalculateComplexity(node.GetSubtree(0)); 104 var exponent Node= node.GetSubtree(1) as ConstantTreeNode;105 if (exponent Node!= null) {106 double exp onent = exponentNode.Value;107 if (exp onent < 0) exponent = Math.Abs(exponent);108 if (exp onent < 1) exponent = 1 / exponent;109 return Math.Pow(complexity, Math.Round(exp onent));80 var exponent = node.GetSubtree(1) as ConstantTreeNode; 81 if (exponent != null) { 82 double expVal = exponent.Value; 83 if (expVal < 0) expVal = Math.Abs(expVal); 84 if (expVal < 1) expVal = 1 / expVal; 85 return Math.Pow(complexity, Math.Round(expVal)); 110 86 } 111 87 112 double exponentComplexity = CalculateComplexity(node.GetSubtree(1)); 113 return Math.Pow(complexity, 2 * exponentComplexity); 114 } 115 case OpCodes.Root: { 116 double complexity = CalculateComplexity(node.GetSubtree(0)); 117 var rootNode = node.GetSubtree(1) as ConstantTreeNode; 118 if (rootNode != null) { 119 double root = rootNode.Value; 120 if (root < 0) root = Math.Abs(root); 121 if (root < 1) root = 1 / root; 122 return Math.Pow(complexity, Math.Round(root)); 123 } 124 125 double rootComplexity = CalculateComplexity(node.GetSubtree(1)); 126 return Math.Pow(complexity, 2 * rootComplexity); 88 double expComplexity = CalculateComplexity(node.GetSubtree(1)); 89 return Math.Pow(complexity, 2 * expComplexity); 127 90 } 128 91
Note: See TracChangeset
for help on using the changeset viewer.