- Timestamp:
- 01/02/12 11:40:31 (13 years ago)
- Location:
- branches/RegressionBenchmarks
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RegressionBenchmarks
-
branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAnalyzer.cs
r5882 r7255 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; 26 using HeuristicLab.Data;27 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 25 using HeuristicLab.Operators; 26 using HeuristicLab.Optimization; 29 27 using HeuristicLab.Parameters; 30 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 29 33 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 49 46 #endregion 50 47 #region properties 48 public virtual bool EnabledByDefault { 49 get { return true; } 50 } 51 51 public ItemArray<ISymbolicExpressionTree> SymbolicExpressionTree { 52 52 get { return SymbolicExpressionTreeParameter.ActualValue; } -
branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs
r5882 r7255 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.Linq; 23 25 using HeuristicLab.Common; … … 26 28 using HeuristicLab.Parameters; 27 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using System.Collections.Generic;29 using System;30 30 using HeuristicLab.Random; 31 31 -
branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r7085 r7255 77 77 strBuilder.Append(FormatRecursively(node.GetSubtree(0))); 78 78 } 79 int i = 1; 79 80 foreach (SymbolicExpressionTreeNode subTree in node.Subtrees.Skip(1)) { 80 FormatSep(node, strBuilder );81 FormatSep(node, strBuilder, i); 81 82 // format the whole subtree 82 83 strBuilder.Append(FormatRecursively(subTree)); 84 i++; 83 85 } 84 86 … … 90 92 private void FormatBegin(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 91 93 if (node.Symbol is Addition) { 92 strBuilder.Append(@" ");94 strBuilder.Append(@" ( "); 93 95 } else if (node.Symbol is Subtraction) { 94 96 if (node.SubtreeCount == 1) { 95 strBuilder.Append(@"- ");97 strBuilder.Append(@"- ( "); 96 98 } else { 97 strBuilder.Append(@" ");99 strBuilder.Append(@" ( "); 98 100 } 99 101 } else if (node.Symbol is Multiplication) { … … 109 111 strBuilder.Append(@" \cfrac{1}{" + node.SubtreeCount + @"}"); 110 112 } 111 strBuilder.Append(@" ");113 strBuilder.Append(@" ( "); 112 114 } else if (node.Symbol is Logarithm) { 113 strBuilder.Append(@"\log ");115 strBuilder.Append(@"\log ( "); 114 116 } else if (node.Symbol is Exponential) { 115 strBuilder.Append(@"\exp ");117 strBuilder.Append(@"\exp ( "); 116 118 } else if (node.Symbol is Sine) { 117 strBuilder.Append(@"\sin ");119 strBuilder.Append(@"\sin ( "); 118 120 } else if (node.Symbol is Cosine) { 119 strBuilder.Append(@"\cos ");121 strBuilder.Append(@"\cos ( "); 120 122 } else if (node.Symbol is Tangent) { 121 strBuilder.Append(@"\tan ");123 strBuilder.Append(@"\tan ( "); 122 124 } else if (node.Symbol is GreaterThan) { 123 strBuilder.Append(@" ");125 strBuilder.Append(@" ( "); 124 126 } else if (node.Symbol is LessThan) { 125 strBuilder.Append(@" ");127 strBuilder.Append(@" ( "); 126 128 } else if (node.Symbol is And) { 127 strBuilder.Append(@" ");129 strBuilder.Append(@" ( "); 128 130 } else if (node.Symbol is Or) { 129 strBuilder.Append(@" ");131 strBuilder.Append(@" ( "); 130 132 } else if (node.Symbol is Not) { 131 strBuilder.Append(@" \neg ");133 strBuilder.Append(@" \neg ( "); 132 134 } else if (node.Symbol is IfThenElse) { 133 strBuilder.Append(@" \operatorname{if} 0 < ");135 strBuilder.Append(@" \operatorname{if} ( 0 < "); 134 136 } else if (node.Symbol is Constant) { 135 137 strBuilder.Append("c_{" + constants.Count + "} "); … … 159 161 } else if (node.Symbol is InvokeFunction) { 160 162 var invokeNode = node as InvokeFunctionTreeNode; 161 strBuilder.Append(invokeNode.Symbol.FunctionName + @" ");163 strBuilder.Append(invokeNode.Symbol.FunctionName + @" ( "); 162 164 } else if (node.Symbol is StartSymbol) { 163 165 strBuilder.Append("Result & = "); … … 166 168 strBuilder.Append(" ARG+" + argSym.ArgumentIndex + " "); 167 169 } else if (node.Symbol is Derivative) { 168 strBuilder.Append(@" \cfrac{d ");170 strBuilder.Append(@" \cfrac{d ( "); 169 171 } else if (node.Symbol is TimeLag) { 170 172 var laggedNode = node as ILaggedTreeNode; 171 173 currentLag += laggedNode.Lag; 172 174 } else if (node.Symbol is Power) { 173 strBuilder.Append(@" ");175 strBuilder.Append(@" ( "); 174 176 } else if (node.Symbol is Root) { 175 strBuilder.Append(@" ");177 strBuilder.Append(@" ( "); 176 178 } else if (node.Symbol is Integral) { 177 179 // actually a new variable for t is needed in all subtrees (TODO) 178 180 var laggedTreeNode = node as ILaggedTreeNode; 179 strBuilder.Append(@"\sum_{t=" + (laggedTreeNode.Lag + currentLag) + @"}^0 ");181 strBuilder.Append(@"\sum_{t=" + (laggedTreeNode.Lag + currentLag) + @"}^0 ( "); 180 182 } else if (node.Symbol is VariableCondition) { 181 183 var conditionTreeNode = node as VariableConditionTreeNode; … … 184 186 p += @" \cdot " + EscapeLatexString(conditionTreeNode.VariableName) + LagToString(currentLag) + " - c_{" + constants.Count + @"} "; 185 187 constants.Add(conditionTreeNode.Threshold); 186 strBuilder.Append(@" " + p + @"\cdot ");188 strBuilder.Append(@" ( " + p + @"\cdot "); 187 189 } else { 188 190 throw new NotImplementedException("Export of " + node.Symbol + " is not implemented."); … … 190 192 } 191 193 192 private void FormatSep(ISymbolicExpressionTreeNode node, StringBuilder strBuilder ) {194 private void FormatSep(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, int step) { 193 195 if (node.Symbol is Addition) { 194 196 strBuilder.Append(" + "); … … 198 200 strBuilder.Append(@" \cdot "); 199 201 } else if (node.Symbol is Division) { 200 strBuilder.Append(@" }{ \cfrac{ "); 202 if (step + 1 == node.SubtreeCount) 203 strBuilder.Append(@"}{"); 204 else 205 strBuilder.Append(@" }{ \cfrac{ "); 201 206 } else if (node.Symbol is Average) { 202 207 strBuilder.Append(@" + "); … … 216 221 strBuilder.Append(@" < "); 217 222 } else if (node.Symbol is And) { 218 strBuilder.Append(@" > 0 \land");223 strBuilder.Append(@" > 0 ) \land ("); 219 224 } else if (node.Symbol is Or) { 220 strBuilder.Append(@" > 0 \lor");225 strBuilder.Append(@" > 0 ) \lor ("); 221 226 } else if (node.Symbol is Not) { 222 227 throw new InvalidOperationException(); 223 228 } else if (node.Symbol is IfThenElse) { 224 strBuilder.Append(@" ,");229 strBuilder.Append(@" ) , ("); 225 230 } else if (node.Symbol is ProgramRootSymbol) { 226 231 strBuilder.Append(@"\\" + Environment.NewLine); … … 231 236 strBuilder.Append(@"\\" + Environment.NewLine + " & "); 232 237 } else if (node.Symbol is Power) { 233 strBuilder.Append(@" ^ { \operatorname{round}");238 strBuilder.Append(@") ^ { \operatorname{round} ("); 234 239 } else if (node.Symbol is Root) { 235 strBuilder.Append(@" ^ { \cfrac{1}{ \operatorname{round}");240 strBuilder.Append(@") ^ { \cfrac{1}{ \operatorname{round} ("); 236 241 } else if (node.Symbol is VariableCondition) { 237 242 var conditionTreeNode = node as VariableConditionTreeNode; 238 string p = @"1 / 1 + \exp- c_{" + constants.Count + "} ";243 string p = @"1 / ( 1 + \exp ( - c_{" + constants.Count + "} "; 239 244 constants.Add(conditionTreeNode.Slope); 240 p += @" \cdot " + EscapeLatexString(conditionTreeNode.VariableName) + LagToString(currentLag) + " - c_{" + constants.Count + @"} ";245 p += @" \cdot " + EscapeLatexString(conditionTreeNode.VariableName) + LagToString(currentLag) + " - c_{" + constants.Count + @"} ) ) ) "; 241 246 constants.Add(conditionTreeNode.Threshold); 242 strBuilder.Append(@" + 1 - " + p + @"\cdot ");247 strBuilder.Append(@" + ( 1 - " + p + @" ) \cdot "); 243 248 } else { 244 249 throw new NotImplementedException("Export of " + node.Symbol + " is not implemented."); … … 248 253 private void FormatEnd(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 249 254 if (node.Symbol is Addition) { 250 strBuilder.Append(@" ");255 strBuilder.Append(@" ) "); 251 256 } else if (node.Symbol is Subtraction) { 252 strBuilder.Append(@" ");257 strBuilder.Append(@" ) "); 253 258 } else if (node.Symbol is Multiplication) { 254 259 } else if (node.Symbol is Division) { 255 strBuilder.Append("} "); 256 if (node.SubtreeCount > 1) 257 strBuilder.Append("{1} "); 258 for (int i = 1; i < node.SubtreeCount; i++) { 260 strBuilder.Append(" } "); 261 for (int i = 2; i < node.SubtreeCount; i++) 259 262 strBuilder.Append(" } "); 260 }261 263 } else if (node.Symbol is Average) { 262 strBuilder.Append(@" ");264 strBuilder.Append(@" ) "); 263 265 } else if (node.Symbol is Logarithm) { 264 strBuilder.Append(@" ");266 strBuilder.Append(@" ) "); 265 267 } else if (node.Symbol is Exponential) { 266 strBuilder.Append(@" ");268 strBuilder.Append(@" ) "); 267 269 } else if (node.Symbol is Sine) { 268 strBuilder.Append(@" ");270 strBuilder.Append(@" ) "); 269 271 } else if (node.Symbol is Cosine) { 270 strBuilder.Append(@" ");272 strBuilder.Append(@" ) "); 271 273 } else if (node.Symbol is Tangent) { 272 strBuilder.Append(@" ");274 strBuilder.Append(@" ) "); 273 275 } else if (node.Symbol is GreaterThan) { 274 strBuilder.Append(@" ");276 strBuilder.Append(@" ) "); 275 277 } else if (node.Symbol is LessThan) { 276 strBuilder.Append(@" ");278 strBuilder.Append(@" ) "); 277 279 } else if (node.Symbol is And) { 278 strBuilder.Append(@" > 0 280 strBuilder.Append(@" > 0 ) ) "); 279 281 } else if (node.Symbol is Or) { 280 strBuilder.Append(@" > 0 282 strBuilder.Append(@" > 0 ) ) "); 281 283 } else if (node.Symbol is Not) { 282 strBuilder.Append(@" ");284 strBuilder.Append(@" ) "); 283 285 } else if (node.Symbol is IfThenElse) { 284 strBuilder.Append(@" 286 strBuilder.Append(@" ) ) "); 285 287 } else if (node.Symbol is Constant) { 286 288 } else if (node.Symbol is LaggedVariable) { … … 298 300 } else if (node.Symbol is Defun) { 299 301 } else if (node.Symbol is InvokeFunction) { 300 strBuilder.Append(@" ");302 strBuilder.Append(@" ) "); 301 303 } else if (node.Symbol is StartSymbol) { 302 304 } else if (node.Symbol is Argument) { 303 305 } else if (node.Symbol is Derivative) { 304 strBuilder.Append(@" }{dt} ");306 strBuilder.Append(@" ) }{dt} "); 305 307 } else if (node.Symbol is TimeLag) { 306 308 var laggedNode = node as ILaggedTreeNode; 307 309 currentLag -= laggedNode.Lag; 308 310 } else if (node.Symbol is Power) { 309 strBuilder.Append(@" } ");311 strBuilder.Append(@" ) } "); 310 312 } else if (node.Symbol is Root) { 311 strBuilder.Append(@" }} ");313 strBuilder.Append(@" ) } ) } "); 312 314 } else if (node.Symbol is Integral) { 313 315 var laggedTreeNode = node as ILaggedTreeNode; 314 strBuilder.Append(@" ");316 strBuilder.Append(@" ) "); 315 317 } else if (node.Symbol is VariableCondition) { 316 318 strBuilder.Append(@"\left) "); -
branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r7085 r7255 194 194 Symbols.Where(s => s.Name == TimeSeriesSymbolsName).First().Enabled = false; 195 195 } 196 197 public void ConfigureAsDefaultTimeSeriesPrognosisGrammar() {198 Symbols.Where(s => s is Variable).First().Enabled = false;199 Symbols.Where(s => s.Name == TrigonometricFunctionsName).First().Enabled = false;200 Symbols.Where(s => s.Name == PowerFunctionsName).First().Enabled = false;201 Symbols.Where(s => s.Name == ConditionalSymbolsName).First().Enabled = false;202 }203 196 } 204 197 } -
branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisModel.cs
r5914 r7255 32 32 [StorableClass] 33 33 public abstract class SymbolicDataAnalysisModel : NamedItem, ISymbolicDataAnalysisModel { 34 public override ImageItemImage {34 public static new Image StaticItemImage { 35 35 get { return HeuristicLab.Common.Resources.VSImageLibrary.Function; } 36 36 } -
branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs
r7085 r7255 102 102 #region properties 103 103 public string Filename { get; set; } 104 public override ImageItemImage { get { return VSImageLibrary.Type; } }104 public static new Image StaticItemImage { get { return VSImageLibrary.Type; } } 105 105 106 106 IDataAnalysisProblemData IDataAnalysisProblem.ProblemData {
Note: See TracChangeset
for help on using the changeset viewer.