Changeset 18027 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic
- Timestamp:
- 07/20/21 18:13:55 (3 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 1 deleted
- 9 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 17929,17931,17958,17963-17964,17993
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeSimplifier.cs
r17928 r18027 784 784 } else if (IsExp(node)) { 785 785 return MakeExp(MakeProduct(node.GetSubtree(0), MakeConstant(2.0))); // sqr(exp(x)) = exp(2x) 786 } else if (IsSquare(node)) { 787 return MakePower(node.GetSubtree(0), MakeConstant(4)); 786 788 } else if (IsCube(node)) { 787 789 return MakePower(node.GetSubtree(0), MakeConstant(6)); … … 809 811 } else if (IsSquare(node)) { 810 812 return MakePower(node.GetSubtree(0), MakeConstant(6)); 813 } else if (IsCube(node)) { 814 return MakePower(node.GetSubtree(0), MakeConstant(9)); 811 815 } else { 812 816 var cubeNode = cubeSymbol.CreateTreeNode(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionPythonFormatter.cs
r17928 r18027 58 58 } 59 59 60 private st ring GenerateHeader(ISymbolicExpressionTree symbolicExpressionTree) {60 private static string GenerateHeader(ISymbolicExpressionTree symbolicExpressionTree) { 61 61 StringBuilder strBuilder = new StringBuilder(); 62 62 … … 102 102 } 103 103 104 private st ring GenerateNecessaryImports(int mathLibCounter, int statisticLibCounter) {104 private static string GenerateNecessaryImports(int mathLibCounter, int statisticLibCounter) { 105 105 StringBuilder strBuilder = new StringBuilder(); 106 106 if (mathLibCounter > 0 || statisticLibCounter > 0) { … … 115 115 } 116 116 117 private st ring GenerateIfThenElseSource(int evaluateIfCounter) {117 private static string GenerateIfThenElseSource(int evaluateIfCounter) { 118 118 StringBuilder strBuilder = new StringBuilder(); 119 119 if (evaluateIfCounter > 0) { … … 128 128 } 129 129 130 private st ring GenerateModelEvaluationFunction(ISet<string> variables) {130 private static string GenerateModelEvaluationFunction(ISet<string> variables) { 131 131 StringBuilder strBuilder = new StringBuilder(); 132 132 strBuilder.Append("def evaluate("); … … 142 142 } 143 143 144 private void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {144 private static void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 145 145 ISymbol symbol = node.Symbol; 146 146 if (symbol is ProgramRootSymbol) … … 208 208 } 209 209 210 private st ring VariableName2Identifier(string variableName) => variableName.Replace(" ", "_");211 212 private void FormatNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, string prefixSymbol = "", string openingSymbol = "(", string closingSymbol = ")", string infixSymbol = ",") {210 private static string VariableName2Identifier(string variableName) => variableName.Replace(" ", "_"); 211 212 private static void FormatNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, string prefixSymbol = "", string openingSymbol = "(", string closingSymbol = ")", string infixSymbol = ",") { 213 213 strBuilder.Append($"{prefixSymbol}{openingSymbol}"); 214 214 foreach (var child in node.Subtrees) { … … 220 220 } 221 221 222 private void FormatVariableTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {222 private static void FormatVariableTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 223 223 var varNode = node as VariableTreeNode; 224 224 var formattedVariable = VariableName2Identifier(varNode.VariableName); … … 227 227 } 228 228 229 private void FormatConstantTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {229 private static void FormatConstantTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 230 230 var constNode = node as ConstantTreeNode; 231 231 strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture)); 232 232 } 233 233 234 private void FormatPower(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, string exponent) {234 private static void FormatPower(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, string exponent) { 235 235 strBuilder.Append("math.pow("); 236 236 FormatRecursively(node.GetSubtree(0), strBuilder); … … 238 238 } 239 239 240 private void FormatRoot(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {240 private static void FormatRoot(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 241 241 strBuilder.Append("math.pow("); 242 242 FormatRecursively(node.GetSubtree(0), strBuilder); … … 246 246 } 247 247 248 private void FormatSubtraction(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {248 private static void FormatSubtraction(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 249 249 if (node.SubtreeCount == 1) { 250 250 strBuilder.Append("-"); … … 256 256 } 257 257 258 private void FormatDivision(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {258 private static void FormatDivision(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 259 259 strBuilder.Append("("); 260 260 if (node.SubtreeCount == 1) { … … 273 273 } 274 274 275 private void FormatAnalyticQuotient(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {275 private static void FormatAnalyticQuotient(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 276 276 strBuilder.Append("("); 277 277 FormatRecursively(node.GetSubtree(0), strBuilder); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r17928 r18027 99 99 </PropertyGroup> 100 100 <ItemGroup> 101 <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 102 <HintPath>..\..\bin\ALGLIB-3.7.0.dll</HintPath> 101 <Reference Include="ALGLIB-3.17.0, Version=3.17.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 102 <SpecificVersion>False</SpecificVersion> 103 <HintPath>..\..\bin\ALGLIB-3.17.0.dll</HintPath> 103 104 <Private>False</Private> 104 105 </Reference> … … 158 159 <Compile Include="Formatters\SymbolicDataAnalysisExpressionCSharpFormatter.cs" /> 159 160 <Compile Include="Grammars\DataAnalysisGrammar.cs" /> 160 <Compile Include="Grammars\ IntervalArithmeticGrammar.cs" />161 <Compile Include="Grammars\LinearScalingGrammar.cs" /> 161 162 <Compile Include="Hashing\HashExtensions.cs" /> 162 163 <Compile Include="Hashing\HashUtil.cs" /> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalArithBoundsEstimator.cs
r17928 r18027 223 223 break; 224 224 } 225 case OpCodes.Power: { 226 var a = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals); 227 var b = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals); 228 // support only integer powers 229 if (b.LowerBound == b.UpperBound && Math.Truncate(b.LowerBound) == b.LowerBound) { 230 result = Interval.Power(a, (int)b.LowerBound); 231 } else { 232 throw new NotSupportedException("Interval is only supported for integer powers"); 233 } 234 break; 235 } 225 236 case OpCodes.Absolute: { 226 237 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals); … … 329 340 !(n.Symbol is Cube) && 330 341 !(n.Symbol is CubeRoot) && 342 !(n.Symbol is Power) && 331 343 !(n.Symbol is Absolute) && 332 344 !(n.Symbol is AnalyticQuotient) -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalInterpreter.cs
r17928 r18027 283 283 break; 284 284 } 285 case OpCodes.Power: { 286 var a = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals); 287 var b = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals); 288 // support only integer powers 289 if (b.LowerBound == b.UpperBound && Math.Truncate(b.LowerBound) == b.LowerBound) { 290 result = Interval.Power(a, (int)b.LowerBound); 291 } else { 292 throw new NotSupportedException("Interval is only supported for integer powers"); 293 } 294 break; 295 } 296 285 297 case OpCodes.Absolute: { 286 298 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals); … … 309 321 310 322 public static bool IsCompatible(ISymbolicExpressionTree tree) { 311 var containsUnknownSymbols = ( 312 from n in tree.Root.GetSubtree(0).IterateNodesPrefix() 313 where 323 foreach (var n in tree.Root.GetSubtree(0).IterateNodesPrefix()) { 324 if ( 314 325 !(n.Symbol is Variable) && 315 326 !(n.Symbol is Constant) && … … 329 340 !(n.Symbol is Cube) && 330 341 !(n.Symbol is CubeRoot) && 342 !(n.Symbol is Power) && 331 343 !(n.Symbol is Absolute) && 332 !(n.Symbol is AnalyticQuotient) 333 select n).Any(); 334 return !containsUnknownSymbols; 344 !(n.Symbol is AnalyticQuotient)) return false; 345 346 else if (n.Symbol is Power) { 347 // only integer exponents are supported 348 var exp = n.GetSubtree(1) as ConstantTreeNode; 349 if (exp == null || exp.Value != Math.Truncate(exp.Value)) return false; 350 } 351 } 352 return true; 335 353 } 336 354 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs
r17180 r18027 144 144 { typeof(Cosine), OpCodes.Cos }, 145 145 { typeof(Tangent), OpCodes.Tan }, 146 { typeof 146 { typeof(HyperbolicTangent), OpCodes.Tanh}, 147 147 { typeof(Logarithm), OpCodes.Log }, 148 148 { typeof(Exponential), OpCodes.Exp }, -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame
r17184 r18027 28 28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic","Provides base classes for symbolic data analysis tasks.", "3.4.12.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.ALGLIB", "3. 7.0")]30 [PluginDependency("HeuristicLab.ALGLIB", "3.17.0")] 31 31 [PluginDependency("HeuristicLab.AutoDiff", "1.0")] 32 32 [PluginDependency("HeuristicLab.Analysis", "3.3")]
Note: See TracChangeset
for help on using the changeset viewer.