Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13593


Ignore:
Timestamp:
02/07/16 23:12:22 (9 years ago)
Author:
abeham
Message:

#2457:

  • Changed ICharacteristicCalculator interface
  • Updated OKB Problem view
Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.Designer.cs

    r13550 r13593  
    5353      this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
    5454      this.characteristicsTabPage = new System.Windows.Forms.TabPage();
    55       this.characteristicSplitContainer = new System.Windows.Forms.SplitContainer();
    56       this.calculatorListView = new System.Windows.Forms.ListView();
    57       this.characteristicColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
    58       this.calculateButton = new System.Windows.Forms.Button();
    59       this.characteristicsMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
    6055      this.uploadCharacteristicsButton = new System.Windows.Forms.Button();
    6156      this.downloadCharacteristicsButton = new System.Windows.Forms.Button();
     57      this.flaAnalysisTabPage = new System.Windows.Forms.TabPage();
     58      this.calculatorListView = new System.Windows.Forms.ListView();
     59      this.calculateButton = new System.Windows.Forms.Button();
     60      this.calculatorSplitContainer = new System.Windows.Forms.SplitContainer();
     61      this.calculatorViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     62      this.characteristicsMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
    6263      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6364      this.tabControl.SuspendLayout();
    6465      this.parametersTabPage.SuspendLayout();
    6566      this.characteristicsTabPage.SuspendLayout();
    66       ((System.ComponentModel.ISupportInitialize)(this.characteristicSplitContainer)).BeginInit();
    67       this.characteristicSplitContainer.Panel1.SuspendLayout();
    68       this.characteristicSplitContainer.Panel2.SuspendLayout();
    69       this.characteristicSplitContainer.SuspendLayout();
     67      this.flaAnalysisTabPage.SuspendLayout();
     68      ((System.ComponentModel.ISupportInitialize)(this.calculatorSplitContainer)).BeginInit();
     69      this.calculatorSplitContainer.Panel1.SuspendLayout();
     70      this.calculatorSplitContainer.Panel2.SuspendLayout();
     71      this.calculatorSplitContainer.SuspendLayout();
    7072      this.SuspendLayout();
    7173      //
     
    138140      this.tabControl.Controls.Add(this.parametersTabPage);
    139141      this.tabControl.Controls.Add(this.characteristicsTabPage);
     142      this.tabControl.Controls.Add(this.flaAnalysisTabPage);
    140143      this.tabControl.Location = new System.Drawing.Point(6, 53);
    141144      this.tabControl.Name = "tabControl";
     
    170173      // characteristicsTabPage
    171174      //
    172       this.characteristicsTabPage.Controls.Add(this.characteristicSplitContainer);
     175      this.characteristicsTabPage.Controls.Add(this.characteristicsMatrixView);
    173176      this.characteristicsTabPage.Controls.Add(this.uploadCharacteristicsButton);
    174177      this.characteristicsTabPage.Controls.Add(this.downloadCharacteristicsButton);
     
    181184      this.characteristicsTabPage.UseVisualStyleBackColor = true;
    182185      //
    183       // characteristicSplitContainer
    184       //
    185       this.characteristicSplitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    186             | System.Windows.Forms.AnchorStyles.Left)
    187             | System.Windows.Forms.AnchorStyles.Right)));
    188       this.characteristicSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
    189       this.characteristicSplitContainer.Location = new System.Drawing.Point(0, 35);
    190       this.characteristicSplitContainer.Name = "characteristicSplitContainer";
    191       //
    192       // characteristicSplitContainer.Panel1
    193       //
    194       this.characteristicSplitContainer.Panel1.Controls.Add(this.calculatorListView);
    195       this.characteristicSplitContainer.Panel1.Controls.Add(this.calculateButton);
    196       //
    197       // characteristicSplitContainer.Panel2
    198       //
    199       this.characteristicSplitContainer.Panel2.Controls.Add(this.characteristicsMatrixView);
    200       this.characteristicSplitContainer.Size = new System.Drawing.Size(692, 279);
    201       this.characteristicSplitContainer.SplitterDistance = 221;
    202       this.characteristicSplitContainer.TabIndex = 2;
    203       //
    204       // calculatorListView
    205       //
    206       this.calculatorListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    207             | System.Windows.Forms.AnchorStyles.Left)
    208             | System.Windows.Forms.AnchorStyles.Right)));
    209       this.calculatorListView.CheckBoxes = true;
    210       this.calculatorListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
    211             this.characteristicColumnHeader});
    212       this.calculatorListView.Location = new System.Drawing.Point(3, 0);
    213       this.calculatorListView.Name = "calculatorListView";
    214       this.calculatorListView.Size = new System.Drawing.Size(215, 244);
    215       this.calculatorListView.TabIndex = 0;
    216       this.calculatorListView.UseCompatibleStateImageBehavior = false;
    217       this.calculatorListView.View = System.Windows.Forms.View.Details;
    218       this.calculatorListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.calculatorListView_ItemChecked);
    219       //
    220       // characteristicColumnHeader
    221       //
    222       this.characteristicColumnHeader.Text = "Characteristic";
    223       this.characteristicColumnHeader.Width = 211;
    224       //
    225       // calculateButton
    226       //
    227       this.calculateButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
    228             | System.Windows.Forms.AnchorStyles.Right)));
    229       this.calculateButton.Location = new System.Drawing.Point(6, 250);
    230       this.calculateButton.Name = "calculateButton";
    231       this.calculateButton.Size = new System.Drawing.Size(212, 23);
    232       this.calculateButton.TabIndex = 0;
    233       this.calculateButton.Text = "Calculate";
    234       this.calculateButton.UseVisualStyleBackColor = true;
    235       this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click);
    236       //
    237       // characteristicsMatrixView
    238       //
    239       this.characteristicsMatrixView.Caption = "StringConvertibleMatrix View";
    240       this.characteristicsMatrixView.Content = null;
    241       this.characteristicsMatrixView.Dock = System.Windows.Forms.DockStyle.Fill;
    242       this.characteristicsMatrixView.Location = new System.Drawing.Point(0, 0);
    243       this.characteristicsMatrixView.Name = "characteristicsMatrixView";
    244       this.characteristicsMatrixView.ReadOnly = false;
    245       this.characteristicsMatrixView.ShowRowsAndColumnsTextBox = false;
    246       this.characteristicsMatrixView.ShowStatisticalInformation = false;
    247       this.characteristicsMatrixView.Size = new System.Drawing.Size(467, 279);
    248       this.characteristicsMatrixView.TabIndex = 1;
    249       //
    250186      // uploadCharacteristicsButton
    251187      //
     
    267203      this.downloadCharacteristicsButton.UseVisualStyleBackColor = true;
    268204      this.downloadCharacteristicsButton.Click += new System.EventHandler(this.downloadCharacteristicsButton_Click);
     205      //
     206      // flaAnalysisTabPage
     207      //
     208      this.flaAnalysisTabPage.Controls.Add(this.calculatorSplitContainer);
     209      this.flaAnalysisTabPage.Location = new System.Drawing.Point(4, 22);
     210      this.flaAnalysisTabPage.Name = "flaAnalysisTabPage";
     211      this.flaAnalysisTabPage.Padding = new System.Windows.Forms.Padding(3);
     212      this.flaAnalysisTabPage.Size = new System.Drawing.Size(692, 314);
     213      this.flaAnalysisTabPage.TabIndex = 2;
     214      this.flaAnalysisTabPage.Text = "FLA Analysis";
     215      this.flaAnalysisTabPage.UseVisualStyleBackColor = true;
     216      //
     217      // calculatorListView
     218      //
     219      this.calculatorListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     220            | System.Windows.Forms.AnchorStyles.Left)
     221            | System.Windows.Forms.AnchorStyles.Right)));
     222      this.calculatorListView.HideSelection = false;
     223      this.calculatorListView.Location = new System.Drawing.Point(0, 0);
     224      this.calculatorListView.Name = "calculatorListView";
     225      this.calculatorListView.Size = new System.Drawing.Size(225, 276);
     226      this.calculatorListView.TabIndex = 1;
     227      this.calculatorListView.UseCompatibleStateImageBehavior = false;
     228      this.calculatorListView.View = System.Windows.Forms.View.List;
     229      this.calculatorListView.SelectedIndexChanged += new System.EventHandler(this.calculatorListView_SelectedIndexChanged);
     230      //
     231      // calculateButton
     232      //
     233      this.calculateButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
     234            | System.Windows.Forms.AnchorStyles.Right)));
     235      this.calculateButton.Location = new System.Drawing.Point(0, 282);
     236      this.calculateButton.Name = "calculateButton";
     237      this.calculateButton.Size = new System.Drawing.Size(225, 23);
     238      this.calculateButton.TabIndex = 2;
     239      this.calculateButton.Text = "Calculate";
     240      this.calculateButton.UseVisualStyleBackColor = true;
     241      this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click);
     242      //
     243      // calculatorSplitContainer
     244      //
     245      this.calculatorSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
     246      this.calculatorSplitContainer.Location = new System.Drawing.Point(3, 3);
     247      this.calculatorSplitContainer.Name = "calculatorSplitContainer";
     248      //
     249      // calculatorSplitContainer.Panel1
     250      //
     251      this.calculatorSplitContainer.Panel1.Controls.Add(this.calculatorListView);
     252      this.calculatorSplitContainer.Panel1.Controls.Add(this.calculateButton);
     253      //
     254      // calculatorSplitContainer.Panel2
     255      //
     256      this.calculatorSplitContainer.Panel2.Controls.Add(this.calculatorViewHost);
     257      this.calculatorSplitContainer.Size = new System.Drawing.Size(686, 308);
     258      this.calculatorSplitContainer.SplitterDistance = 228;
     259      this.calculatorSplitContainer.TabIndex = 3;
     260      //
     261      // calculatorViewHost
     262      //
     263      this.calculatorViewHost.Caption = "View";
     264      this.calculatorViewHost.Content = null;
     265      this.calculatorViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
     266      this.calculatorViewHost.Enabled = false;
     267      this.calculatorViewHost.Location = new System.Drawing.Point(0, 0);
     268      this.calculatorViewHost.Name = "calculatorViewHost";
     269      this.calculatorViewHost.ReadOnly = false;
     270      this.calculatorViewHost.Size = new System.Drawing.Size(454, 308);
     271      this.calculatorViewHost.TabIndex = 0;
     272      this.calculatorViewHost.ViewsLabelVisible = true;
     273      this.calculatorViewHost.ViewType = null;
     274      //
     275      // characteristicsMatrixView
     276      //
     277      this.characteristicsMatrixView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     278            | System.Windows.Forms.AnchorStyles.Left)
     279            | System.Windows.Forms.AnchorStyles.Right)));
     280      this.characteristicsMatrixView.Caption = "StringConvertibleMatrix View";
     281      this.characteristicsMatrixView.Content = null;
     282      this.characteristicsMatrixView.Location = new System.Drawing.Point(3, 35);
     283      this.characteristicsMatrixView.Name = "characteristicsMatrixView";
     284      this.characteristicsMatrixView.ReadOnly = false;
     285      this.characteristicsMatrixView.ShowRowsAndColumnsTextBox = false;
     286      this.characteristicsMatrixView.ShowStatisticalInformation = false;
     287      this.characteristicsMatrixView.Size = new System.Drawing.Size(686, 276);
     288      this.characteristicsMatrixView.TabIndex = 2;
    269289      //
    270290      // OKBProblemView
     
    291311      this.parametersTabPage.ResumeLayout(false);
    292312      this.characteristicsTabPage.ResumeLayout(false);
    293       this.characteristicSplitContainer.Panel1.ResumeLayout(false);
    294       this.characteristicSplitContainer.Panel2.ResumeLayout(false);
    295       ((System.ComponentModel.ISupportInitialize)(this.characteristicSplitContainer)).EndInit();
    296       this.characteristicSplitContainer.ResumeLayout(false);
     313      this.flaAnalysisTabPage.ResumeLayout(false);
     314      this.calculatorSplitContainer.Panel1.ResumeLayout(false);
     315      this.calculatorSplitContainer.Panel2.ResumeLayout(false);
     316      ((System.ComponentModel.ISupportInitialize)(this.calculatorSplitContainer)).EndInit();
     317      this.calculatorSplitContainer.ResumeLayout(false);
    297318      this.ResumeLayout(false);
    298319      this.PerformLayout();
     
    310331    private System.Windows.Forms.TabPage characteristicsTabPage;
    311332    private Core.Views.ParameterCollectionView parameterCollectionView;
    312     private Data.Views.StringConvertibleMatrixView characteristicsMatrixView;
    313333    private System.Windows.Forms.Button uploadCharacteristicsButton;
    314334    private System.Windows.Forms.Button downloadCharacteristicsButton;
    315     private System.Windows.Forms.SplitContainer characteristicSplitContainer;
     335    private System.Windows.Forms.TabPage flaAnalysisTabPage;
    316336    private System.Windows.Forms.ListView calculatorListView;
    317     private System.Windows.Forms.ColumnHeader characteristicColumnHeader;
    318337    private System.Windows.Forms.Button calculateButton;
     338    private System.Windows.Forms.SplitContainer calculatorSplitContainer;
     339    private MainForm.WindowsForms.ViewHost calculatorViewHost;
     340    private Data.Views.StringConvertibleMatrixView characteristicsMatrixView;
    319341
    320342
  • trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.cs

    r13552 r13593  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Windows.Forms;
    2622using HeuristicLab.Common.Resources;
    2723using HeuristicLab.Core.Views;
     
    3026using HeuristicLab.Optimization;
    3127using HeuristicLab.PluginInfrastructure;
     28using System;
     29using System.Collections.Generic;
     30using System.Linq;
     31using System.Windows.Forms;
    3232
    3333namespace HeuristicLab.Clients.OKB.RunCreation {
     
    9191      uploadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly
    9292        && characteristicsMatrixView.Content != null && characteristicsMatrixView.Content.Rows > 0;
    93       calculateButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly && calculatorListView.CheckedItems.Count > 0;
     93      calculateButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly;
    9494    }
    9595
     
    105105      if (Content == null || Content.ProblemId == -1) return;
    106106      var problem = Content.CloneProblem();
    107       var calculators = ApplicationManager.Manager.GetInstances<ICharacteristicCalculator>().Where(x => x.CanCalculate(problem)).ToList();
     107      var calculators = ApplicationManager.Manager.GetInstances<ICharacteristicCalculator>().ToList();
    108108      try {
    109109        calculatorListView.BeginUpdate();
    110110        foreach (var calc in calculators) {
     111          calc.Problem = problem;
    111112          var group = calculatorListView.Groups.Add(calc.Name, calc.Name);
    112113          group.Tag = calc;
    113           foreach (var c in calc.Characteristics) {
    114             var item = calculatorListView.Items.Add(c, c);
    115             item.Group = group;
    116             item.Checked = true;
    117           }
     114
     115          var paramItem = calculatorListView.Items.Add(calc.Name + ".Parameters", "Parameters");
     116          paramItem.Group = group;
     117          paramItem.Tag = "param";
     118
     119          var charactItem = calculatorListView.Items.Add(calc.Name + ".Characteristics", "Characteristics");
     120          charactItem.Group = group;
     121          charactItem.Tag = "chara";
    118122        }
    119123      } finally { calculatorListView.EndUpdate(); }
     
    189193      } catch (Exception ex) { ErrorHandling.ShowErrorDialog(ex); }
    190194    }
     195    private void calculatorListView_SelectedIndexChanged(object sender, EventArgs e) {
     196      if (InvokeRequired) {
     197        Invoke((Action<object, EventArgs>)calculatorListView_SelectedIndexChanged, sender, e);
     198        return;
     199      }
     200      if (calculatorListView.SelectedIndices.Count == 0) calculatorViewHost.Content = null;
     201      else {
     202        var item = calculatorListView.SelectedItems[0];
     203        if ((string)item.Tag == "param") {
     204          calculatorViewHost.Content = ((ICharacteristicCalculator)item.Group.Tag);
     205        } else if ((string)item.Tag == "chara") {
     206          calculatorViewHost.Content = ((ICharacteristicCalculator)item.Group.Tag).Characteristics;
     207        }
     208      }
     209    }
    191210    private void calculateButton_Click(object sender, EventArgs e) {
    192       var characteristics = calculatorListView.CheckedItems.OfType<ListViewItem>().GroupBy(x => x.Group).ToList();
    193       if (characteristics.Count == 0) return;
    194       var problem = Content.CloneProblem();
     211      var calculators = calculatorListView.Groups.OfType<ListViewGroup>()
     212                                                     .Select(x => (ICharacteristicCalculator)x.Tag)
     213                                                     .Where(x => x.Characteristics.CheckedItems.Any()
     214                                                              && x.CanCalculate()).ToList();
     215      if (calculators.Count == 0) return;
     216
    195217      var results = new Dictionary<string, Value>();
    196       foreach (var c in characteristics) {
    197         var calc = (ICharacteristicCalculator)c.Key.Tag;
    198         foreach (var result in calc.Calculate(problem, c.Select(x => x.Text).ToArray()))
    199           results[result.Key] = RunCreationClient.Instance.ConvertToValue(result.Value, result.Key);
     218      foreach (var calc in calculators) {
     219        foreach (var result in calc.Calculate())
     220          results[result.Name] = RunCreationClient.Instance.ConvertToValue(result.Value, result.Name);
    200221      }
    201222      var matrix = (characteristicsMatrixView.Content as StringMatrix) ?? (new StringMatrix(results.Count, 3));
     
    231252        }
    232253      }
    233       SetEnabledStateOfControls();
    234     }
    235     private void calculatorListView_ItemChecked(object sender, ItemCheckedEventArgs e) {
     254      characteristicsMatrixView.Content = matrix;
    236255      SetEnabledStateOfControls();
    237256    }
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ICharacteristicCalculator.cs

    r13552 r13593  
    2222using System.Collections.Generic;
    2323using HeuristicLab.Core;
     24using HeuristicLab.Data;
    2425
    2526namespace HeuristicLab.Optimization {
    26   public interface ICharacteristicCalculator : INamedItem {
    27     IEnumerable<string> Characteristics { get; }
    28     bool CanCalculate(IProblem problem);
    29     IEnumerable<KeyValuePair<string, IItem>> Calculate(IProblem problem, IEnumerable<string> characteristics = null);
     27  public interface ICharacteristicCalculator : IParameterizedNamedItem {
     28    IProblem Problem { get; set; }
     29    ReadOnlyCheckedItemList<StringValue> Characteristics { get; }
     30
     31    bool CanCalculate();
     32    IEnumerable<IResult> Calculate();
    3033  }
    3134}
Note: See TracChangeset for help on using the changeset viewer.