Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5317 for branches


Ignore:
Timestamp:
01/18/11 02:44:26 (14 years ago)
Author:
swagner
Message:

Worked on OKB (#1174)

Location:
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/OKBExperiment.cs

    r5304 r5317  
    337337    }
    338338    private void algorithm_Stopped(object sender, EventArgs e) {
    339       OnStopped();
    340 
    341339      try {
    342340        OKBClient.Instance.AddRun(AlgorithmId, ProblemId, algorithm);
     
    345343        OnExceptionOccurred(ex);
    346344      }
     345      OnStopped();
    347346    }
    348347    private void algorithm_Runs_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IRun> e) {
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/QueryView.Designer.cs

    r5304 r5317  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    48       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QueryView));
    4948      this.refreshResultsButton = new System.Windows.Forms.Button();
    5049      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     
    5554      this.resultsGroupBox = new System.Windows.Forms.GroupBox();
    5655      this.deserializeBlobsCheckBox = new System.Windows.Forms.CheckBox();
     56      this.resultsInfoPanel = new System.Windows.Forms.Panel();
     57      this.abortButton = new System.Windows.Forms.Button();
     58      this.resultsProgressBar = new System.Windows.Forms.ProgressBar();
     59      this.resultsInfoLabel = new System.Windows.Forms.Label();
     60      this.filtersInfoPanel = new System.Windows.Forms.Panel();
     61      this.filtersInfoLabel = new System.Windows.Forms.Label();
    5762      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    5863      this.splitContainer.Panel1.SuspendLayout();
     
    6166      this.filtersGroupBox.SuspendLayout();
    6267      this.resultsGroupBox.SuspendLayout();
     68      this.resultsInfoPanel.SuspendLayout();
     69      this.filtersInfoPanel.SuspendLayout();
    6370      this.SuspendLayout();
    6471      //
     
    8491      this.runCollectionView.Name = "runCollectionView";
    8592      this.runCollectionView.ReadOnly = false;
    86       this.runCollectionView.Size = new System.Drawing.Size(722, 156);
     93      this.runCollectionView.Size = new System.Drawing.Size(826, 223);
    8794      this.runCollectionView.TabIndex = 2;
    8895      //
     
    103110      //
    104111      this.splitContainer.Panel2.Controls.Add(this.resultsGroupBox);
    105       this.splitContainer.Size = new System.Drawing.Size(734, 435);
    106       this.splitContainer.SplitterDistance = 217;
     112      this.splitContainer.Size = new System.Drawing.Size(838, 567);
     113      this.splitContainer.SplitterDistance = 282;
    107114      this.splitContainer.TabIndex = 0;
    108115      //
     
    115122      this.filtersGroupBox.Location = new System.Drawing.Point(0, 0);
    116123      this.filtersGroupBox.Name = "filtersGroupBox";
    117       this.filtersGroupBox.Size = new System.Drawing.Size(734, 214);
     124      this.filtersGroupBox.Size = new System.Drawing.Size(838, 279);
    118125      this.filtersGroupBox.TabIndex = 0;
    119126      this.filtersGroupBox.TabStop = false;
     
    127134      this.filterPanel.Location = new System.Drawing.Point(6, 19);
    128135      this.filterPanel.Name = "filterPanel";
    129       this.filterPanel.Size = new System.Drawing.Size(722, 189);
     136      this.filterPanel.Size = new System.Drawing.Size(826, 254);
    130137      this.filterPanel.TabIndex = 0;
    131138      //
     
    140147      this.resultsGroupBox.Location = new System.Drawing.Point(0, 3);
    141148      this.resultsGroupBox.Name = "resultsGroupBox";
    142       this.resultsGroupBox.Size = new System.Drawing.Size(734, 211);
     149      this.resultsGroupBox.Size = new System.Drawing.Size(838, 278);
    143150      this.resultsGroupBox.TabIndex = 0;
    144151      this.resultsGroupBox.TabStop = false;
     
    153160      this.deserializeBlobsCheckBox.Name = "deserializeBlobsCheckBox";
    154161      this.deserializeBlobsCheckBox.Size = new System.Drawing.Size(106, 17);
    155       this.deserializeBlobsCheckBox.TabIndex = 3;
     162      this.deserializeBlobsCheckBox.TabIndex = 1;
    156163      this.deserializeBlobsCheckBox.Text = "&Deserialize Blobs";
    157164      this.deserializeBlobsCheckBox.UseVisualStyleBackColor = true;
    158165      //
     166      // resultsInfoPanel
     167      //
     168      this.resultsInfoPanel.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
     169      this.resultsInfoPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     170      this.resultsInfoPanel.Controls.Add(this.abortButton);
     171      this.resultsInfoPanel.Controls.Add(this.resultsProgressBar);
     172      this.resultsInfoPanel.Controls.Add(this.resultsInfoLabel);
     173      this.resultsInfoPanel.Location = new System.Drawing.Point(238, 339);
     174      this.resultsInfoPanel.Name = "resultsInfoPanel";
     175      this.resultsInfoPanel.Size = new System.Drawing.Size(362, 87);
     176      this.resultsInfoPanel.TabIndex = 1;
     177      this.resultsInfoPanel.Visible = false;
     178      //
     179      // abortButton
     180      //
     181      this.abortButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
     182      this.abortButton.Location = new System.Drawing.Point(3, 58);
     183      this.abortButton.Name = "abortButton";
     184      this.abortButton.Size = new System.Drawing.Size(354, 23);
     185      this.abortButton.TabIndex = 2;
     186      this.abortButton.Text = "&Abort";
     187      this.abortButton.UseVisualStyleBackColor = true;
     188      this.abortButton.Click += new System.EventHandler(this.abortButton_Click);
     189      //
     190      // resultsProgressBar
     191      //
     192      this.resultsProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
     193      this.resultsProgressBar.Enabled = false;
     194      this.resultsProgressBar.Location = new System.Drawing.Point(3, 29);
     195      this.resultsProgressBar.Name = "resultsProgressBar";
     196      this.resultsProgressBar.Size = new System.Drawing.Size(354, 23);
     197      this.resultsProgressBar.Step = 1;
     198      this.resultsProgressBar.TabIndex = 1;
     199      //
     200      // resultsInfoLabel
     201      //
     202      this.resultsInfoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
     203      this.resultsInfoLabel.Enabled = false;
     204      this.resultsInfoLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     205      this.resultsInfoLabel.Location = new System.Drawing.Point(3, 3);
     206      this.resultsInfoLabel.Name = "resultsInfoLabel";
     207      this.resultsInfoLabel.Size = new System.Drawing.Size(354, 23);
     208      this.resultsInfoLabel.TabIndex = 0;
     209      this.resultsInfoLabel.Text = "Loading ...";
     210      this.resultsInfoLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
     211      //
     212      // filtersInfoPanel
     213      //
     214      this.filtersInfoPanel.Anchor = System.Windows.Forms.AnchorStyles.Top;
     215      this.filtersInfoPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     216      this.filtersInfoPanel.Controls.Add(this.filtersInfoLabel);
     217      this.filtersInfoPanel.Enabled = false;
     218      this.filtersInfoPanel.Location = new System.Drawing.Point(238, 136);
     219      this.filtersInfoPanel.Name = "filtersInfoPanel";
     220      this.filtersInfoPanel.Size = new System.Drawing.Size(362, 33);
     221      this.filtersInfoPanel.TabIndex = 0;
     222      this.filtersInfoPanel.Visible = false;
     223      //
     224      // filtersInfoLabel
     225      //
     226      this.filtersInfoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
     227      this.filtersInfoLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     228      this.filtersInfoLabel.Location = new System.Drawing.Point(3, 4);
     229      this.filtersInfoLabel.Name = "filtersInfoLabel";
     230      this.filtersInfoLabel.Size = new System.Drawing.Size(354, 23);
     231      this.filtersInfoLabel.TabIndex = 0;
     232      this.filtersInfoLabel.Text = "Loading Filters ...";
     233      this.filtersInfoLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
     234      //
    159235      // QueryView
    160236      //
    161237      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    162238      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     239      this.Controls.Add(this.filtersInfoPanel);
     240      this.Controls.Add(this.resultsInfoPanel);
    163241      this.Controls.Add(this.splitContainer);
    164242      this.Name = "QueryView";
    165       this.Size = new System.Drawing.Size(734, 435);
     243      this.Size = new System.Drawing.Size(838, 567);
    166244      this.splitContainer.Panel1.ResumeLayout(false);
    167245      this.splitContainer.Panel2.ResumeLayout(false);
     
    171249      this.resultsGroupBox.ResumeLayout(false);
    172250      this.resultsGroupBox.PerformLayout();
     251      this.resultsInfoPanel.ResumeLayout(false);
     252      this.filtersInfoPanel.ResumeLayout(false);
    173253      this.ResumeLayout(false);
    174254
     
    185265    private System.Windows.Forms.Panel filterPanel;
    186266    private System.Windows.Forms.CheckBox deserializeBlobsCheckBox;
     267    private System.Windows.Forms.Panel resultsInfoPanel;
     268    private System.Windows.Forms.ProgressBar resultsProgressBar;
     269    private System.Windows.Forms.Label resultsInfoLabel;
     270    private System.Windows.Forms.Button abortButton;
     271    private System.Windows.Forms.Panel filtersInfoPanel;
     272    private System.Windows.Forms.Label filtersInfoLabel;
    187273
    188274  }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/QueryView.cs

    r5304 r5317  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.IO;
    2524using System.Linq;
     25using System.Threading;
     26using System.Threading.Tasks;
    2627using System.Windows.Forms;
    2728using HeuristicLab.Core;
     
    3637  [Content(typeof(OKBClient), false)]
    3738  public sealed partial class QueryView : HeuristicLab.MainForm.WindowsForms.View {
     39    private CancellationTokenSource cancellationTokenSource;
    3840    private CombinedFilterView combinedFilterView;
    3941
     
    4446    protected override void OnInitialized(EventArgs e) {
    4547      base.OnInitialized(e);
    46       this.Cursor = Cursors.AppStarting;
    47 
    48       Func<CombinedFilter> func = () => {
    49         return OKBClient.Instance.GetFilters().OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.And).FirstOrDefault();
    50       };
    51 
    52       func.BeginInvoke((IAsyncResult result) => {
    53         CombinedFilter filter = func.EndInvoke(result);
    54         if (InvokeRequired) Invoke(new Action<CombinedFilter>(FinishedLoadingFilter), filter);
    55         else FinishedLoadingFilter(filter);
    56       }, null);
     48      LoadFiltersAsync();
    5749    }
    5850
    59     private void FinishedLoadingFilter(CombinedFilter filter) {
    60       if (filter != null) {
    61         combinedFilterView = (CombinedFilterView)MainFormManager.CreateView(typeof(CombinedFilterView));
    62         combinedFilterView.Content = (CombinedFilter)filter.Clone();
    63         Control control = (Control)combinedFilterView;
    64         control.Dock = DockStyle.Fill;
    65         filterPanel.Controls.Add(control);
    66       }
    67       this.Cursor = Cursors.Default;
    68       SetEnabledStateOfControls();
    69     }
    7051
    7152    protected override void SetEnabledStateOfControls() {
     
    7455    }
    7556
    76     private void refreshResultsButton_Click(object sender, EventArgs e) {
     57    #region Load Filters
     58    private void LoadFiltersAsync() {
     59      Cursor = Cursors.AppStarting;
     60      filtersInfoPanel.Visible = true;
     61      splitContainer.Enabled = false;
     62
     63      Task<CombinedFilter> task = Task.Factory.StartNew<CombinedFilter>(() => {
     64        return OKBClient.Instance.GetFilters().OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.And).FirstOrDefault();
     65      });
     66      task.ContinueWith(t => {
     67        CombinedFilter filter = t.Result;
     68        Invoke(new Action(() => {
     69          if (filter != null) {
     70            combinedFilterView = (CombinedFilterView)MainFormManager.CreateView(typeof(CombinedFilterView));
     71            combinedFilterView.Content = (CombinedFilter)filter.Clone();
     72            Control control = (Control)combinedFilterView;
     73            control.Dock = DockStyle.Fill;
     74            filterPanel.Controls.Add(control);
     75          }
     76          filtersInfoPanel.Visible = false;
     77          splitContainer.Enabled = true;
     78          this.Cursor = Cursors.Default;
     79          SetEnabledStateOfControls();
     80        }));
     81      });
     82    }
     83    #endregion
     84
     85    #region Load Results
     86    private void LoadResultsAsync(int batchSize) {
    7787      bool deserialize = deserializeBlobsCheckBox.Checked;
    7888
    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;
     89      Cursor = Cursors.AppStarting;
     90      resultsInfoLabel.Text = "Loading Results ...";
     91      resultsProgressBar.Value = 0;
     92      resultsProgressBar.Step = batchSize;
     93      abortButton.Enabled = true;
     94      resultsInfoPanel.Visible = true;
     95      splitContainer.Enabled = false;
     96      cancellationTokenSource = new CancellationTokenSource();
     97      CancellationToken cancellationToken = cancellationTokenSource.Token;
    8598
    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;
     99      Task task = Task.Factory.StartNew(() => {
     100        var ids = OKBClient.Instance.GetQueryResultIds(combinedFilterView.Content);
     101        int idsCount = ids.Count();
    90102
    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;
     103        Invoke(new Action(() => {
     104          resultsInfoLabel.Text = "Loaded 0 of " + idsCount.ToString() + " Results ...";
     105          resultsProgressBar.Maximum = idsCount;
     106        }));
    99107
    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);
     108        RunCollection runs = new RunCollection();
     109        runs.CollectionReset += new Collections.CollectionItemsChangedEventHandler<IRun>(runs_CollectionReset);
     110        runCollectionView.Content = runs;
     111        while (ids.Count() > 0) {
     112          cancellationToken.ThrowIfCancellationRequested();
     113          runs.AddRange(OKBClient.Instance.GetQueryResults(ids.Take(batchSize)).Select(x => ConvertToOptimizationRun(x, deserialize)));
     114          ids = ids.Skip(batchSize);
     115          Invoke(new Action(() => {
     116            resultsInfoLabel.Text = "Loaded " + runs.Count + " of " + idsCount.ToString() + " Results ...";
     117            resultsProgressBar.PerformStep();
     118          }));
     119        }
     120      }, cancellationToken);
     121      task.ContinueWith(t => {
     122        Invoke(new Action(() => {
     123          cancellationTokenSource.Dispose();
     124          cancellationTokenSource = null;
     125          resultsInfoPanel.Visible = false;
     126          splitContainer.Enabled = true;
     127          this.Cursor = Cursors.Default;
     128          SetEnabledStateOfControls();
     129        }));
     130      });
     131    }
    110132
    111       SetEnabledStateOfControls();
     133    void runs_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IRun> e) {
     134    }
     135    #endregion
     136
     137    private void refreshResultsButton_Click(object sender, EventArgs e) {
     138      LoadResultsAsync(10);
     139    }
     140
     141    private void abortButton_Click(object sender, EventArgs e) {
     142      if (cancellationTokenSource != null) cancellationTokenSource.Cancel();
     143      abortButton.Enabled = false;
    112144    }
    113145
Note: See TracChangeset for help on using the changeset viewer.