Changeset 14826 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs
- Timestamp:
- 04/04/17 17:52:44 (8 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs
r14185 r14826 110 110 } 111 111 } else { 112 if (node is VariableTreeNode) { 112 // terminals 113 if (node.Symbol is Variable) { 113 114 var varNode = node as VariableTreeNode; 114 115 strBuilder.AppendFormat("Times[{0}, {1}]", varNode.VariableName, varNode.Weight.ToString("G17", CultureInfo.InvariantCulture)); 115 } else if (node is ConstantTreeNode) {116 } else if (node.Symbol is Constant) { 116 117 var constNode = node as ConstantTreeNode; 117 118 strBuilder.Append(constNode.Value.ToString("G17", CultureInfo.InvariantCulture)); 119 } else if (node.Symbol is FactorVariable) { 120 var factorNode = node as FactorVariableTreeNode; 121 strBuilder.AppendFormat("Switch[{0},", factorNode.VariableName); 122 var varValues = factorNode.Symbol.GetVariableValues(factorNode.VariableName).ToArray(); 123 var weights = varValues.Select(factorNode.GetValue).ToArray(); 124 125 var weightStr = string.Join(", ", 126 varValues.Zip(weights, (s, d) => string.Format(CultureInfo.InvariantCulture, "\"{0}\", {1:G17}", s, d))); 127 strBuilder.Append(weightStr); 128 strBuilder.Append("]"); 129 } else if (node.Symbol is BinaryFactorVariable) { 130 var factorNode = node as BinaryFactorVariableTreeNode; 131 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "If[{0}==\"{1}\",{2:G17},0.0]", 132 factorNode.VariableName, factorNode.VariableValue, factorNode.Weight); 118 133 } else { 119 134 throw new NotSupportedException("Formatting of symbol: " + node.Symbol + " is not supported.");
Note: See TracChangeset
for help on using the changeset viewer.