Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/11 05:03:21 (14 years ago)
Author:
swagner
Message:

Worked on OKB (#1174)

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  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Windows.Forms;
     
    4849      base.OnContentChanged();
    4950      RemoveFilters();
     51      label.Text = string.Empty;
    5052      if (Content != null) {
     53        string nl = Environment.NewLine;
     54        label.Text = Content.Operation == BooleanOperation.And ? "A" + nl + "N" + nl + "D" : "O" + nl + "R";
     55
    5156        foreach (Filter filter in Content.Filters)
    5257          AddFilter(filter);
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/QueryView.Designer.cs

    r5295 r5304  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
     48      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QueryView));
    4849      this.refreshResultsButton = new System.Windows.Forms.Button();
    4950      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();
    5252      this.splitContainer = new System.Windows.Forms.SplitContainer();
    5353      this.filtersGroupBox = new System.Windows.Forms.GroupBox();
     54      this.filterPanel = new System.Windows.Forms.Panel();
    5455      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();
    5757      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    5858      this.splitContainer.Panel1.SuspendLayout();
     
    7373      this.refreshResultsButton.UseVisualStyleBackColor = true;
    7474      this.refreshResultsButton.Click += new System.EventHandler(this.refreshResultsButton_Click);
    75       //
    76       // showRunsButton
    77       //
    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);
    8575      //
    8676      // runCollectionView
     
    130120      this.filtersGroupBox.Text = "Filters";
    131121      //
    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.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       // nrOfRunsButton
    149       //
    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       //
    158122      // filterPanel
    159123      //
     
    165129      this.filterPanel.Size = new System.Drawing.Size(722, 189);
    166130      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;
    167158      //
    168159      // QueryView
     
    179170      this.filtersGroupBox.ResumeLayout(false);
    180171      this.resultsGroupBox.ResumeLayout(false);
     172      this.resultsGroupBox.PerformLayout();
    181173      this.ResumeLayout(false);
    182174
     
    187179    private System.Windows.Forms.Button refreshResultsButton;
    188180    private System.Windows.Forms.ToolTip toolTip;
    189     private RunCollectionView runCollectionView;
    190     private System.Windows.Forms.Button showRunsButton;
     181    private HeuristicLab.Optimization.Views.RunCollectionView runCollectionView;
    191182    private System.Windows.Forms.SplitContainer splitContainer;
    192183    private System.Windows.Forms.GroupBox filtersGroupBox;
    193184    private System.Windows.Forms.GroupBox resultsGroupBox;
    194     private System.Windows.Forms.Button nrOfRunsButton;
    195185    private System.Windows.Forms.Panel filterPanel;
     186    private System.Windows.Forms.CheckBox deserializeBlobsCheckBox;
    196187
    197188  }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/QueryView.cs

    r5295 r5304  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.IO;
    2325using System.Linq;
    2426using System.Windows.Forms;
     27using HeuristicLab.Core;
     28using HeuristicLab.Data;
    2529using HeuristicLab.MainForm;
    2630using HeuristicLab.MainForm.WindowsForms;
     31using HeuristicLab.Optimization;
     32using HeuristicLab.Persistence.Default.Xml;
    2733
    2834namespace HeuristicLab.Clients.OKB {
     
    3036  [Content(typeof(OKBClient), false)]
    3137  public sealed partial class QueryView : HeuristicLab.MainForm.WindowsForms.View {
    32     private AndFilterView andFilterView;
     38    private CombinedFilterView combinedFilterView;
    3339
    3440    public QueryView() {
     
    4046      this.Cursor = Cursors.AppStarting;
    4147
    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();
    4450      };
    4551
    4652      func.BeginInvoke((IAsyncResult result) => {
    47         AndFilter filter = func.EndInvoke(result);
    48         if (InvokeRequired) Invoke(new Action<AndFilter>(FinishedLoadingAndFilter), filter);
    49         else FinishedLoadingAndFilter(filter);
     53        CombinedFilter filter = func.EndInvoke(result);
     54        if (InvokeRequired) Invoke(new Action<CombinedFilter>(FinishedLoadingFilter), filter);
     55        else FinishedLoadingFilter(filter);
    5056      }, null);
    5157    }
    5258
    53     private void FinishedLoadingAndFilter(AndFilter filter) {
     59    private void FinishedLoadingFilter(CombinedFilter filter) {
    5460      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;
    5864        control.Dock = DockStyle.Fill;
    5965        filterPanel.Controls.Add(control);
     
    6571    protected override void SetEnabledStateOfControls() {
    6672      base.SetEnabledStateOfControls();
    67       resultsGroupBox.Enabled = andFilterView != null;
    68       showRunsButton.Enabled = (runCollectionView.Content != null) && (runCollectionView.Content.Count > 0);
     73      resultsGroupBox.Enabled = combinedFilterView != null;
    6974    }
    7075
    7176    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
    75111      SetEnabledStateOfControls();
    76112    }
    77113
    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;
    82123    }
    83124
    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;
    87150    }
    88151  }
Note: See TracChangeset for help on using the changeset viewer.