Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/16/15 17:04:35 (8 years ago)
Author:
abeham
Message:

#2457, #2431: updated from trunk, worked on okb connection for downloading knowledge base

Location:
branches/PerformanceComparison
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison

    • Property svn:ignore
      •  

        old new  
        22*.suo
        33*.user
         4.git
         5.gitignore
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.Designer.cs

    r12957 r13475  
    3434    /// </summary>
    3535    private void InitializeComponent() {
     36      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExpertSystemView));
    3637      this.evaluationsLimitabel = new System.Windows.Forms.Label();
    3738      this.maxEvaluationsTextBox = new System.Windows.Forms.TextBox();
     
    5051      this.algorithmInstancesViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5152      this.problemInstancesTabPage = new System.Windows.Forms.TabPage();
    52       this.problemInstancesView = new HeuristicLab.Optimization.Views.RunCollectionBubbleChartView();
     53      this.problemInstancesView = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     54      this.instancesDropPanel = new System.Windows.Forms.Panel();
     55      this.dragFLAHereLabel = new System.Windows.Forms.Label();
     56      this.refreshMapButton = new System.Windows.Forms.Button();
    5357      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
     58      this.okbDownloadButton = new System.Windows.Forms.Button();
    5459      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5560      this.tabControl.SuspendLayout();
     
    5964      this.okbTabPage.SuspendLayout();
    6065      this.problemInstancesTabPage.SuspendLayout();
     66      this.instancesDropPanel.SuspendLayout();
    6167      this.SuspendLayout();
    6268      //
     
    8389      // maxEvaluationsTextBox
    8490      //
    85       this.maxEvaluationsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     91      this.maxEvaluationsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    8692            | System.Windows.Forms.AnchorStyles.Right)));
    8793      this.maxEvaluationsTextBox.Location = new System.Drawing.Point(75, 26);
     
    94100      //
    95101      this.tabControl.AllowDrop = true;
    96       this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    97             | System.Windows.Forms.AnchorStyles.Left)
     102      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     103            | System.Windows.Forms.AnchorStyles.Left) 
    98104            | System.Windows.Forms.AnchorStyles.Right)));
    99105      this.tabControl.Controls.Add(this.problemTabPage);
     
    127133      // problemViewHost
    128134      //
    129       this.problemViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    130             | System.Windows.Forms.AnchorStyles.Left)
     135      this.problemViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     136            | System.Windows.Forms.AnchorStyles.Left) 
    131137            | System.Windows.Forms.AnchorStyles.Right)));
    132138      this.problemViewHost.Caption = "View";
     
    143149      // openProblemButton
    144150      //
    145       this.openProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
     151      this.openProblemButton.Image = ((System.Drawing.Image)(resources.GetObject("openProblemButton.Image")));
    146152      this.openProblemButton.Location = new System.Drawing.Point(36, 6);
    147153      this.openProblemButton.Name = "openProblemButton";
     
    154160      // newProblemButton
    155161      //
    156       this.newProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;
     162      this.newProblemButton.Image = ((System.Drawing.Image)(resources.GetObject("newProblemButton.Image")));
    157163      this.newProblemButton.Location = new System.Drawing.Point(6, 6);
    158164      this.newProblemButton.Name = "newProblemButton";
     
    178184      // algorithmViewHost
    179185      //
    180       this.algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    181             | System.Windows.Forms.AnchorStyles.Left)
     186      this.algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     187            | System.Windows.Forms.AnchorStyles.Left) 
    182188            | System.Windows.Forms.AnchorStyles.Right)));
    183189      this.algorithmViewHost.Caption = "View";
     
    203209      // suggestedInstancesComboBox
    204210      //
    205       this.suggestedInstancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     211      this.suggestedInstancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    206212            | System.Windows.Forms.AnchorStyles.Right)));
    207213      this.suggestedInstancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     
    237243      // okbTabPage
    238244      //
     245      this.okbTabPage.Controls.Add(this.okbDownloadButton);
    239246      this.okbTabPage.Controls.Add(this.algorithmInstancesViewHost);
    240247      this.okbTabPage.Location = new System.Drawing.Point(4, 22);
     
    248255      // algorithmInstancesViewHost
    249256      //
     257      this.algorithmInstancesViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     258            | System.Windows.Forms.AnchorStyles.Left)
     259            | System.Windows.Forms.AnchorStyles.Right)));
    250260      this.algorithmInstancesViewHost.Caption = "View";
    251261      this.algorithmInstancesViewHost.Content = null;
    252       this.algorithmInstancesViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    253262      this.algorithmInstancesViewHost.Enabled = false;
    254       this.algorithmInstancesViewHost.Location = new System.Drawing.Point(3, 3);
     263      this.algorithmInstancesViewHost.Location = new System.Drawing.Point(3, 35);
    255264      this.algorithmInstancesViewHost.Name = "algorithmInstancesViewHost";
    256265      this.algorithmInstancesViewHost.ReadOnly = false;
    257       this.algorithmInstancesViewHost.Size = new System.Drawing.Size(532, 329);
     266      this.algorithmInstancesViewHost.Size = new System.Drawing.Size(532, 297);
    258267      this.algorithmInstancesViewHost.TabIndex = 0;
    259268      this.algorithmInstancesViewHost.ViewsLabelVisible = true;
     
    263272      //
    264273      this.problemInstancesTabPage.Controls.Add(this.problemInstancesView);
     274      this.problemInstancesTabPage.Controls.Add(this.instancesDropPanel);
     275      this.problemInstancesTabPage.Controls.Add(this.refreshMapButton);
    265276      this.problemInstancesTabPage.Location = new System.Drawing.Point(4, 22);
    266277      this.problemInstancesTabPage.Name = "problemInstancesTabPage";
     
    273284      // problemInstancesView
    274285      //
    275       this.problemInstancesView.BackColor = System.Drawing.SystemColors.Window;
    276       this.problemInstancesView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    277       this.problemInstancesView.Caption = "Bubble Chart";
     286      this.problemInstancesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     287            | System.Windows.Forms.AnchorStyles.Left)
     288            | System.Windows.Forms.AnchorStyles.Right)));
     289      this.problemInstancesView.Caption = "View";
    278290      this.problemInstancesView.Content = null;
    279       this.problemInstancesView.Dock = System.Windows.Forms.DockStyle.Fill;
    280       this.problemInstancesView.Location = new System.Drawing.Point(3, 3);
     291      this.problemInstancesView.Enabled = false;
     292      this.problemInstancesView.Location = new System.Drawing.Point(3, 34);
    281293      this.problemInstancesView.Name = "problemInstancesView";
    282294      this.problemInstancesView.ReadOnly = false;
    283       this.problemInstancesView.Size = new System.Drawing.Size(532, 329);
    284       this.problemInstancesView.TabIndex = 0;
     295      this.problemInstancesView.Size = new System.Drawing.Size(532, 298);
     296      this.problemInstancesView.TabIndex = 3;
     297      this.problemInstancesView.ViewsLabelVisible = true;
     298      this.problemInstancesView.ViewType = null;
     299      //
     300      // instancesDropPanel
     301      //
     302      this.instancesDropPanel.AllowDrop = true;
     303      this.instancesDropPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     304            | System.Windows.Forms.AnchorStyles.Right)));
     305      this.instancesDropPanel.BackColor = System.Drawing.Color.LightYellow;
     306      this.instancesDropPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     307      this.instancesDropPanel.Controls.Add(this.dragFLAHereLabel);
     308      this.instancesDropPanel.Location = new System.Drawing.Point(35, 7);
     309      this.instancesDropPanel.Name = "instancesDropPanel";
     310      this.instancesDropPanel.Size = new System.Drawing.Size(500, 21);
     311      this.instancesDropPanel.TabIndex = 2;
     312      this.instancesDropPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.instancesDropPanel_DragDrop);
     313      this.instancesDropPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.instancesDropPanel_DragEnter);
     314      this.instancesDropPanel.DragOver += new System.Windows.Forms.DragEventHandler(this.instancesDropPanel_DragOver);
     315      //
     316      // dragFLAHereLabel
     317      //
     318      this.dragFLAHereLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
     319      this.dragFLAHereLabel.AutoSize = true;
     320      this.dragFLAHereLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
     321      this.dragFLAHereLabel.Location = new System.Drawing.Point(155, 3);
     322      this.dragFLAHereLabel.Name = "dragFLAHereLabel";
     323      this.dragFLAHereLabel.Size = new System.Drawing.Size(175, 13);
     324      this.dragFLAHereLabel.TabIndex = 0;
     325      this.dragFLAHereLabel.Text = "Drag and drop runs with FLA here...";
     326      //
     327      // refreshMapButton
     328      //
     329      this.refreshMapButton.Location = new System.Drawing.Point(3, 6);
     330      this.refreshMapButton.Name = "refreshMapButton";
     331      this.refreshMapButton.Size = new System.Drawing.Size(26, 23);
     332      this.refreshMapButton.TabIndex = 1;
     333      this.refreshMapButton.Text = "Refresh";
     334      this.refreshMapButton.UseVisualStyleBackColor = true;
     335      this.refreshMapButton.Click += new System.EventHandler(this.refreshMapButton_Click);
    285336      //
    286337      // openFileDialog
     
    290341      this.openFileDialog.Filter = "HeuristicLab Files|*.hl|All Files|*.*";
    291342      this.openFileDialog.Title = "Open Optimizer";
     343      //
     344      // okbDownloadButton
     345      //
     346      this.okbDownloadButton.Location = new System.Drawing.Point(6, 6);
     347      this.okbDownloadButton.Name = "okbDownloadButton";
     348      this.okbDownloadButton.Size = new System.Drawing.Size(146, 23);
     349      this.okbDownloadButton.TabIndex = 1;
     350      this.okbDownloadButton.Text = "Download from OKB";
     351      this.okbDownloadButton.UseVisualStyleBackColor = true;
     352      this.okbDownloadButton.Click += new System.EventHandler(this.okbDownloadButton_Click);
    292353      //
    293354      // ExpertSystemView
     
    313374      this.okbTabPage.ResumeLayout(false);
    314375      this.problemInstancesTabPage.ResumeLayout(false);
     376      this.instancesDropPanel.ResumeLayout(false);
     377      this.instancesDropPanel.PerformLayout();
    315378      this.ResumeLayout(false);
    316379      this.PerformLayout();
     
    337400    private MainForm.WindowsForms.ViewHost algorithmInstancesViewHost;
    338401    private System.Windows.Forms.TabPage problemInstancesTabPage;
    339     private Optimization.Views.RunCollectionBubbleChartView problemInstancesView;
     402    private System.Windows.Forms.Panel instancesDropPanel;
     403    private System.Windows.Forms.Button refreshMapButton;
     404    private System.Windows.Forms.Label dragFLAHereLabel;
     405    private MainForm.WindowsForms.ViewHost problemInstancesView;
     406    private System.Windows.Forms.Button okbDownloadButton;
    340407  }
    341408}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs

    r12860 r13475  
    2121
    2222using System;
     23using System.Collections;
    2324using System.ComponentModel;
     25using System.IO;
     26using System.Linq;
    2427using System.Windows.Forms;
     28using HeuristicLab.Clients.OKB.Administration;
     29using HeuristicLab.Clients.OKB.Query;
    2530using HeuristicLab.Common;
     31using HeuristicLab.Common.Resources;
     32using HeuristicLab.Core;
    2633using HeuristicLab.Core.Views;
    2734using HeuristicLab.MainForm;
    2835using HeuristicLab.Optimization;
     36using HeuristicLab.Persistence.Default.Xml;
    2937using HeuristicLab.PluginInfrastructure;
    3038
     
    4351    public ExpertSystemView() {
    4452      InitializeComponent();
     53      refreshMapButton.Text = string.Empty;
     54      refreshMapButton.Image = VSImageLibrary.Refresh;
    4555    }
    4656
     
    8393          runsView.Content = null;
    8494          algorithmInstancesViewHost.Content = null;
     95          problemInstancesView.Content = null;
    8596        } else {
    8697          maxEvaluationsTextBox.Text = Content.MaximumEvaluations.ToString();
     
    8899          runsView.Content = Content.Runs;
    89100          algorithmInstancesViewHost.Content = Content.AlgorithmInstances;
     101          problemInstancesView.Content = Content.ProblemInstances;
    90102        }
    91103      } finally { SuppressEvents = false; }
     
    103115      runsView.Enabled = Content != null;
    104116      algorithmInstancesViewHost.Enabled = Content != null;
     117      refreshMapButton.Enabled = Content != null;
     118      okbDownloadButton.Enabled = Content != null && Content.Problem != null && !ReadOnly && !Locked;
    105119    }
    106120
     
    131145      try {
    132146        switch (e.PropertyName) {
     147          case "AlgorithmInstances": algorithmInstancesViewHost.Content = Content.AlgorithmInstances; break;
    133148          case "MaximumEvaluations": maxEvaluationsTextBox.Text = Content.MaximumEvaluations.ToString(); break;
    134149          case "Problem": problemViewHost.Content = Content.Problem; break;
     150          case "ProblemInstances": problemInstancesView.Content = Content.ProblemInstances; break;
    135151        }
    136152      } finally { SuppressEvents = false; }
     153      SetEnabledStateOfControls();
    137154    }
    138155
     
    233250    }
    234251    #endregion
     252
     253    private bool validDragOperation;
     254    private void instancesDropPanel_DragEnter(object sender, DragEventArgs e) {
     255      validDragOperation = false;
     256      if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IRun)) {
     257        validDragOperation = true;
     258      } else if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable)) {
     259        validDragOperation = true;
     260        var items = (IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     261        foreach (object item in items)
     262          validDragOperation = validDragOperation && (item is IRun);
     263      }
     264    }
     265    private void instancesDropPanel_DragOver(object sender, DragEventArgs e) {
     266      e.Effect = DragDropEffects.None;
     267      if (!validDragOperation) return;
     268      if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
     269      else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
     270      else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
     271      else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
     272      else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
     273    }
     274    private void instancesDropPanel_DragDrop(object sender, DragEventArgs e) {
     275      if (e.Effect == DragDropEffects.None) return;
     276      if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IRun) {
     277        var item = (IRun)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     278        Content.ProblemInstances.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (IRun)item.Clone() : item);
     279      } else if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable) {
     280        var items = ((IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat)).Cast<IRun>();
     281        if (e.Effect.HasFlag(DragDropEffects.Copy)) {
     282          var cloner = new Cloner();
     283          items = items.Select(x => cloner.Clone(x));
     284        }
     285        Content.ProblemInstances.AddRange(items);
     286      }
     287    }
    235288    #endregion
     289
     290    private void refreshMapButton_Click(object sender, EventArgs e) {
     291      Content.UpdateInstanceMap();
     292    }
     293
     294    private void okbDownloadButton_Click(object sender, EventArgs e) {
     295      var queryClient = QueryClient.Instance;
     296      queryClient.Refresh();
     297
     298      var problemTypeFilter = (StringComparisonAvailableValuesFilter)queryClient.Filters.Single(x => x.Label == "Problem Data Type Name");
     299      problemTypeFilter.Value = Content.Problem.GetType().Name;
     300
     301      var runIds = queryClient.GetRunIds(problemTypeFilter).ToList();
     302      var count = queryClient.GetNumberOfRuns(problemTypeFilter);
     303      if (count > 0) {
     304        var list = new ItemList<IAlgorithm>();
     305        var adminClient = AdministrationClient.Instance;
     306        adminClient.Refresh();
     307        var runs = queryClient.GetRuns(runIds, true).ToList();
     308        foreach (var rGroup in runs.GroupBy(x => x.Algorithm.Id)) {
     309          var data = AdministrationClient.GetAlgorithmData(rGroup.Key);
     310          if (data != null) {
     311            using (var stream = new MemoryStream(data)) {
     312              try {
     313                var alg = (IAlgorithm)XmlParser.Deserialize<IContent>(stream);
     314                alg.Runs.AddRange(rGroup.Select(x => queryClient.ConvertToOptimizationRun(x)));
     315                list.Add(alg);
     316              } catch (Exception) { }
     317              stream.Close();
     318            }
     319          }
     320        }
     321        Content.AlgorithmInstances = list;
     322      }
     323    }
    236324  }
    237325}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/HeuristicLab.OptimizationExpertSystem.Views-3.3.csproj

    r12957 r13475  
    7878      <Private>False</Private>
    7979    </Reference>
     80    <Reference Include="HeuristicLab.Clients.OKB-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     81      <SpecificVersion>False</SpecificVersion>
     82      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Clients.OKB-3.3.dll</HintPath>
     83      <Private>False</Private>
     84    </Reference>
    8085    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    8186      <SpecificVersion>False</SpecificVersion>
     
    121126      <SpecificVersion>False</SpecificVersion>
    122127      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath>
     128      <Private>False</Private>
     129    </Reference>
     130    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     131      <SpecificVersion>False</SpecificVersion>
     132      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
    123133      <Private>False</Private>
    124134    </Reference>
     
    136146    <Reference Include="System.Core" />
    137147    <Reference Include="System.Drawing" />
     148    <Reference Include="System.Runtime.Serialization" />
    138149    <Reference Include="System.Windows.Forms" />
    139150    <Reference Include="System.Xml.Linq" />
     
    185196    </ProjectReference>
    186197  </ItemGroup>
     198  <ItemGroup>
     199    <EmbeddedResource Include="ExpertSystemView.resx">
     200      <DependentUpon>ExpertSystemView.cs</DependentUpon>
     201    </EmbeddedResource>
     202  </ItemGroup>
    187203  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    188204  <PropertyGroup>
Note: See TracChangeset for help on using the changeset viewer.