Changeset 17790 for branches/3073_IA_constraint_splitting
- Timestamp:
- 12/10/20 08:28:40 (4 years ago)
- Location:
- branches/3073_IA_constraint_splitting
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis (added) merged: 17787-17788
- Property svn:mergeinfo changed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic (added) merged: 17648,17685,17755
- Property svn:mergeinfo changed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs
r17581 r17790 29 29 using HeuristicLab.Core; 30 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 31 using Microsoft.SqlServer.Server; 31 32 32 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 83 84 if (!varNode.Weight.IsAlmost(1.0)) { 84 85 strBuilder.Append("("); 85 if (constants != null) { 86 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", varNode.Weight); 87 } else { 88 strBuilder.Append(varNode.Weight.ToString(formatString, numberFormat)); 89 } 86 AppendConstant(strBuilder, constants, varNode.Weight, formatString, numberFormat); 90 87 strBuilder.Append("*"); 91 88 } 92 89 93 90 strBuilder.Append("LAG("); 94 if (varNode.VariableName.Contains("'")) 95 strBuilder.AppendFormat("\"{0}\"", varNode.VariableName); 96 else 97 strBuilder.AppendFormat("'{0}'", varNode.VariableName); 98 91 AppendVariableName(strBuilder, varNode.VariableName); 99 92 strBuilder.Append(", ") 100 93 .AppendFormat(numberFormat, "{0}", varNode.Lag) 101 94 .Append(")"); 95 if (!varNode.Weight.IsAlmost(1.0)) strBuilder.Append(")"); 102 96 } else if (node.Symbol is Variable) { 103 97 var varNode = node as VariableTreeNode; 104 98 if (!varNode.Weight.IsAlmost(1.0)) { 105 99 strBuilder.Append("("); 106 if (constants != null) { 107 string constantKey = $"c_{constants.Count}"; 108 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", constantKey); 109 constants.Add(new KeyValuePair<string, double>(constantKey, varNode.Weight)); 110 } else { 111 strBuilder.Append(varNode.Weight.ToString(formatString, numberFormat)); 112 } 113 100 AppendConstant(strBuilder, constants, varNode.Weight, formatString, numberFormat); 114 101 strBuilder.Append("*"); 115 102 } 116 103 117 if (varNode.VariableName.Contains("'")) 118 strBuilder.AppendFormat("\"{0}\"", varNode.VariableName); 119 else 120 strBuilder.AppendFormat("'{0}'", varNode.VariableName); 104 AppendVariableName(strBuilder, varNode.VariableName); 121 105 122 106 if (!varNode.Weight.IsAlmost(1.0)) strBuilder.Append(")"); 123 107 } else if (node.Symbol is FactorVariable) { 124 108 var factorNode = node as FactorVariableTreeNode; 125 if (factorNode.VariableName.Contains("'")) 126 strBuilder.AppendFormat("\"{0}\"", factorNode.VariableName); 127 else 128 strBuilder.AppendFormat("'{0}'", factorNode.VariableName); 129 130 strBuilder.AppendFormat("[{0}]", 131 string.Join(", ", factorNode.Weights.Select(w => w.ToString(formatString, numberFormat)))); 109 AppendVariableName(strBuilder, factorNode.VariableName); 110 111 strBuilder.Append("["); 112 for (int i = 0; i < factorNode.Weights.Length; i++) { 113 if (i > 0) strBuilder.Append(", "); 114 AppendConstant(strBuilder, constants, factorNode.Weights[i], formatString, numberFormat); 115 } 116 strBuilder.Append("]"); 132 117 } else if (node.Symbol is BinaryFactorVariable) { 133 118 var factorNode = node as BinaryFactorVariableTreeNode; 134 119 if (!factorNode.Weight.IsAlmost(1.0)) { 135 120 strBuilder.Append("("); 136 if (constants != null) { 137 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", factorNode.Weight); 138 } else { 139 strBuilder.Append(factorNode.Weight.ToString(formatString, numberFormat)); 140 } 121 AppendConstant(strBuilder, constants, factorNode.Weight, formatString, numberFormat); 141 122 142 123 strBuilder.Append("*"); 143 124 } 144 125 145 if (factorNode.VariableName.Contains("'")) 146 strBuilder.AppendFormat("\"{0}\"", factorNode.VariableName); 147 else 148 strBuilder.AppendFormat("'{0}'", factorNode.VariableName); 149 126 AppendVariableName(strBuilder, factorNode.VariableName); 150 127 strBuilder.Append(" = "); 151 if (factorNode.VariableValue.Contains("'")) 152 strBuilder.AppendFormat("\"{0}\"", factorNode.VariableValue); 153 else 154 strBuilder.AppendFormat("'{0}'", factorNode.VariableValue); 128 AppendVariableName(strBuilder, factorNode.VariableValue); 155 129 156 130 if (!factorNode.Weight.IsAlmost(1.0)) strBuilder.Append(")"); 157 131 } else if (node.Symbol is Constant) { 158 132 var constNode = node as ConstantTreeNode; 159 if (constants != null) { 160 string constantKey = $"c_{constants.Count}"; 161 162 strBuilder.AppendFormat(CultureInfo.InvariantCulture, constantKey); 163 constants.Add(new KeyValuePair<string, double>(constantKey, constNode.Value)); 133 if(constants==null && constNode.Value < 0) { 134 strBuilder.Append("(").Append(constNode.Value.ToString(formatString, numberFormat)) 135 .Append(")"); // (-1 164 136 } else { 165 if (constNode.Value >= 0.0) 166 strBuilder.Append(constNode.Value.ToString(formatString, numberFormat)); 167 else 168 strBuilder.Append("(").Append(constNode.Value.ToString(formatString, numberFormat)) 169 .Append(")"); // (-1 137 AppendConstant(strBuilder, constants, constNode.Value, formatString, numberFormat); 170 138 } 171 139 } 172 140 } 141 } 142 143 private static void AppendConstant(StringBuilder strBuilder, List<KeyValuePair<string, double>> constants, double value, string formatString, NumberFormatInfo numberFormat) { 144 if (constants != null) { 145 string constantKey = $"c_{constants.Count}"; 146 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", constantKey); 147 constants.Add(new KeyValuePair<string, double>(constantKey, value)); 148 } else { 149 strBuilder.Append(value.ToString(formatString, numberFormat)); 150 } 151 } 152 153 private static void AppendVariableName(StringBuilder strBuilder, string name) { 154 if (name.Contains("'")) 155 strBuilder.AppendFormat("\"{0}\"", name); 156 else 157 strBuilder.AppendFormat("'{0}'", name); 173 158 } 174 159 -
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs
r17180 r17790 154 154 strBuilder.Append(" / Math.Sqrt(1 + Math.Pow("); 155 155 FormatRecursively(node.GetSubtree(1), strBuilder); 156 strBuilder.Append(" , 2) ) ");156 strBuilder.Append(" , 2) ) )"); 157 157 } else { 158 158 throw new NotSupportedException("Formatting of symbol: " + node.Symbol + " not supported for C# symbolic expression tree formatter."); -
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r17180 r17790 517 517 518 518 private void FormatStartSymbol(StringBuilder strBuilder) { 519 strBuilder.Append( targetVariable ?? "target_" + (targetCount++));519 strBuilder.Append(EscapeLatexString(targetVariable) ?? "target_{" + targetCount++ + "}"); 520 520 if (containsTimeSeriesSymbol) 521 521 strBuilder.Append("(t)"); -
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Views (added) merged: 17775
- Property svn:mergeinfo changed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/PartialDependencePlot.cs
r17579 r17790 646 646 647 647 private void sharedFixedVariables_Reset(object sender, EventArgs e) { 648 RecalculateInternalDataset(); 648 649 var newValue = sharedFixedVariables.GetDoubleValue(FreeVariable, 0); 649 650 VerticalLineAnnotation.X = newValue; 650 UpdateCursor(); // triggers update of InternalDataset651 UpdateCursor(); 651 652 } 652 653
Note: See TracChangeset
for help on using the changeset viewer.