- Timestamp:
- 02/03/12 17:59:51 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 13 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs.sln
r7294 r7446 36 36 EndProject 37 37 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.ALGLIB-3.4.0", "HeuristicLab.ExtLibs\HeuristicLab.ALGLIB\3.4.0\HeuristicLab.ALGLIB-3.4.0\HeuristicLab.ALGLIB-3.4.0.csproj", "{DE69A359-A5B8-4D3D-BA8D-D5780D7F96D6}" 38 EndProject 39 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.MathJax-1.1", "HeuristicLab.ExtLibs\HeuristicLab.MathJax\1.1\HeuristicLab.MathJax-1.1\HeuristicLab.MathJax-1.1.csproj", "{BF4C452F-4903-44E6-89B7-DF93D02C4819}" 38 40 EndProject 39 41 Global … … 227 229 {DE69A359-A5B8-4D3D-BA8D-D5780D7F96D6}.Release|x86.ActiveCfg = Release|x86 228 230 {DE69A359-A5B8-4D3D-BA8D-D5780D7F96D6}.Release|x86.Build.0 = Release|x86 231 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 232 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Debug|Any CPU.Build.0 = Debug|Any CPU 233 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Debug|x64.ActiveCfg = Debug|x64 234 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Debug|x64.Build.0 = Debug|x64 235 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Debug|x86.ActiveCfg = Debug|x86 236 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Debug|x86.Build.0 = Debug|x86 237 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Release|Any CPU.ActiveCfg = Release|Any CPU 238 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Release|Any CPU.Build.0 = Release|Any CPU 239 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Release|x64.ActiveCfg = Release|x64 240 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Release|x64.Build.0 = Release|x64 241 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Release|x86.ActiveCfg = Release|x86 242 {BF4C452F-4903-44E6-89B7-DF93D02C4819}.Release|x86.Build.0 = Release|x86 229 243 EndGlobalSection 230 244 GlobalSection(SolutionProperties) = preSolution -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/GraphicalSymbolicDataAnalysisModelView.cs
r7259 r7446 26 26 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 27 27 [View("Graphical Representation")] 28 [Content(typeof(ISymbolicDataAnalysisModel) , true)]28 [Content(typeof(ISymbolicDataAnalysisModel))] 29 29 public partial class GraphicalSymbolicDataAnalysisModelView : AsynchronousContentView { 30 30 public GraphicalSymbolicDataAnalysisModelView() -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj
r7294 r7446 114 114 </ItemGroup> 115 115 <ItemGroup> 116 <Compile Include="MathSymbolicDataAnalysisModelView.cs"> 117 <SubType>UserControl</SubType> 118 </Compile> 119 <Compile Include="MathSymbolicDataAnalysisModelView.designer.cs"> 120 <DependentUpon>MathSymbolicDataAnalysisModelView.cs</DependentUpon> 121 </Compile> 116 122 <Compile Include="Plugin.cs" /> 117 123 <Compile Include="TextualSymbolicDataAnalysisModelView.cs"> … … 292 298 <Install>true</Install> 293 299 </BootstrapperPackage> 300 </ItemGroup> 301 <ItemGroup> 302 <Content Include="displayModelFrame.html"> 303 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 304 </Content> 294 305 </ItemGroup> 295 306 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Plugin.cs.frame
r7294 r7446 28 28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic.Views","Provides views for symbolic data analysis problem classes.", "3.4.2.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.dll", PluginFileType.Assembly)] 30 [PluginFile("displayModelFrame.html", PluginFileType.Data)] 30 31 [PluginDependency("HeuristicLab.ALGLIB", "3.4")] 31 32 [PluginDependency("HeuristicLab.Collections", "3.3")] … … 39 40 [PluginDependency("HeuristicLab.MainForm", "3.3")] 40 41 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 42 [PluginDependency("HeuristicLab.MathJax", "1.1")] 41 43 [PluginDependency("HeuristicLab.Optimization","3.3")] 42 44 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r7259 r7446 57 57 StringBuilder strBuilder = new StringBuilder(); 58 58 constants.Clear(); 59 strBuilder.AppendLine("% needs \\usepackage{amsmath}");60 strBuilder.AppendLine("\\begin{align*}");61 strBuilder.AppendLine("\\nonumber");62 59 strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root)); 63 strBuilder.AppendLine("\\end{align*}");64 60 return strBuilder.ToString(); 65 61 } … … 92 88 private void FormatBegin(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 93 89 if (node.Symbol is Addition) { 94 strBuilder.Append(@" ( ");90 strBuilder.Append(@" \left( "); 95 91 } else if (node.Symbol is Subtraction) { 96 92 if (node.SubtreeCount == 1) { 97 strBuilder.Append(@"- ( ");93 strBuilder.Append(@"- \left( "); 98 94 } else { 99 strBuilder.Append(@" ( ");95 strBuilder.Append(@" \left( "); 100 96 } 101 97 } else if (node.Symbol is Multiplication) { … … 111 107 strBuilder.Append(@" \cfrac{1}{" + node.SubtreeCount + @"}"); 112 108 } 113 strBuilder.Append(@" ( ");109 strBuilder.Append(@" \left( "); 114 110 } else if (node.Symbol is Logarithm) { 115 strBuilder.Append(@"\log ( ");111 strBuilder.Append(@"\log \left( "); 116 112 } else if (node.Symbol is Exponential) { 117 strBuilder.Append(@"\exp ( ");113 strBuilder.Append(@"\exp \left( "); 118 114 } else if (node.Symbol is Sine) { 119 strBuilder.Append(@"\sin ( ");115 strBuilder.Append(@"\sin \left( "); 120 116 } else if (node.Symbol is Cosine) { 121 strBuilder.Append(@"\cos ( ");117 strBuilder.Append(@"\cos \left( "); 122 118 } else if (node.Symbol is Tangent) { 123 strBuilder.Append(@"\tan ( ");119 strBuilder.Append(@"\tan \left( "); 124 120 } else if (node.Symbol is GreaterThan) { 125 strBuilder.Append(@" ( ");121 strBuilder.Append(@" \left( "); 126 122 } else if (node.Symbol is LessThan) { 127 strBuilder.Append(@" ( ");123 strBuilder.Append(@" \left( "); 128 124 } else if (node.Symbol is And) { 129 strBuilder.Append(@" ( ");125 strBuilder.Append(@" \left( "); 130 126 } else if (node.Symbol is Or) { 131 strBuilder.Append(@" ( ");127 strBuilder.Append(@" \left( "); 132 128 } else if (node.Symbol is Not) { 133 strBuilder.Append(@" \neg ( ");129 strBuilder.Append(@" \neg \left( "); 134 130 } else if (node.Symbol is IfThenElse) { 135 strBuilder.Append(@" \operatorname{if} ( 0 <");131 strBuilder.Append(@" \operatorname{if} \left( "); 136 132 } else if (node.Symbol is Constant) { 137 133 strBuilder.Append("c_{" + constants.Count + "} "); … … 156 152 strBuilder.Append(LagToString(currentLag)); 157 153 } else if (node.Symbol is ProgramRootSymbol) { 154 strBuilder 155 .AppendLine("\\begin{align*}") 156 .AppendLine("\\nonumber"); 158 157 } else if (node.Symbol is Defun) { 159 158 var defunNode = node as DefunTreeNode; … … 161 160 } else if (node.Symbol is InvokeFunction) { 162 161 var invokeNode = node as InvokeFunctionTreeNode; 163 strBuilder.Append(invokeNode.Symbol.FunctionName + @" ( ");162 strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( "); 164 163 } else if (node.Symbol is StartSymbol) { 165 164 strBuilder.Append("Result & = "); … … 168 167 strBuilder.Append(" ARG+" + argSym.ArgumentIndex + " "); 169 168 } else if (node.Symbol is Derivative) { 170 strBuilder.Append(@" \cfrac{d ( ");169 strBuilder.Append(@" \cfrac{d \left( "); 171 170 } else if (node.Symbol is TimeLag) { 172 171 var laggedNode = node as ILaggedTreeNode; 173 172 currentLag += laggedNode.Lag; 174 173 } else if (node.Symbol is Power) { 175 strBuilder.Append(@" ( ");174 strBuilder.Append(@" \left( "); 176 175 } else if (node.Symbol is Root) { 177 strBuilder.Append(@" ( ");176 strBuilder.Append(@" \left( "); 178 177 } else if (node.Symbol is Integral) { 179 178 // actually a new variable for t is needed in all subtrees (TODO) 180 179 var laggedTreeNode = node as ILaggedTreeNode; 181 strBuilder.Append(@"\sum_{t=" + (laggedTreeNode.Lag + currentLag) + @"}^0 ( ");180 strBuilder.Append(@"\sum_{t=" + (laggedTreeNode.Lag + currentLag) + @"}^0 \left( "); 182 181 } else if (node.Symbol is VariableCondition) { 183 182 var conditionTreeNode = node as VariableConditionTreeNode; … … 186 185 p += @" \cdot " + EscapeLatexString(conditionTreeNode.VariableName) + LagToString(currentLag) + " - c_{" + constants.Count + @"} "; 187 186 constants.Add(conditionTreeNode.Threshold); 188 strBuilder.Append(@" ( " + p + @"\cdot ");187 strBuilder.Append(@" \left( " + p + @"\cdot "); 189 188 } else { 190 189 throw new NotImplementedException("Export of " + node.Symbol + " is not implemented."); … … 221 220 strBuilder.Append(@" < "); 222 221 } else if (node.Symbol is And) { 223 strBuilder.Append(@" > 0 ) \land(");222 strBuilder.Append(@" > 0 \right) \land \left("); 224 223 } else if (node.Symbol is Or) { 225 strBuilder.Append(@" > 0 ) \lor(");224 strBuilder.Append(@" > 0 \right) \lor \left("); 226 225 } else if (node.Symbol is Not) { 227 226 throw new InvalidOperationException(); 228 227 } else if (node.Symbol is IfThenElse) { 229 strBuilder.Append(@" ) , (");228 strBuilder.Append(@" , "); 230 229 } else if (node.Symbol is ProgramRootSymbol) { 231 230 strBuilder.Append(@"\\" + Environment.NewLine); … … 236 235 strBuilder.Append(@"\\" + Environment.NewLine + " & "); 237 236 } else if (node.Symbol is Power) { 238 strBuilder.Append(@" ) ^ { \operatorname{round}(");237 strBuilder.Append(@"\right) ^ { \operatorname{round} \left("); 239 238 } else if (node.Symbol is Root) { 240 strBuilder.Append(@" ) ^ { \cfrac{1}{ \operatorname{round}(");239 strBuilder.Append(@"\right) ^ { \cfrac{1}{ \operatorname{round} \left("); 241 240 } else if (node.Symbol is VariableCondition) { 242 241 var conditionTreeNode = node as VariableConditionTreeNode; 243 string p = @"1 / ( 1 + \exp( - c_{" + constants.Count + "} ";242 string p = @"1 / \left( 1 + \exp \left( - c_{" + constants.Count + "} "; 244 243 constants.Add(conditionTreeNode.Slope); 245 p += @" \cdot " + EscapeLatexString(conditionTreeNode.VariableName) + LagToString(currentLag) + " - c_{" + constants.Count + @"} ) )) ";244 p += @" \cdot " + EscapeLatexString(conditionTreeNode.VariableName) + LagToString(currentLag) + " - c_{" + constants.Count + @"} \right) \right) \right) "; 246 245 constants.Add(conditionTreeNode.Threshold); 247 strBuilder.Append(@" + ( 1 - " + p + @") \cdot ");246 strBuilder.Append(@" + \left( 1 - " + p + @" \right) \cdot "); 248 247 } else { 249 248 throw new NotImplementedException("Export of " + node.Symbol + " is not implemented."); … … 253 252 private void FormatEnd(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 254 253 if (node.Symbol is Addition) { 255 strBuilder.Append(@" ) ");254 strBuilder.Append(@" \right) "); 256 255 } else if (node.Symbol is Subtraction) { 257 strBuilder.Append(@" ) ");256 strBuilder.Append(@" \right) "); 258 257 } else if (node.Symbol is Multiplication) { 259 258 } else if (node.Symbol is Division) { … … 262 261 strBuilder.Append(" } "); 263 262 } else if (node.Symbol is Average) { 264 strBuilder.Append(@" ) ");263 strBuilder.Append(@" \right) "); 265 264 } else if (node.Symbol is Logarithm) { 266 strBuilder.Append(@" ) ");265 strBuilder.Append(@" \right) "); 267 266 } else if (node.Symbol is Exponential) { 268 strBuilder.Append(@" ) ");267 strBuilder.Append(@" \right) "); 269 268 } else if (node.Symbol is Sine) { 270 strBuilder.Append(@" ) ");269 strBuilder.Append(@" \right) "); 271 270 } else if (node.Symbol is Cosine) { 272 strBuilder.Append(@" ) ");271 strBuilder.Append(@" \right) "); 273 272 } else if (node.Symbol is Tangent) { 274 strBuilder.Append(@" ) ");273 strBuilder.Append(@" \right) "); 275 274 } else if (node.Symbol is GreaterThan) { 276 strBuilder.Append(@" ) ");275 strBuilder.Append(@" \right) "); 277 276 } else if (node.Symbol is LessThan) { 278 strBuilder.Append(@" ) ");277 strBuilder.Append(@" \right) "); 279 278 } else if (node.Symbol is And) { 280 strBuilder.Append(@" > 0 )) ");279 strBuilder.Append(@" > 0 \right) \right) "); 281 280 } else if (node.Symbol is Or) { 282 strBuilder.Append(@" > 0 )) ");281 strBuilder.Append(@" > 0 \right) \right) "); 283 282 } else if (node.Symbol is Not) { 284 strBuilder.Append(@" ) ");283 strBuilder.Append(@" \right) "); 285 284 } else if (node.Symbol is IfThenElse) { 286 strBuilder.Append(@" )) ");285 strBuilder.Append(@" \right) "); 287 286 } else if (node.Symbol is Constant) { 288 287 } else if (node.Symbol is LaggedVariable) { 289 288 } else if (node.Symbol is Variable) { 290 289 } else if (node.Symbol is ProgramRootSymbol) { 290 strBuilder 291 .AppendLine("\\end{align*}") 292 .AppendLine("\\begin{align*}") 293 .AppendLine("\\nonumber"); 291 294 // output all constant values 292 295 if (constants.Count > 0) { 293 296 int i = 0; 294 297 foreach (var constant in constants) { 295 strBuilder.AppendLine(@"\\"); 296 strBuilder.Append("c_{" + i + "} & = " + constant); 298 // replace "." with ".&" to align decimal points 299 var constStr = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "{0:G5}", constant); 300 if(!constStr.Contains(".")) constStr = constStr + ".0"; 301 constStr = constStr.Replace(".", "\\negthickspace&."); // fix problem in rendering of aligned expressions 302 strBuilder.Append("c_{" + i + "}& = & " + constStr); 303 strBuilder.Append(@"\\"); 297 304 i++; 298 305 } 299 306 } 307 strBuilder.AppendLine("\\end{align*}"); 300 308 } else if (node.Symbol is Defun) { 301 309 } else if (node.Symbol is InvokeFunction) { 302 strBuilder.Append(@" ) ");310 strBuilder.Append(@" \right) "); 303 311 } else if (node.Symbol is StartSymbol) { 304 312 } else if (node.Symbol is Argument) { 305 313 } else if (node.Symbol is Derivative) { 306 strBuilder.Append(@" ) }{dt} ");314 strBuilder.Append(@" \right) }{dt} "); 307 315 } else if (node.Symbol is TimeLag) { 308 316 var laggedNode = node as ILaggedTreeNode; 309 317 currentLag -= laggedNode.Lag; 310 318 } else if (node.Symbol is Power) { 311 strBuilder.Append(@" ) } ");319 strBuilder.Append(@" \right) } "); 312 320 } else if (node.Symbol is Root) { 313 strBuilder.Append(@" ) } )} ");321 strBuilder.Append(@" \right) } } "); 314 322 } else if (node.Symbol is Integral) { 315 var laggedTreeNode = node as ILaggedTreeNode; 316 strBuilder.Append(@" ) "); 323 strBuilder.Append(@" \right) "); 317 324 } else if (node.Symbol is VariableCondition) { 318 strBuilder.Append(@"\ left) ");325 strBuilder.Append(@"\right) "); 319 326 } else { 320 327 throw new NotImplementedException("Export of " + node.Symbol + " is not implemented."); … … 331 338 332 339 private string EscapeLatexString(string s) { 333 return s.Replace(@"_", @"\_"); 340 return "\\text{" + 341 s 342 .Replace("\\", "\\\\") 343 .Replace("{", "\\{") 344 .Replace("}", "\\}") 345 .Replace("%", "\\%") 346 + "}"; 334 347 } 335 348 }
Note: See TracChangeset
for help on using the changeset viewer.