- Timestamp:
- 01/17/11 05:03:21 (14 years ago)
- Location:
- branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views
- Files:
-
- 4 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/CombinedFilterView.cs
r5289 r5304 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Windows.Forms; … … 48 49 base.OnContentChanged(); 49 50 RemoveFilters(); 51 label.Text = string.Empty; 50 52 if (Content != null) { 53 string nl = Environment.NewLine; 54 label.Text = Content.Operation == BooleanOperation.And ? "A" + nl + "N" + nl + "D" : "O" + nl + "R"; 55 51 56 foreach (Filter filter in Content.Filters) 52 57 AddFilter(filter); -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/QueryView.Designer.cs
r5295 r5304 46 46 private void InitializeComponent() { 47 47 this.components = new System.ComponentModel.Container(); 48 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QueryView)); 48 49 this.refreshResultsButton = new System.Windows.Forms.Button(); 49 50 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 50 this.showRunsButton = new System.Windows.Forms.Button(); 51 this.runCollectionView = new HeuristicLab.Clients.OKB.RunCollectionView(); 51 this.runCollectionView = new HeuristicLab.Optimization.Views.RunCollectionView(); 52 52 this.splitContainer = new System.Windows.Forms.SplitContainer(); 53 53 this.filtersGroupBox = new System.Windows.Forms.GroupBox(); 54 this.filterPanel = new System.Windows.Forms.Panel(); 54 55 this.resultsGroupBox = new System.Windows.Forms.GroupBox(); 55 this.nrOfRunsButton = new System.Windows.Forms.Button(); 56 this.filterPanel = new System.Windows.Forms.Panel(); 56 this.deserializeBlobsCheckBox = new System.Windows.Forms.CheckBox(); 57 57 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 58 58 this.splitContainer.Panel1.SuspendLayout(); … … 73 73 this.refreshResultsButton.UseVisualStyleBackColor = true; 74 74 this.refreshResultsButton.Click += new System.EventHandler(this.refreshResultsButton_Click); 75 //76 // showRunsButton77 //78 this.showRunsButton.Location = new System.Drawing.Point(36, 19);79 this.showRunsButton.Name = "showRunsButton";80 this.showRunsButton.Size = new System.Drawing.Size(75, 24);81 this.showRunsButton.TabIndex = 1;82 this.showRunsButton.Text = "&Show Runs";83 this.showRunsButton.UseVisualStyleBackColor = true;84 this.showRunsButton.Click += new System.EventHandler(this.showRunsButton_Click);85 75 // 86 76 // runCollectionView … … 130 120 this.filtersGroupBox.Text = "Filters"; 131 121 // 132 // resultsGroupBox133 //134 this.resultsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)135 | System.Windows.Forms.AnchorStyles.Left)136 | System.Windows.Forms.AnchorStyles.Right)));137 this.resultsGroupBox.Controls.Add(this.nrOfRunsButton);138 this.resultsGroupBox.Controls.Add(this.refreshResultsButton);139 this.resultsGroupBox.Controls.Add(this.runCollectionView);140 this.resultsGroupBox.Controls.Add(this.showRunsButton);141 this.resultsGroupBox.Location = new System.Drawing.Point(0, 3);142 this.resultsGroupBox.Name = "resultsGroupBox";143 this.resultsGroupBox.Size = new System.Drawing.Size(734, 211);144 this.resultsGroupBox.TabIndex = 0;145 this.resultsGroupBox.TabStop = false;146 this.resultsGroupBox.Text = "Results";147 //148 // nrOfRunsButton149 //150 this.nrOfRunsButton.Location = new System.Drawing.Point(117, 19);151 this.nrOfRunsButton.Name = "nrOfRunsButton";152 this.nrOfRunsButton.Size = new System.Drawing.Size(75, 23);153 this.nrOfRunsButton.TabIndex = 3;154 this.nrOfRunsButton.Text = "No. of Runs";155 this.nrOfRunsButton.UseVisualStyleBackColor = true;156 this.nrOfRunsButton.Click += new System.EventHandler(this.nrOfRunsButton_Click);157 //158 122 // filterPanel 159 123 // … … 165 129 this.filterPanel.Size = new System.Drawing.Size(722, 189); 166 130 this.filterPanel.TabIndex = 0; 131 // 132 // resultsGroupBox 133 // 134 this.resultsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 135 | System.Windows.Forms.AnchorStyles.Left) 136 | System.Windows.Forms.AnchorStyles.Right))); 137 this.resultsGroupBox.Controls.Add(this.deserializeBlobsCheckBox); 138 this.resultsGroupBox.Controls.Add(this.refreshResultsButton); 139 this.resultsGroupBox.Controls.Add(this.runCollectionView); 140 this.resultsGroupBox.Location = new System.Drawing.Point(0, 3); 141 this.resultsGroupBox.Name = "resultsGroupBox"; 142 this.resultsGroupBox.Size = new System.Drawing.Size(734, 211); 143 this.resultsGroupBox.TabIndex = 0; 144 this.resultsGroupBox.TabStop = false; 145 this.resultsGroupBox.Text = "Results"; 146 // 147 // deserializeBlobsCheckBox 148 // 149 this.deserializeBlobsCheckBox.AutoSize = true; 150 this.deserializeBlobsCheckBox.Checked = true; 151 this.deserializeBlobsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; 152 this.deserializeBlobsCheckBox.Location = new System.Drawing.Point(62, 24); 153 this.deserializeBlobsCheckBox.Name = "deserializeBlobsCheckBox"; 154 this.deserializeBlobsCheckBox.Size = new System.Drawing.Size(106, 17); 155 this.deserializeBlobsCheckBox.TabIndex = 3; 156 this.deserializeBlobsCheckBox.Text = "&Deserialize Blobs"; 157 this.deserializeBlobsCheckBox.UseVisualStyleBackColor = true; 167 158 // 168 159 // QueryView … … 179 170 this.filtersGroupBox.ResumeLayout(false); 180 171 this.resultsGroupBox.ResumeLayout(false); 172 this.resultsGroupBox.PerformLayout(); 181 173 this.ResumeLayout(false); 182 174 … … 187 179 private System.Windows.Forms.Button refreshResultsButton; 188 180 private System.Windows.Forms.ToolTip toolTip; 189 private RunCollectionView runCollectionView; 190 private System.Windows.Forms.Button showRunsButton; 181 private HeuristicLab.Optimization.Views.RunCollectionView runCollectionView; 191 182 private System.Windows.Forms.SplitContainer splitContainer; 192 183 private System.Windows.Forms.GroupBox filtersGroupBox; 193 184 private System.Windows.Forms.GroupBox resultsGroupBox; 194 private System.Windows.Forms.Button nrOfRunsButton;195 185 private System.Windows.Forms.Panel filterPanel; 186 private System.Windows.Forms.CheckBox deserializeBlobsCheckBox; 196 187 197 188 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/QueryView.cs
r5295 r5304 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.IO; 23 25 using System.Linq; 24 26 using System.Windows.Forms; 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 25 29 using HeuristicLab.MainForm; 26 30 using HeuristicLab.MainForm.WindowsForms; 31 using HeuristicLab.Optimization; 32 using HeuristicLab.Persistence.Default.Xml; 27 33 28 34 namespace HeuristicLab.Clients.OKB { … … 30 36 [Content(typeof(OKBClient), false)] 31 37 public sealed partial class QueryView : HeuristicLab.MainForm.WindowsForms.View { 32 private AndFilterView andFilterView;38 private CombinedFilterView combinedFilterView; 33 39 34 40 public QueryView() { … … 40 46 this.Cursor = Cursors.AppStarting; 41 47 42 Func< AndFilter> func = () => {43 return OKBClient.Instance.GetFilters().OfType< AndFilter>().FirstOrDefault();48 Func<CombinedFilter> func = () => { 49 return OKBClient.Instance.GetFilters().OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.And).FirstOrDefault(); 44 50 }; 45 51 46 52 func.BeginInvoke((IAsyncResult result) => { 47 AndFilter filter = func.EndInvoke(result);48 if (InvokeRequired) Invoke(new Action< AndFilter>(FinishedLoadingAndFilter), filter);49 else FinishedLoading AndFilter(filter);53 CombinedFilter filter = func.EndInvoke(result); 54 if (InvokeRequired) Invoke(new Action<CombinedFilter>(FinishedLoadingFilter), filter); 55 else FinishedLoadingFilter(filter); 50 56 }, null); 51 57 } 52 58 53 private void FinishedLoading AndFilter(AndFilter filter) {59 private void FinishedLoadingFilter(CombinedFilter filter) { 54 60 if (filter != null) { 55 andFilterView = (AndFilterView)MainFormManager.CreateView(typeof(AndFilterView));56 andFilterView.Content = (AndFilter)filter.Clone();57 Control control = (Control) andFilterView;61 combinedFilterView = (CombinedFilterView)MainFormManager.CreateView(typeof(CombinedFilterView)); 62 combinedFilterView.Content = (CombinedFilter)filter.Clone(); 63 Control control = (Control)combinedFilterView; 58 64 control.Dock = DockStyle.Fill; 59 65 filterPanel.Controls.Add(control); … … 65 71 protected override void SetEnabledStateOfControls() { 66 72 base.SetEnabledStateOfControls(); 67 resultsGroupBox.Enabled = andFilterView != null; 68 showRunsButton.Enabled = (runCollectionView.Content != null) && (runCollectionView.Content.Count > 0); 73 resultsGroupBox.Enabled = combinedFilterView != null; 69 74 } 70 75 71 76 private void refreshResultsButton_Click(object sender, EventArgs e) { 72 DateTime start = DateTime.Now; 73 runCollectionView.Content = OKBClient.Instance.QueryRuns(andFilterView.Content); 74 MessageBox.Show((DateTime.Now - start).ToString()); 77 bool deserialize = deserializeBlobsCheckBox.Checked; 78 79 System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); 80 sw.Start(); 81 long count = OKBClient.Instance.GetNumberOfQueryResults(combinedFilterView.Content); 82 sw.Stop(); 83 MessageBox.Show(count.ToString() + " Runs"); 84 if (MessageBox.Show(sw.Elapsed.ToString(), "GetNumberOfQueryResults", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; 85 86 sw.Restart(); 87 var ids = OKBClient.Instance.GetQueryResultIds(combinedFilterView.Content); 88 sw.Stop(); 89 if (MessageBox.Show(sw.Elapsed.ToString(), "GetQueryResultIds", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; 90 91 sw.Restart(); 92 List<QueryResult> results = new List<QueryResult>(); 93 while (ids.Count() > 0) { 94 results.AddRange(OKBClient.Instance.GetQueryResults(ids.Take(50))); 95 ids = ids.Skip(50); 96 } 97 sw.Stop(); 98 if (MessageBox.Show(sw.Elapsed.ToString(), "GetQueryResults", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; 99 100 sw.Restart(); 101 IEnumerable<QueryResult> res = results.AsEnumerable(); 102 RunCollection runs = new RunCollection(); 103 runCollectionView.Content = runs; 104 while (res.Count() > 0) { 105 runs.AddRange(res.Take(50).Select(x => ConvertToOptimizationRun(x, deserialize))); 106 res = res.Skip(50); 107 } 108 sw.Stop(); 109 MessageBox.Show(sw.Elapsed.ToString(), "Conversion", MessageBoxButtons.OK); 110 75 111 SetEnabledStateOfControls(); 76 112 } 77 113 78 private void showRunsButton_Click(object sender, EventArgs e) { 79 DateTime start = DateTime.Now; 80 MainFormManager.MainForm.ShowContent(OKBClient.Instance.ConvertOKBRunsToOptimizationRuns(runCollectionView.Content)); 81 MessageBox.Show((DateTime.Now - start).ToString()); 114 private Optimization.IRun ConvertToOptimizationRun(QueryResult queryResult, bool deserialize) { 115 Optimization.Run run = new Optimization.Run(); 116 foreach (QueryValue value in queryResult.AlgorithmParameters) 117 run.Parameters.Add(value.Name, ConvertToItem(value, deserialize)); 118 foreach (QueryValue value in queryResult.ProblemParameters) 119 run.Parameters.Add(value.Name, ConvertToItem(value, deserialize)); 120 foreach (QueryValue value in queryResult.Results) 121 run.Results.Add(value.Name, ConvertToItem(value, deserialize)); 122 return run; 82 123 } 83 124 84 private void nrOfRunsButton_Click(object sender, EventArgs e) { 85 long runs = OKBClient.Instance.QueryNumberOfRuns(andFilterView.Content); 86 MessageBox.Show(runs.ToString()); 125 private IItem ConvertToItem(QueryValue value, bool deserialize) { 126 if (value is QueryBlobValue) { 127 if (deserialize) { 128 IItem item = null; 129 using (MemoryStream stream = new MemoryStream(((QueryBlobValue)value).Value)) { 130 try { 131 item = XmlParser.Deserialize<IItem>(stream); 132 } 133 catch (Exception) { } 134 stream.Close(); 135 } 136 return item != null ? item : new StringValue(((QueryBlobValue)value).DataTypeName); 137 } else { 138 return new StringValue(((QueryBlobValue)value).DataTypeName); 139 } 140 } else if (value is QueryBoolValue) { 141 return new BoolValue(((QueryBoolValue)value).Value); 142 } else if (value is QueryFloatValue) { 143 return new DoubleValue(((QueryFloatValue)value).Value); 144 } else if (value is QueryIntValue) { 145 return new IntValue((int)((QueryIntValue)value).Value); 146 } else if (value is QueryStringValue) { 147 return new StringValue(((QueryStringValue)value).Value); 148 } 149 return null; 87 150 } 88 151 }
Note: See TracChangeset
for help on using the changeset viewer.