Changeset 9584
 Timestamp:
 06/05/13 10:33:30 (7 years ago)
 Location:
 branches/ExportSymbolicDataAnalysisSolutions
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

branches/ExportSymbolicDataAnalysisSolutions/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/MenuItems/ExportSymbolicSolutionToExcelMenuItem.cs
r9583 r9584 57 57 protected override void OnActiveViewChanged(object sender, EventArgs e) { 58 58 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 59 ToolStripItem.Enabled = activeView != null && activeView.Content as ISymbolicDataAnalysisSolution != null;59 ToolStripItem.Enabled = activeView != null && activeView.Content is ISymbolicDataAnalysisSolution; 60 60 } 61 61 62 62 public override void Execute() { 63 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;64 var solution = activeView.Content as ISymbolicDataAnalysisSolution;63 var activeView = (IContentView)MainFormManager.MainForm.ActiveView; 64 var solution = (ISymbolicDataAnalysisSolution)activeView.Content; 65 65 var formatter = new SymbolicDataAnalysisExpressionExcelFormatter(); 66 66 var formula = formatter.Format(solution.Model.SymbolicExpressionTree); 
branches/ExportSymbolicDataAnalysisSolutions/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
r9580 r9584 33 33 [StorableClass] 34 34 public sealed class SymbolicDataAnalysisExpressionExcelFormatter : NamedItem, ISymbolicExpressionTreeStringFormatter { 35 //private int currentLag;36 37 35 [StorableConstructor] 38 36 private SymbolicDataAnalysisExpressionExcelFormatter(bool deserializing) : base(deserializing) { } … … 68 66 return string.Format("${0}1", variableNameMapping[variabelName]); 69 67 } 70 //public string CurrentIndexVariable {71 // get {72 // return "i" + currentIndexNumber;73 // }74 //}75 //private void ReleaseIndexVariable() {76 // currentIndexNumber;77 //}78 79 //private string AllocateIndexVariable() {80 // currentIndexNumber++;81 // return CurrentIndexVariable;82 //}83 68 84 69 public string Format(ISymbolicExpressionTree symbolicExpressionTree) { … … 108 93 } 109 94 stringBuilder.Append(")"); 110 //} else if (symbol is And) {111 // stringBuilder.Append("((");112 // for (int i = 0; i < node.SubtreeCount; i++) {113 // if (i > 0) stringBuilder.Append("&");114 // stringBuilder.Append("((");115 // stringBuilder.Append(FormatRecursively(node.GetSubtree(i)));116 // stringBuilder.Append(")>0)");117 // }118 // stringBuilder.Append(")0.5)*2");119 // // MATLAB maps false and true to 0 and 1, resp., we map this result to 1.0 and +1.0, resp.120 95 } else if (symbol is Average) { 121 96 stringBuilder.Append("(1/"); … … 161 136 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 162 137 stringBuilder.Append(")"); 163 //} else if (symbol is GreaterThan) {164 // stringBuilder.Append("((");165 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));166 // stringBuilder.Append(">");167 // stringBuilder.Append(FormatRecursively(node.GetSubtree(1)));168 // stringBuilder.Append(")0.5)*2");169 // // MATLAB maps false and true to 0 and 1, resp., we map this result to 1.0 and +1.0, resp.170 //} else if (symbol is IfThenElse) {171 // stringBuilder.Append("(");172 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));173 // stringBuilder.Append(">0)*");174 // stringBuilder.Append(FormatRecursively(node.GetSubtree(1)));175 // stringBuilder.Append("+");176 // stringBuilder.Append("(");177 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));178 // stringBuilder.Append("<=0)*");179 // stringBuilder.Append(FormatRecursively(node.GetSubtree(2)));180 //} else if (symbol is LaggedVariable) {181 // // this if must be checked before if(symbol is LaggedVariable)182 // LaggedVariableTreeNode laggedVariableTreeNode = node as LaggedVariableTreeNode;183 // stringBuilder.Append(laggedVariableTreeNode.Weight.ToString(CultureInfo.InvariantCulture));184 // stringBuilder.Append("*");185 // stringBuilder.Append(laggedVariableTreeNode.VariableName +186 // LagToString(currentLag + laggedVariableTreeNode.Lag));187 //} else if (symbol is LessThan) {188 // stringBuilder.Append("((");189 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));190 // stringBuilder.Append("<");191 // stringBuilder.Append(FormatRecursively(node.GetSubtree(1)));192 // stringBuilder.Append(")0.5)*2");193 // // MATLAB maps false and true to 0 and 1, resp., we map this result to 1.0 and +1.0, resp.194 138 } else if (symbol is Logarithm) { 195 139 stringBuilder.Append("LOG("); … … 201 145 stringBuilder.Append(FormatRecursively(node.GetSubtree(i))); 202 146 } 203 //} else if (symbol is Not) {204 // stringBuilder.Append("NOT(");205 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));206 // stringBuilder.Append(" > 0 )");207 //} else if (symbol is Or) {208 // stringBuilder.Append("((");209 // for (int i = 0; i < node.SubtreeCount; i++) {210 // if (i > 0) stringBuilder.Append("");211 // stringBuilder.Append("((");212 // stringBuilder.Append(FormatRecursively(node.GetSubtree(i)));213 // stringBuilder.Append(")>0)");214 // }215 // stringBuilder.Append(")0.5)*2");216 // // MATLAB maps false and true to 0 and 1, resp., we map this result to 1.0 and +1.0, resp.217 147 } else if (symbol is Sine) { 218 148 stringBuilder.Append("SIN("); … … 236 166 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 237 167 stringBuilder.Append(")"); 238 //} else if (node.Symbol is AiryA) { 239 // stringBuilder.Append("airy("); 240 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 241 // stringBuilder.Append(")"); 242 //} else if (node.Symbol is AiryB) { 243 // stringBuilder.Append("airy(2, "); 244 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 245 // stringBuilder.Append(")"); 246 //} else if (node.Symbol is Bessel) { 247 // stringBuilder.Append("besseli(0.0,"); 248 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 249 // stringBuilder.Append(")"); 250 //} else if (node.Symbol is CosineIntegral) { 251 // stringBuilder.Append("cosint("); 252 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 253 // stringBuilder.Append(")"); 254 //} else if (node.Symbol is Dawson) { 255 // stringBuilder.Append("dawson("); 256 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 257 // stringBuilder.Append(")"); 258 //} else if (node.Symbol is Erf) { 259 // stringBuilder.Append("erf("); 260 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 261 // stringBuilder.Append(")"); 262 //} else if (node.Symbol is ExponentialIntegralEi) { 263 // stringBuilder.Append("expint("); 264 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 265 // stringBuilder.Append(")"); 266 //} else if (node.Symbol is FresnelCosineIntegral) { 267 // stringBuilder.Append("FresnelC("); 268 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 269 // stringBuilder.Append(")"); 270 //} else if (node.Symbol is FresnelSineIntegral) { 271 // stringBuilder.Append("FresnelS("); 272 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 273 // stringBuilder.Append(")"); 274 //} else if (node.Symbol is Gamma) { 275 // stringBuilder.Append("gamma("); 276 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 277 // stringBuilder.Append(")"); 278 //} else if (node.Symbol is HyperbolicCosineIntegral) { 279 // stringBuilder.Append("Chi("); 280 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 281 // stringBuilder.Append(")"); 282 //} else if (node.Symbol is HyperbolicSineIntegral) { 283 // stringBuilder.Append("Shi("); 284 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 285 // stringBuilder.Append(")"); 286 //} else if (node.Symbol is Norm) { 287 // stringBuilder.Append("normpdf("); 288 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 289 // stringBuilder.Append(")"); 290 //} else if (node.Symbol is Psi) { 291 // stringBuilder.Append("psi("); 292 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 293 // stringBuilder.Append(")"); 294 //} else if (node.Symbol is SineIntegral) { 295 // stringBuilder.Append("sinint("); 296 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 297 // stringBuilder.Append(")"); 168 298 169 } else if (symbol is HeuristicLab.Problems.DataAnalysis.Symbolic.Variable) { 299 170 VariableTreeNode variableTreeNode = node as VariableTreeNode; … … 313 184 stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); 314 185 stringBuilder.Append(",0))"); 315 //} else if (symbol is Derivative) {316 // stringBuilder.Append("fivePoint(");317 // // f0318 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));319 // stringBuilder.Append(", ");320 // // f1321 // currentLag;322 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));323 // stringBuilder.Append(", ");324 // // f3325 // currentLag = 2;326 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));327 // stringBuilder.Append(", ");328 // currentLag;329 // // f4330 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));331 // stringBuilder.Append(")");332 // currentLag += 4;333 //} else if (symbol is Integral) {334 // var laggedNode = node as LaggedTreeNode;335 // string prevCounterVariable = CurrentIndexVariable;336 // string counterVariable = AllocateIndexVariable();337 // stringBuilder.AppendLine(" sum (map(@(" + counterVariable + ") " + FormatRecursively(node.GetSubtree(0)) +338 // ", (" + prevCounterVariable + "+" + laggedNode.Lag + "):" + prevCounterVariable +339 // "))");340 // ReleaseIndexVariable();341 //} else if (symbol is TimeLag) {342 // var laggedNode = node as LaggedTreeNode;343 // currentLag += laggedNode.Lag;344 // stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));345 //currentLag = laggedNode.Lag;346 186 } else { 347 187 stringBuilder.Append("ERROR"); … … 349 189 return stringBuilder.ToString(); 350 190 } 351 352 353 //private string LagToString(int lag) {354 // if (lag < 0) {355 // return "(" + CurrentIndexVariable + "" + lag + ")";356 // } else if (lag > 0) {357 // return "(" + CurrentIndexVariable + "+" + lag + ")";358 // } else return "(" + CurrentIndexVariable + ")";359 //}360 361 191 } 362 192 }
Note: See TracChangeset
for help on using the changeset viewer.