- Timestamp:
- 02/07/12 12:35:42 (13 years ago)
- Location:
- branches/HeuristicLab.TimeSeries
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs
r7183 r7463 70 70 Dictionary<ISymbolicExpressionTreeNode, double> impactValues = 71 71 new Dictionary<ISymbolicExpressionTreeNode, double>(); 72 var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, Content.ProblemData.TargetVariables.ToArray(), rows )72 var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, Content.ProblemData.TargetVariables.ToArray(), rows, 1) 73 73 .ToArray(); 74 74 int i = 0; -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/Interfaces/ISymbolicTimeSeriesPrognosisModel.cs
r7129 r7463 20 20 #endregion 21 21 22 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;23 22 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis { 24 23 public interface ISymbolicTimeSeriesPrognosisModel : ITimeSeriesPrognosisModel, ISymbolicDataAnalysisModel { -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/Plugin.cs.frame
r7099 r7463 28 28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis","Provides classes to perform symbolic time-series prognosis.", "3.4.1.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.ALGLIB", "3. 1")]30 [PluginDependency("HeuristicLab.ALGLIB", "3.4")] 31 31 [PluginDependency("HeuristicLab.Analysis", "3.3")] 32 32 [PluginDependency("HeuristicLab.Common", "3.3")] -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/MathSymbolicDataAnalysisModelView.designer.cs
r7460 r7463 53 53 this.webBrowser.AllowNavigation = false; 54 54 this.webBrowser.AllowWebBrowserDrop = false; 55 this.webBrowser.Dock = System.Windows.Forms.DockStyle.Fill; 55 this.webBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 56 | System.Windows.Forms.AnchorStyles.Left) 57 | System.Windows.Forms.AnchorStyles.Right))); 56 58 this.webBrowser.IsWebBrowserContextMenuEnabled = false; 57 this.webBrowser.Location = new System.Drawing.Point( 0, 0);59 this.webBrowser.Location = new System.Drawing.Point(3, 3); 58 60 this.webBrowser.MinimumSize = new System.Drawing.Size(20, 20); 59 61 this.webBrowser.Name = "webBrowser"; 60 this.webBrowser.Size = new System.Drawing.Size(3 52, 413);62 this.webBrowser.Size = new System.Drawing.Size(346, 407); 61 63 this.webBrowser.TabIndex = 0; 62 64 this.webBrowser.WebBrowserShortcutsEnabled = false; -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r7460 r7463 33 33 [StorableClass] 34 34 public sealed class SymbolicDataAnalysisExpressionLatexFormatter : NamedItem, ISymbolicExpressionTreeStringFormatter { 35 private List<double> constants; 35 private readonly List<double> constants; 36 private int targetCount; 36 37 private int currentLag; 37 38 … … 57 58 StringBuilder strBuilder = new StringBuilder(); 58 59 constants.Clear(); 60 targetCount = 1; 59 61 strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root)); 60 62 return strBuilder.ToString(); … … 96 98 } else if (node.Symbol is Division) { 97 99 if (node.SubtreeCount == 1) { 98 strBuilder.Append(@" \cfrac{1 }{");100 strBuilder.Append(@" \cfrac{1"); 99 101 } else { 100 102 strBuilder.Append(@" \cfrac{ "); … … 160 162 strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( "); 161 163 } else if (node.Symbol is StartSymbol) { 162 strBuilder.Append(" Result& = ");164 strBuilder.Append("target_" + (targetCount++) + "(t) & = "); 163 165 } else if (node.Symbol is Argument) { 164 166 var argSym = node.Symbol as Argument; … … 197 199 strBuilder.Append(@" \cdot "); 198 200 } else if (node.Symbol is Division) { 199 strBuilder.Append(@" }{ \cfrac{ "); 201 if (node.SubtreeCount <= 2) 202 strBuilder.Append(@" }{ "); 203 else 204 strBuilder.Append(@" }{ \cfrac{ "); 200 205 } else if (node.Symbol is Average) { 201 206 strBuilder.Append(@" + "); … … 228 233 strBuilder.Append(" , "); 229 234 } else if (node.Symbol is StartSymbol) { 230 strBuilder.Append(@"\\" + Environment.NewLine + " & "); 235 strBuilder.Append(@"\\" + Environment.NewLine); 236 strBuilder.Append("target_" + (targetCount++) + "(t) & = "); 231 237 } else if (node.Symbol is Power) { 232 238 strBuilder.Append(@"\right) ^ { \operatorname{round} \left("); … … 253 259 } else if (node.Symbol is Division) { 254 260 strBuilder.Append("} "); 255 if (node.SubtreeCount > 1) 256 strBuilder.Append("{1} "); 257 for (int i = 1; i < node.SubtreeCount; i++) { 261 if (node.SubtreeCount == 1 || node.SubtreeCount == 2) 258 262 strBuilder.Append(" } "); 259 } 263 else 264 for (int i = 0; i < node.SubtreeCount; i++) { 265 strBuilder.Append(" } "); 266 } 260 267 } else if (node.Symbol is Average) { 261 268 strBuilder.Append(@" \right) "); -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
r7268 r7463 51 51 private GreaterThan gtSymbol = new GreaterThan(); 52 52 private LessThan ltSymbol = new LessThan(); 53 private Integral integralSymbol = new Integral(); 54 private LaggedVariable laggedVariableSymbol = new LaggedVariable(); 55 private TimeLag timeLagSymbol = new TimeLag(); 53 56 54 57 public ISymbolicExpressionTree Simplify(ISymbolicExpressionTree originalTree) { … … 175 178 private bool IsConstant(ISymbolicExpressionTreeNode node) { 176 179 return node.Symbol is Constant; 180 } 181 182 // dynamic 183 private bool IsTimeLag(ISymbolicExpressionTreeNode node) { 184 return node.Symbol is TimeLag; 185 } 186 private bool IsIntegral(ISymbolicExpressionTreeNode node) { 187 return node.Symbol is Integral; 177 188 } 178 189 … … 223 234 } else if (IsNot(original)) { 224 235 return SimplifyNot(original); 236 } else if (IsTimeLag(original)) { 237 return SimplifyTimeLag(original); 238 } else if (IsIntegral(original)) { 239 return SimplifyIntegral(original); 225 240 } else { 226 241 return SimplifyAny(original); … … 359 374 return MakePower(GetSimplifiedTree(original.GetSubtree(0)), GetSimplifiedTree(original.GetSubtree(1))); 360 375 } 376 private ISymbolicExpressionTreeNode SimplifyTimeLag(ISymbolicExpressionTreeNode original) { 377 var laggedTreeNode = original as ILaggedTreeNode; 378 var simplifiedSubtree = GetSimplifiedTree(original.GetSubtree(0)); 379 if (!ContainsVariableCondition(simplifiedSubtree)) { 380 return AddLagToDynamicNodes(simplifiedSubtree, laggedTreeNode.Lag); 381 } else { 382 return MakeTimeLag(simplifiedSubtree, laggedTreeNode.Lag); 383 } 384 } 385 private ISymbolicExpressionTreeNode SimplifyIntegral(ISymbolicExpressionTreeNode original) { 386 var laggedTreeNode = original as ILaggedTreeNode; 387 var simplifiedSubtree = GetSimplifiedTree(original.GetSubtree(0)); 388 if (IsConstant(simplifiedSubtree)) { 389 return GetSimplifiedTree(MakeProduct(simplifiedSubtree, MakeConstant(-laggedTreeNode.Lag))); 390 } else { 391 return MakeIntegral(simplifiedSubtree, laggedTreeNode.Lag); 392 } 393 } 394 361 395 #endregion 362 396 363 397 #region low level tree restructuring 398 private ISymbolicExpressionTreeNode MakeTimeLag(ISymbolicExpressionTreeNode subtree, int lag) { 399 if (lag == 0) return subtree; 400 if (IsConstant(subtree)) return subtree; 401 var lagNode = (LaggedTreeNode)timeLagSymbol.CreateTreeNode(); 402 lagNode.Lag = lag; 403 lagNode.AddSubtree(subtree); 404 return lagNode; 405 } 406 407 private ISymbolicExpressionTreeNode MakeIntegral(ISymbolicExpressionTreeNode subtree, int lag) { 408 if (lag == 0) return subtree; 409 else if (lag == -1 || lag == 1) { 410 return MakeSum(subtree, AddLagToDynamicNodes((ISymbolicExpressionTreeNode)subtree.Clone(), lag)); 411 } else { 412 var node = (LaggedTreeNode)integralSymbol.CreateTreeNode(); 413 node.Lag = lag; 414 node.AddSubtree(subtree); 415 return node; 416 } 417 } 418 364 419 private ISymbolicExpressionTreeNode MakeNot(ISymbolicExpressionTreeNode t) { 365 420 if (IsConstant(t)) { … … 811 866 812 867 #region helper functions 868 private bool ContainsVariableCondition(ISymbolicExpressionTreeNode node) { 869 if (node.Symbol is VariableCondition) return true; 870 foreach (var subtree in node.Subtrees) 871 if (ContainsVariableCondition(subtree)) return true; 872 return false; 873 } 874 875 private ISymbolicExpressionTreeNode AddLagToDynamicNodes(ISymbolicExpressionTreeNode node, int lag) { 876 var laggedTreeNode = node as ILaggedTreeNode; 877 var variableNode = node as VariableTreeNode; 878 var variableConditionNode = node as VariableConditionTreeNode; 879 if (laggedTreeNode != null) 880 laggedTreeNode.Lag += lag; 881 else if (variableNode != null) { 882 var laggedVariableNode = (LaggedVariableTreeNode)laggedVariableSymbol.CreateTreeNode(); 883 laggedVariableNode.Lag = lag; 884 laggedVariableNode.VariableName = variableNode.VariableName; 885 return laggedVariableNode; 886 } else if (variableConditionNode != null) { 887 throw new NotSupportedException("Removal of time lags around variable condition symbols is not allowed."); 888 } 889 var subtrees = new List<ISymbolicExpressionTreeNode>(node.Subtrees); 890 while (node.SubtreeCount > 0) node.RemoveSubtree(0); 891 foreach (var subtree in subtrees) { 892 node.AddSubtree(AddLagToDynamicNodes(subtree, lag)); 893 } 894 return node; 895 } 813 896 814 897 private bool AreSameVariable(ISymbolicExpressionTreeNode a, ISymbolicExpressionTreeNode b) { -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionLineChartView.Designer.cs
r7129 r7463 44 44 /// </summary> 45 45 private void InitializeComponent() { 46 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea 2= new System.Windows.Forms.DataVisualization.Charting.ChartArea();47 System.Windows.Forms.DataVisualization.Charting.Legend legend 2= new System.Windows.Forms.DataVisualization.Charting.Legend();46 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); 47 System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); 48 48 this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart(); 49 49 this.targetVariableComboBox = new System.Windows.Forms.ComboBox(); … … 55 55 // chart 56 56 // 57 this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 58 | System.Windows.Forms.AnchorStyles.Left)59 60 chartArea 2.Name = "ChartArea";61 this.chart.ChartAreas.Add(chartArea 2);62 legend 2.Alignment = System.Drawing.StringAlignment.Center;63 legend 2.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;64 legend 2.Name = "Default";65 this.chart.Legends.Add(legend 2);57 this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 58 | System.Windows.Forms.AnchorStyles.Left) 59 | System.Windows.Forms.AnchorStyles.Right))); 60 chartArea1.Name = "ChartArea"; 61 this.chart.ChartAreas.Add(chartArea1); 62 legend1.Alignment = System.Drawing.StringAlignment.Center; 63 legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top; 64 legend1.Name = "Default"; 65 this.chart.Legends.Add(legend1); 66 66 this.chart.Location = new System.Drawing.Point(0, 31); 67 67 this.chart.Name = "chart"; 68 this.chart.Size = new System.Drawing.Size( 388, 194);68 this.chart.Size = new System.Drawing.Size(609, 194); 69 69 this.chart.TabIndex = 0; 70 70 this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend); … … 96 96 this.prognosedValuesCheckbox.Checked = true; 97 97 this.prognosedValuesCheckbox.CheckState = System.Windows.Forms.CheckState.Checked; 98 this.prognosedValuesCheckbox.Location = new System.Drawing.Point(271, 7);98 this.prognosedValuesCheckbox.Location = new System.Drawing.Point(271, 6); 99 99 this.prognosedValuesCheckbox.Name = "prognosedValuesCheckbox"; 100 100 this.prognosedValuesCheckbox.Size = new System.Drawing.Size(112, 17); … … 114 114 this.Controls.Add(this.chart); 115 115 this.Name = "TimeSeriesPrognosisSolutionLineChartView"; 116 this.Size = new System.Drawing.Size( 388, 225);116 this.Size = new System.Drawing.Size(609, 225); 117 117 ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit(); 118 118 this.ResumeLayout(false); -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionLineChartView.cs
r7154 r7463 36 36 private const string PROGNOSEDVALUES_TEST_SERIES_NAME = "Prognosed Values (test)"; 37 37 private const string PROGNOSEDVALUES_ALL_SERIES_NAME = "Prognosed Values (all samples)"; 38 private string prevTargetVariable;38 private int testPrognosisStart; 39 39 40 40 public new ITimeSeriesPrognosisSolution Content { … … 62 62 targetVariableComboBox.Items.Clear(); 63 63 if (Content != null) { 64 if (testPrognosisStart < Content.ProblemData.TestPartition.Start || testPrognosisStart >= Content.ProblemData.TestPartition.End) { 65 testPrognosisStart = Content.ProblemData.TestPartition.Start; 66 } 64 67 foreach (var targetVariable in Content.ProblemData.TargetVariables) 65 68 targetVariableComboBox.Items.Add(targetVariable); … … 107 110 this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.FastLine; 108 111 if (prognosedValuesCheckbox.Checked) { 112 int offsetToStart = testPrognosisStart - Content.ProblemData.TestPartition.Start; 109 113 this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Points 110 .DataBindXY(Content.ProblemData.TestIndizes.ToArray(), 111 Content.PrognosedTestValues.SelectMany(x => x).Skip(varIndex).TakeEvery(Content.ProblemData.TargetVariables.Count()).ToArray()); 114 .DataBindXY(Content.ProblemData.TestIndizes.Skip(offsetToStart).ToArray(), 115 Content.GetPrognosedValues(Enumerable.Range(testPrognosisStart, 1), Content.ProblemData.TestPartition.End - testPrognosisStart) 116 .SelectMany(x => x.SelectMany(y => y)) 117 .Skip(varIndex) 118 .TakeEvery(Content.ProblemData.TargetVariables.Count()) 119 .ToArray()); 112 120 } else { 113 121 this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Points 114 122 .DataBindXY(Content.ProblemData.TestIndizes.ToArray(), 115 Content.GetPrognosedValues(Content.ProblemData.TestIndizes, 1).SelectMany(x => x.Single()).Skip(varIndex).TakeEvery(Content.ProblemData.TargetVariables.Count()).ToArray()); 123 Content.GetPrognosedValues(Content.ProblemData.TestIndizes, 1) 124 .SelectMany(x => x.Single()) 125 .Skip(varIndex) 126 .TakeEvery(Content.ProblemData.TargetVariables.Count()) 127 .ToArray()); 116 128 } 117 129 this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Tag = Content; … … 163 175 RedrawChart(); 164 176 } 165 166 167 177 168 178 private void Chart_MouseDoubleClick(object sender, MouseEventArgs e) { … … 246 256 break; 247 257 case PROGNOSEDVALUES_TEST_SERIES_NAME: 258 testPrognosisStart = Content.ProblemData.TestPartition.Start; 248 259 indizes = Content.ProblemData.TestIndizes.ToArray(); 249 Content.PrognosedTestValues.SelectMany(x => x).Skip(varIndex).TakeEvery(260 predictedValues = Content.PrognosedTestValues.SelectMany(x => x).Skip(varIndex).TakeEvery( 250 261 Content.ProblemData.TargetVariables.Count()).ToArray(); 251 262 break; … … 266 277 Cursor = Cursors.Default; 267 278 } 279 268 280 private void chart_MouseDown(object sender, MouseEventArgs e) { 269 281 HitTestResult result = chart.HitTest(e.X, e.Y); 270 282 if (result.ChartElementType == ChartElementType.LegendItem && result.Series.Name != TARGETVARIABLE_SERIES_NAME) { 271 283 ToggleSeriesData(result.Series); 284 } else if (result.ChartElementType == ChartElementType.Axis || result.ChartElementType == ChartElementType.AxisLabels || 285 result.ChartElementType == ChartElementType.TickMarks) { 286 chart.ChartAreas[0].CursorX.SetCursorPixelPosition(new Point(e.X, e.Y), true); 287 int pos = (int)Math.Round(chart.ChartAreas[0].CursorX.Position); 288 if (pos >= Content.ProblemData.TestPartition.Start && pos < Content.ProblemData.TestPartition.End) { 289 testPrognosisStart = pos; 290 RedrawChart(); 291 } 272 292 } 273 293 } … … 280 300 e.LegendItems[3].Cells[1].ForeColor = this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black; 281 301 } 282 283 302 } 284 303 } -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineWeightedDirectionalSymmetryCalculator.cs
r7099 r7463 27 27 namespace HeuristicLab.Problems.DataAnalysis { 28 28 public class OnlineWeightedDirectionalSymmetryCalculator : IOnlineTimeSeriesCalculator { 29 private double prevEstimated;30 private double prevOriginal;31 29 private int n; 32 30 private double correctSum; … … 89 87 correctSum = 0; 90 88 incorrectSum = 0; 91 prevOriginal = double.NaN;92 prevEstimated = double.NaN;93 89 errorState = OnlineCalculatorError.InsufficientElementsAdded; 94 90 }
Note: See TracChangeset
for help on using the changeset viewer.