Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13551


Ignore:
Timestamp:
01/19/16 08:49:23 (8 years ago)
Author:
abeham
Message:

#2457: Added characteristic calculator for qap and adapted expert system view

Location:
branches/PerformanceComparison
Files:
5 added
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r13475 r13551  
    198198    <Compile Include="BasicProblems\Operators\SingleObjectiveMoveMaker.cs" />
    199199    <Compile Include="BasicProblems\SingleObjectiveBasicProblem.cs" />
     200    <Compile Include="Interfaces\ICharacteristicCalculator.cs" />
    200201    <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" />
    201202    <Compile Include="Interfaces\IMultiObjectiveOperator.cs" />
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Interfaces/ICharacteristicCalculator.cs

    r13540 r13551  
    2727    IEnumerable<string> Characteristics { get; }
    2828    bool CanCalculate(IProblem problem);
    29     IEnumerable<KeyValuePair<string, double>> Calculate(IProblem problem, IEnumerable<string> characteristics = null);
     29    IEnumerable<KeyValuePair<string, IItem>> Calculate(IProblem problem, IEnumerable<string> characteristics = null);
    3030  }
    3131}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.Designer.cs

    r13485 r13551  
    3434    /// </summary>
    3535    private void InitializeComponent() {
    36       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExpertSystemView));
    3736      this.evaluationsLimitabel = new System.Windows.Forms.Label();
    3837      this.maxEvaluationsTextBox = new System.Windows.Forms.TextBox();
     
    4039      this.problemTabPage = new System.Windows.Forms.TabPage();
    4140      this.problemViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    42       this.openProblemButton = new System.Windows.Forms.Button();
    43       this.newProblemButton = new System.Windows.Forms.Button();
    4441      this.algorithmTabPage = new System.Windows.Forms.TabPage();
    4542      this.algorithmViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     
    4744      this.suggestedInstancesComboBox = new System.Windows.Forms.ComboBox();
    4845      this.runsTabPage = new System.Windows.Forms.TabPage();
     46      this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
    4947      this.okbTabPage = new System.Windows.Forms.TabPage();
    50       this.algorithmInstancesViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     48      this.kbViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5149      this.problemInstancesTabPage = new System.Windows.Forms.TabPage();
    5250      this.problemInstancesView = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     
    5452      this.dragFLAHereLabel = new System.Windows.Forms.Label();
    5553      this.refreshMapButton = new System.Windows.Forms.Button();
     54      this.progressPanel = new System.Windows.Forms.Panel();
     55      this.okbDownloadButton = new System.Windows.Forms.Button();
    5656      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    57       this.okbDownloadButton = new System.Windows.Forms.Button();
    58       this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
    59       this.progressPanel = new System.Windows.Forms.Panel();
     57      this.algorithmStartButton = new System.Windows.Forms.Button();
    6058      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6159      this.tabControl.SuspendLayout();
     
    9088      // maxEvaluationsTextBox
    9189      //
    92       this.maxEvaluationsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     90      this.maxEvaluationsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    9391            | System.Windows.Forms.AnchorStyles.Right)));
    9492      this.maxEvaluationsTextBox.Location = new System.Drawing.Point(75, 26);
     
    10199      //
    102100      this.tabControl.AllowDrop = true;
    103       this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    104             | System.Windows.Forms.AnchorStyles.Left) 
     101      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     102            | System.Windows.Forms.AnchorStyles.Left)
    105103            | System.Windows.Forms.AnchorStyles.Right)));
    106104      this.tabControl.Controls.Add(this.problemTabPage);
     
    109107      this.tabControl.Controls.Add(this.okbTabPage);
    110108      this.tabControl.Controls.Add(this.problemInstancesTabPage);
    111       this.tabControl.Location = new System.Drawing.Point(0, 52);
     109      this.tabControl.Location = new System.Drawing.Point(0, 81);
    112110      this.tabControl.Name = "tabControl";
    113111      this.tabControl.SelectedIndex = 0;
    114       this.tabControl.Size = new System.Drawing.Size(546, 361);
     112      this.tabControl.Size = new System.Drawing.Size(546, 332);
    115113      this.tabControl.TabIndex = 17;
    116114      //
     
    119117      this.problemTabPage.AllowDrop = true;
    120118      this.problemTabPage.Controls.Add(this.problemViewHost);
    121       this.problemTabPage.Controls.Add(this.openProblemButton);
    122       this.problemTabPage.Controls.Add(this.newProblemButton);
    123119      this.problemTabPage.Location = new System.Drawing.Point(4, 22);
    124120      this.problemTabPage.Name = "problemTabPage";
    125121      this.problemTabPage.Padding = new System.Windows.Forms.Padding(3);
    126       this.problemTabPage.Size = new System.Drawing.Size(538, 335);
     122      this.problemTabPage.Size = new System.Drawing.Size(538, 306);
    127123      this.problemTabPage.TabIndex = 1;
    128124      this.problemTabPage.Text = "Problem";
    129125      this.problemTabPage.UseVisualStyleBackColor = true;
    130       this.problemTabPage.DragDrop += new System.Windows.Forms.DragEventHandler(this.problemTabPage_DragDrop);
    131       this.problemTabPage.DragEnter += new System.Windows.Forms.DragEventHandler(this.problemTabPage_DragEnterOver);
    132       this.problemTabPage.DragOver += new System.Windows.Forms.DragEventHandler(this.problemTabPage_DragEnterOver);
    133126      //
    134127      // problemViewHost
    135128      //
    136       this.problemViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    137             | System.Windows.Forms.AnchorStyles.Left)
    138             | System.Windows.Forms.AnchorStyles.Right)));
    139129      this.problemViewHost.Caption = "View";
    140130      this.problemViewHost.Content = null;
     131      this.problemViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    141132      this.problemViewHost.Enabled = false;
    142       this.problemViewHost.Location = new System.Drawing.Point(6, 36);
     133      this.problemViewHost.Location = new System.Drawing.Point(3, 3);
    143134      this.problemViewHost.Name = "problemViewHost";
    144135      this.problemViewHost.ReadOnly = false;
    145       this.problemViewHost.Size = new System.Drawing.Size(526, 293);
     136      this.problemViewHost.Size = new System.Drawing.Size(532, 300);
    146137      this.problemViewHost.TabIndex = 2;
    147       this.problemViewHost.ViewsLabelVisible = true;
     138      this.problemViewHost.ViewsLabelVisible = false;
    148139      this.problemViewHost.ViewType = null;
    149140      //
    150       // openProblemButton
    151       //
    152       this.openProblemButton.Image = ((System.Drawing.Image)(resources.GetObject("openProblemButton.Image")));
    153       this.openProblemButton.Location = new System.Drawing.Point(36, 6);
    154       this.openProblemButton.Name = "openProblemButton";
    155       this.openProblemButton.Size = new System.Drawing.Size(24, 24);
    156       this.openProblemButton.TabIndex = 1;
    157       this.toolTip.SetToolTip(this.openProblemButton, "Open Problem");
    158       this.openProblemButton.UseVisualStyleBackColor = true;
    159       this.openProblemButton.Click += new System.EventHandler(this.openProblemButton_Click);
    160       //
    161       // newProblemButton
    162       //
    163       this.newProblemButton.Image = ((System.Drawing.Image)(resources.GetObject("newProblemButton.Image")));
    164       this.newProblemButton.Location = new System.Drawing.Point(6, 6);
    165       this.newProblemButton.Name = "newProblemButton";
    166       this.newProblemButton.Size = new System.Drawing.Size(24, 24);
    167       this.newProblemButton.TabIndex = 0;
    168       this.toolTip.SetToolTip(this.newProblemButton, "New Problem");
    169       this.newProblemButton.UseVisualStyleBackColor = true;
    170       this.newProblemButton.Click += new System.EventHandler(this.newProblemButton_Click);
    171       //
    172141      // algorithmTabPage
    173142      //
     143      this.algorithmTabPage.Controls.Add(this.algorithmStartButton);
    174144      this.algorithmTabPage.Controls.Add(this.algorithmViewHost);
    175145      this.algorithmTabPage.Controls.Add(this.algorithmSuggestionLabel);
     
    178148      this.algorithmTabPage.Name = "algorithmTabPage";
    179149      this.algorithmTabPage.Padding = new System.Windows.Forms.Padding(3);
    180       this.algorithmTabPage.Size = new System.Drawing.Size(538, 335);
     150      this.algorithmTabPage.Size = new System.Drawing.Size(538, 306);
    181151      this.algorithmTabPage.TabIndex = 4;
    182152      this.algorithmTabPage.Text = "Algorithm";
     
    185155      // algorithmViewHost
    186156      //
    187       this.algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    188             | System.Windows.Forms.AnchorStyles.Left) 
     157      this.algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     158            | System.Windows.Forms.AnchorStyles.Left)
    189159            | System.Windows.Forms.AnchorStyles.Right)));
    190160      this.algorithmViewHost.Caption = "View";
     
    194164      this.algorithmViewHost.Name = "algorithmViewHost";
    195165      this.algorithmViewHost.ReadOnly = false;
    196       this.algorithmViewHost.Size = new System.Drawing.Size(526, 293);
     166      this.algorithmViewHost.Size = new System.Drawing.Size(526, 264);
    197167      this.algorithmViewHost.TabIndex = 2;
    198168      this.algorithmViewHost.ViewsLabelVisible = true;
     
    210180      // suggestedInstancesComboBox
    211181      //
    212       this.suggestedInstancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     182      this.suggestedInstancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    213183            | System.Windows.Forms.AnchorStyles.Right)));
    214184      this.suggestedInstancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     
    216186      this.suggestedInstancesComboBox.Location = new System.Drawing.Point(178, 6);
    217187      this.suggestedInstancesComboBox.Name = "suggestedInstancesComboBox";
    218       this.suggestedInstancesComboBox.Size = new System.Drawing.Size(354, 21);
     188      this.suggestedInstancesComboBox.Size = new System.Drawing.Size(322, 21);
    219189      this.suggestedInstancesComboBox.TabIndex = 0;
    220       this.suggestedInstancesComboBox.SelectedIndexChanged += new System.EventHandler(this.suggestedInstancesComboBox_SelectedIndexChanged);
    221190      //
    222191      // runsTabPage
     
    226195      this.runsTabPage.Name = "runsTabPage";
    227196      this.runsTabPage.Padding = new System.Windows.Forms.Padding(3);
    228       this.runsTabPage.Size = new System.Drawing.Size(538, 335);
     197      this.runsTabPage.Size = new System.Drawing.Size(538, 306);
    229198      this.runsTabPage.TabIndex = 3;
    230199      this.runsTabPage.Text = "Runs";
    231200      this.runsTabPage.UseVisualStyleBackColor = true;
    232201      //
     202      // runsView
     203      //
     204      this.runsView.Caption = "RunCollection View";
     205      this.runsView.Content = null;
     206      this.runsView.Dock = System.Windows.Forms.DockStyle.Fill;
     207      this.runsView.Location = new System.Drawing.Point(3, 3);
     208      this.runsView.Name = "runsView";
     209      this.runsView.ReadOnly = false;
     210      this.runsView.Size = new System.Drawing.Size(532, 300);
     211      this.runsView.TabIndex = 1;
     212      //
    233213      // okbTabPage
    234214      //
    235       this.okbTabPage.Controls.Add(this.progressPanel);
    236       this.okbTabPage.Controls.Add(this.okbDownloadButton);
    237       this.okbTabPage.Controls.Add(this.algorithmInstancesViewHost);
     215      this.okbTabPage.Controls.Add(this.kbViewHost);
    238216      this.okbTabPage.Location = new System.Drawing.Point(4, 22);
    239217      this.okbTabPage.Name = "okbTabPage";
    240218      this.okbTabPage.Padding = new System.Windows.Forms.Padding(3);
    241       this.okbTabPage.Size = new System.Drawing.Size(538, 335);
     219      this.okbTabPage.Size = new System.Drawing.Size(538, 306);
    242220      this.okbTabPage.TabIndex = 5;
    243221      this.okbTabPage.Text = "Knowledge Base";
    244222      this.okbTabPage.UseVisualStyleBackColor = true;
    245223      //
    246       // algorithmInstancesViewHost
    247       //
    248       this.algorithmInstancesViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    249             | System.Windows.Forms.AnchorStyles.Left)
    250             | System.Windows.Forms.AnchorStyles.Right)));
    251       this.algorithmInstancesViewHost.Caption = "View";
    252       this.algorithmInstancesViewHost.Content = null;
    253       this.algorithmInstancesViewHost.Enabled = false;
    254       this.algorithmInstancesViewHost.Location = new System.Drawing.Point(3, 35);
    255       this.algorithmInstancesViewHost.Name = "algorithmInstancesViewHost";
    256       this.algorithmInstancesViewHost.ReadOnly = false;
    257       this.algorithmInstancesViewHost.Size = new System.Drawing.Size(532, 297);
    258       this.algorithmInstancesViewHost.TabIndex = 0;
    259       this.algorithmInstancesViewHost.ViewsLabelVisible = true;
    260       this.algorithmInstancesViewHost.ViewType = null;
     224      // kbViewHost
     225      //
     226      this.kbViewHost.Caption = "View";
     227      this.kbViewHost.Content = null;
     228      this.kbViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
     229      this.kbViewHost.Enabled = false;
     230      this.kbViewHost.Location = new System.Drawing.Point(3, 3);
     231      this.kbViewHost.Name = "kbViewHost";
     232      this.kbViewHost.ReadOnly = true;
     233      this.kbViewHost.Size = new System.Drawing.Size(532, 300);
     234      this.kbViewHost.TabIndex = 3;
     235      this.kbViewHost.ViewsLabelVisible = true;
     236      this.kbViewHost.ViewType = null;
    261237      //
    262238      // problemInstancesTabPage
     
    268244      this.problemInstancesTabPage.Name = "problemInstancesTabPage";
    269245      this.problemInstancesTabPage.Padding = new System.Windows.Forms.Padding(3);
    270       this.problemInstancesTabPage.Size = new System.Drawing.Size(538, 335);
     246      this.problemInstancesTabPage.Size = new System.Drawing.Size(538, 306);
    271247      this.problemInstancesTabPage.TabIndex = 6;
    272248      this.problemInstancesTabPage.Text = "Problem Instances";
     
    275251      // problemInstancesView
    276252      //
    277       this.problemInstancesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    278             | System.Windows.Forms.AnchorStyles.Left) 
     253      this.problemInstancesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     254            | System.Windows.Forms.AnchorStyles.Left)
    279255            | System.Windows.Forms.AnchorStyles.Right)));
    280256      this.problemInstancesView.Caption = "View";
     
    284260      this.problemInstancesView.Name = "problemInstancesView";
    285261      this.problemInstancesView.ReadOnly = false;
    286       this.problemInstancesView.Size = new System.Drawing.Size(532, 298);
     262      this.problemInstancesView.Size = new System.Drawing.Size(532, 269);
    287263      this.problemInstancesView.TabIndex = 3;
    288264      this.problemInstancesView.ViewsLabelVisible = true;
     
    292268      //
    293269      this.instancesDropPanel.AllowDrop = true;
    294       this.instancesDropPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     270      this.instancesDropPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    295271            | System.Windows.Forms.AnchorStyles.Right)));
    296272      this.instancesDropPanel.BackColor = System.Drawing.Color.LightYellow;
     
    326302      this.refreshMapButton.Click += new System.EventHandler(this.refreshMapButton_Click);
    327303      //
     304      // progressPanel
     305      //
     306      this.progressPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     307            | System.Windows.Forms.AnchorStyles.Left)
     308            | System.Windows.Forms.AnchorStyles.Right)));
     309      this.progressPanel.Location = new System.Drawing.Point(0, 81);
     310      this.progressPanel.Name = "progressPanel";
     311      this.progressPanel.Size = new System.Drawing.Size(549, 332);
     312      this.progressPanel.TabIndex = 2;
     313      this.progressPanel.Visible = false;
     314      //
     315      // okbDownloadButton
     316      //
     317      this.okbDownloadButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     318            | System.Windows.Forms.AnchorStyles.Right)));
     319      this.okbDownloadButton.Location = new System.Drawing.Point(6, 52);
     320      this.okbDownloadButton.Name = "okbDownloadButton";
     321      this.okbDownloadButton.Size = new System.Drawing.Size(518, 23);
     322      this.okbDownloadButton.TabIndex = 1;
     323      this.okbDownloadButton.Text = "Download from OKB";
     324      this.okbDownloadButton.UseVisualStyleBackColor = true;
     325      this.okbDownloadButton.Click += new System.EventHandler(this.okbDownloadButton_Click);
     326      //
    328327      // openFileDialog
    329328      //
     
    333332      this.openFileDialog.Title = "Open Optimizer";
    334333      //
    335       // okbDownloadButton
    336       //
    337       this.okbDownloadButton.Location = new System.Drawing.Point(6, 6);
    338       this.okbDownloadButton.Name = "okbDownloadButton";
    339       this.okbDownloadButton.Size = new System.Drawing.Size(146, 23);
    340       this.okbDownloadButton.TabIndex = 1;
    341       this.okbDownloadButton.Text = "Download from OKB";
    342       this.okbDownloadButton.UseVisualStyleBackColor = true;
    343       this.okbDownloadButton.Click += new System.EventHandler(this.okbDownloadButton_Click);
    344       //
    345       // runsView
    346       //
    347       this.runsView.Caption = "RunCollection View";
    348       this.runsView.Content = null;
    349       this.runsView.Dock = System.Windows.Forms.DockStyle.Fill;
    350       this.runsView.Location = new System.Drawing.Point(3, 3);
    351       this.runsView.Name = "runsView";
    352       this.runsView.ReadOnly = false;
    353       this.runsView.Size = new System.Drawing.Size(532, 329);
    354       this.runsView.TabIndex = 1;
    355       //
    356       // progressPanel
    357       //
    358       this.progressPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    359             | System.Windows.Forms.AnchorStyles.Left)
    360             | System.Windows.Forms.AnchorStyles.Right)));
    361       this.progressPanel.Location = new System.Drawing.Point(6, 35);
    362       this.progressPanel.Name = "progressPanel";
    363       this.progressPanel.Size = new System.Drawing.Size(526, 294);
    364       this.progressPanel.TabIndex = 2;
    365       this.progressPanel.Visible = false;
     334      // algorithmStartButton
     335      //
     336      this.algorithmStartButton.Location = new System.Drawing.Point(506, 5);
     337      this.algorithmStartButton.Name = "algorithmStartButton";
     338      this.algorithmStartButton.Size = new System.Drawing.Size(26, 23);
     339      this.algorithmStartButton.TabIndex = 3;
     340      this.algorithmStartButton.Text = "Start";
     341      this.algorithmStartButton.UseVisualStyleBackColor = true;
     342      this.algorithmStartButton.Click += new System.EventHandler(this.algorithmStartButton_Click);
    366343      //
    367344      // ExpertSystemView
    368345      //
    369346      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     347      this.Controls.Add(this.okbDownloadButton);
    370348      this.Controls.Add(this.tabControl);
    371349      this.Controls.Add(this.evaluationsLimitabel);
    372350      this.Controls.Add(this.maxEvaluationsTextBox);
     351      this.Controls.Add(this.progressPanel);
    373352      this.Name = "ExpertSystemView";
    374353      this.Size = new System.Drawing.Size(549, 413);
     354      this.Controls.SetChildIndex(this.progressPanel, 0);
    375355      this.Controls.SetChildIndex(this.maxEvaluationsTextBox, 0);
    376356      this.Controls.SetChildIndex(this.evaluationsLimitabel, 0);
    377357      this.Controls.SetChildIndex(this.tabControl, 0);
    378358      this.Controls.SetChildIndex(this.nameLabel, 0);
     359      this.Controls.SetChildIndex(this.okbDownloadButton, 0);
    379360      this.Controls.SetChildIndex(this.nameTextBox, 0);
    380361      this.Controls.SetChildIndex(this.infoLabel, 0);
     
    404385    private System.Windows.Forms.TabPage problemTabPage;
    405386    private MainForm.WindowsForms.ViewHost problemViewHost;
    406     private System.Windows.Forms.Button openProblemButton;
    407     private System.Windows.Forms.Button newProblemButton;
    408387    private System.Windows.Forms.TabPage algorithmTabPage;
    409388    private MainForm.WindowsForms.ViewHost algorithmViewHost;
     
    411390    private System.Windows.Forms.ComboBox suggestedInstancesComboBox;
    412391    private System.Windows.Forms.TabPage okbTabPage;
    413     private MainForm.WindowsForms.ViewHost algorithmInstancesViewHost;
    414392    private System.Windows.Forms.TabPage problemInstancesTabPage;
    415393    private System.Windows.Forms.Panel instancesDropPanel;
     
    419397    private System.Windows.Forms.Button okbDownloadButton;
    420398    private System.Windows.Forms.Panel progressPanel;
     399    private MainForm.WindowsForms.ViewHost kbViewHost;
     400    private System.Windows.Forms.Button algorithmStartButton;
    421401  }
    422402}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs

    r13485 r13551  
    3030using HeuristicLab.MainForm;
    3131using HeuristicLab.Optimization;
    32 using HeuristicLab.PluginInfrastructure;
     32using HeuristicLab.Optimization.Views;
    3333
    3434namespace HeuristicLab.OptimizationExpertSystem.Views {
     
    4747    public ExpertSystemView() {
    4848      InitializeComponent();
     49      // brings progress panel to front (it is not visible by default, but obstructs other elements in designer)
     50      this.Controls.SetChildIndex(this.progressPanel, 0);
     51      algorithmStartButton.Text = string.Empty;
     52      algorithmStartButton.Image = VSImageLibrary.Play;
    4953      refreshMapButton.Text = string.Empty;
    5054      refreshMapButton.Image = VSImageLibrary.Refresh;
     
    6064
    6165    protected override void DeregisterContentEvents() {
    62       Content.PropertyChanged -= Content_PropertyChanged;
     66      Content.PropertyChanged -= ContentOnPropertyChanged;
    6367      Content.SuggestedInstances.CollectionReset -= SuggestedInstancesOnChanged;
    6468      Content.SuggestedInstances.ItemsAdded -= SuggestedInstancesOnChanged;
     
    6670      Content.SuggestedInstances.ItemsRemoved -= SuggestedInstancesOnChanged;
    6771      Content.SuggestedInstances.ItemsReplaced -= SuggestedInstancesOnChanged;
     72      if (Content.Problem != null) Content.Problem.ProblemChanged -= ContentOnProblemChanged;
    6873      base.DeregisterContentEvents();
    6974    }
    7075    protected override void RegisterContentEvents() {
    7176      base.RegisterContentEvents();
    72       Content.PropertyChanged += Content_PropertyChanged;
     77      Content.PropertyChanged += ContentOnPropertyChanged;
    7378      Content.SuggestedInstances.CollectionReset += SuggestedInstancesOnChanged;
    7479      Content.SuggestedInstances.ItemsAdded += SuggestedInstancesOnChanged;
     
    7681      Content.SuggestedInstances.ItemsRemoved += SuggestedInstancesOnChanged;
    7782      Content.SuggestedInstances.ItemsReplaced += SuggestedInstancesOnChanged;
     83      if (Content.Problem != null) Content.Problem.ProblemChanged += ContentOnProblemChanged;
    7884    }
    7985
     
    8995          algorithmViewHost.Content = null;
    9096          runsView.Content = null;
    91           algorithmInstancesViewHost.Content = null;
     97          kbViewHost.Content = null;
    9298          problemInstancesView.Content = null;
    9399        } else {
     
    95101          problemViewHost.Content = Content.Problem;
    96102          runsView.Content = Content.Runs;
    97           algorithmInstancesViewHost.Content = Content.AlgorithmInstances;
     103          kbViewHost.ViewType = typeof(RunCollectionRLDView);
     104          kbViewHost.Content = Content.KnowledgeBase;
    98105          problemInstancesView.Content = Content.ProblemInstances;
    99106        }
     
    105112      base.SetEnabledStateOfControls();
    106113      maxEvaluationsTextBox.Enabled = Content != null && !ReadOnly && !Locked;
    107       newProblemButton.Enabled = Content != null && !ReadOnly && !Locked;
    108       openProblemButton.Enabled = Content != null && !ReadOnly && !Locked;
    109       problemViewHost.Enabled = Content != null && !ReadOnly && !Locked;
    110       suggestedInstancesComboBox.Enabled = Content != null && !ReadOnly && !Locked;
     114      problemViewHost.Enabled = Content != null && !ReadOnly && !Locked && !okbDownloadInProgress;
     115      suggestedInstancesComboBox.Enabled = Content != null && !ReadOnly && !Locked && !okbDownloadInProgress;
     116      algorithmStartButton.Enabled = Content != null && !ReadOnly && !Locked && suggestedInstancesComboBox.SelectedIndex >= 0;
    111117      algorithmViewHost.Enabled = Content != null && !ReadOnly && !Locked;
    112118      runsView.Enabled = Content != null;
    113       algorithmInstancesViewHost.Enabled = Content != null && !okbDownloadInProgress;
     119      kbViewHost.Enabled = Content != null && !okbDownloadInProgress;
     120      problemInstancesView.Enabled = Content != null && !okbDownloadInProgress;
    114121      refreshMapButton.Enabled = Content != null;
    115       okbDownloadButton.Enabled = Content != null && Content.Problem != null && !ReadOnly && !Locked && !okbDownloadInProgress;
     122      okbDownloadButton.Enabled = Content != null && Content.Problem != null && Content.Problem.ProblemId >= 0 && !ReadOnly && !Locked && !okbDownloadInProgress;
    116123    }
    117124
     
    134141    #region Event Handlers
    135142    #region Content events
    136     private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     143    private void ContentOnProblemChanged(object sender, EventArgs eventArgs) {
     144      UpdateSuggestedInstancesCombobox();
     145      SetEnabledStateOfControls();
     146    }
     147
     148    private void ContentOnPropertyChanged(object sender, PropertyChangedEventArgs e) {
    137149      if (InvokeRequired) {
    138         Invoke((Action<object, PropertyChangedEventArgs>)Content_PropertyChanged, sender, e);
     150        Invoke((Action<object, PropertyChangedEventArgs>)ContentOnPropertyChanged, sender, e);
    139151        return;
    140152      }
     
    142154      try {
    143155        switch (e.PropertyName) {
    144           case "AlgorithmInstances": algorithmInstancesViewHost.Content = Content.AlgorithmInstances; break;
     156          case "KnowledgeBase": kbViewHost.Content = Content.KnowledgeBase; break;
    145157          case "MaximumEvaluations": maxEvaluationsTextBox.Text = Content.MaximumEvaluations.ToString(); break;
    146           case "Problem": problemViewHost.Content = Content.Problem; break;
     158          case "Problem":
     159            problemViewHost.Content = Content.Problem;
     160            Content.Problem.ProblemChanged += ContentOnProblemChanged;
     161            break;
    147162          case "ProblemInstances": problemInstancesView.Content = Content.ProblemInstances; break;
    148163        }
     
    172187        errorProvider.SetError(maxEvaluationsTextBox, null);
    173188      }
    174     }
    175 
    176     private void newProblemButton_Click(object sender, EventArgs e) {
    177       if (problemTypeSelectorDialog == null) {
    178         problemTypeSelectorDialog = new TypeSelectorDialog { Caption = "Select Problem" };
    179         problemTypeSelectorDialog.TypeSelector.Caption = "Available Problems";
    180         problemTypeSelectorDialog.TypeSelector.Configure(typeof(ISingleObjectiveHeuristicOptimizationProblem)
    181           , showNotInstantiableTypes: false, showGenericTypes: false);
    182       }
    183       if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    184         try {
    185           Content.Problem = (ISingleObjectiveHeuristicOptimizationProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    186         } catch (Exception ex) {
    187           ErrorHandling.ShowErrorDialog(this, ex);
    188         }
    189       }
    190     }
    191 
    192     private void openProblemButton_Click(object sender, EventArgs e) {
    193       openFileDialog.Title = "Open Problem";
    194       if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
    195         newProblemButton.Enabled = openProblemButton.Enabled = false;
    196         problemViewHost.Enabled = false;
    197 
    198         ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) {
    199           try {
    200             if (error != null) throw error;
    201             var problem = content as ISingleObjectiveHeuristicOptimizationProblem;
    202             if (problem == null) {
    203               var algorithm = content as IAlgorithm;
    204               if (algorithm == null || !(algorithm.Problem is ISingleObjectiveHeuristicOptimizationProblem))
    205                 MessageBox.Show(this, "The selected file is not a problem, nor an algorithm with a problem.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);
    206               else Content.Problem = (ISingleObjectiveHeuristicOptimizationProblem)algorithm.Problem;
    207             } else
    208               Content.Problem = problem;
    209           } catch (Exception ex) {
    210             ErrorHandling.ShowErrorDialog(this, ex);
    211           } finally {
    212             Invoke(new Action(delegate() {
    213               problemViewHost.Enabled = true;
    214               newProblemButton.Enabled = openProblemButton.Enabled = true;
    215             }));
    216           }
    217         });
    218       }
    219     }
    220 
    221     private void problemTabPage_DragEnterOver(object sender, DragEventArgs e) {
    222       e.Effect = DragDropEffects.None;
    223       var prob = e.Data.GetData(Constants.DragDropDataFormat) as ISingleObjectiveHeuristicOptimizationProblem;
    224       if (!ReadOnly && prob != null) {
    225         if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
    226         else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
    227         else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
    228         else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
    229         else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
    230       }
    231     }
    232 
    233     private void problemTabPage_DragDrop(object sender, DragEventArgs e) {
    234       if (e.Effect != DragDropEffects.None) {
    235         var prob = e.Data.GetData(Constants.DragDropDataFormat) as ISingleObjectiveHeuristicOptimizationProblem;
    236         if (e.Effect.HasFlag(DragDropEffects.Copy)) prob = (ISingleObjectiveHeuristicOptimizationProblem)prob.Clone();
    237         Content.Problem = prob;
    238       }
    239     }
    240 
    241     private void suggestedInstancesComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    242       if (SuppressEvents) return;
    243       if (InvokeRequired) { Invoke((Action<object, EventArgs>)suggestedInstancesComboBox_SelectedIndexChanged, sender, e); return; }
    244       if (suggestedInstancesComboBox.SelectedIndex >= 0)
    245         algorithmViewHost.Content = (IAlgorithm)suggestedInstancesComboBox.SelectedItem;
    246       else algorithmViewHost.Content = null;
    247189    }
    248190    #endregion
     
    290232
    291233    private void okbDownloadButton_Click(object sender, EventArgs e) {
     234      if (Content.Problem.ProblemId < 0) {
     235        MessageBox.Show("Please select a problem instance first.");
     236        return;
     237      }
    292238      var progress = new Progress();
    293239      progress.ProgressStateChanged += OkbDownloadProgressOnStateChanged;
     
    307253      }
    308254    }
     255
     256    private void algorithmStartButton_Click(object sender, EventArgs e) {
     257      var selectedInstance = (IAlgorithm)suggestedInstancesComboBox.SelectedItem;
     258      var clone = (IAlgorithm)selectedInstance.Clone();
     259      clone.Prepare(true);
     260      clone.Start();
     261      algorithmViewHost.Content = clone.Results;
     262    }
    309263  }
    310264}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.resx

    r13485 r13551  
    127127    <value>140, 17</value>
    128128  </metadata>
    129   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    130   <data name="openProblemButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    131     <value>
    132         iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6
    133         JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAsMAAALDAE/QCLIAAACeUlE
    134         QVQ4T6WSWUiUURiG/4suurJIjUIwskQsEAMjqosQpUVNKbdCSRPKrQVDMddmXEedGdcpFXNGnUYdrSzF
    135         sEIoFInQcqHE1CwoKsXUUMnt6XfEye0munjgnO+c9+HjO0cA/osNi2tJLdA6SXN13MwoI12lJ06uiV8+
    136         W3d5IwIjVXiGKvwX11djSs2TRFlUito7ILIAoVab7SvCWhqrZYq1omXC4gpPe4Ur8AjNMQjo69IwPVZj
    137         4PeojtlhNfoyBXXalKSNBJ5hSjxCcnELzkeoKVcyNVq5Kjz/rZDZnggqSzOoKEpDXZBEcU4id+Sx5Mui
    138         RcdfmVClyWLqh8YYXhDD9MVCT/CGrBPcK5Hx62uxMdxUm2XgiT6Tep2MhxVp6NXJ6IqllKlucTc3niJl
    139         LKqsGINMqChOY+JTnqHtwRYJdZVK5gelMJSymo9ibSAOeiPhXTid1T5cD3IvF9SqZMb7M+CznEdVCtqe
    140         ypcurWz9bQC0ezHX6sr0M0c+lNtx5cKJcVGwXyjJlfDzvZSh1gTqdHIWBiTQHbIU7AwSg+eYa3Nnuvk4
    141         E41HGak9gDTUmvPOZjmGGRQqExjpiuG+NouOl2InvRGi4BJ0+LPw6gwzL04x2XSM0ToHvlfZ0p66FT9X
    142         KxxsTGwMAlVmLN3NiTzQZkJ/IrwR233tzUyLG5PPHRmrP8Sw3o4vmr30yE2RBO/Bfp9Fg/EV8tKjqSnL
    143         oOdxGO3ZgpE2+SaaZZtpSNpCdbw56mgLbt/YhZ/L7oVD9pYuRkF2ShTZksukxwQSd813cbJc9HHm7MnD
    144         OB2x46CdNbZWFljuNGP7NhN2mJqIuRX/YOXm30H4A70P0TsBWkcYAAAAAElFTkSuQmCC
    145 </value>
    146   </data>
    147   <data name="newProblemButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    148     <value>
    149         iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6
    150         JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAsMAAALDAE/QCLIAAABmElE
    151         QVQ4T42QTUsCURSGJWgVtWkb9AfatKhN1L4I2rRoX9BvEIJ+QG4qFNKKCAMtEPqAUMiKamESEmpoWiKa
    152         YuZnmuOo83bufKUYgy+8c849957n3jk6ALJXOWAxBAulfrKwEAOW+L/9/y0locEzXs9SI3BB8UXKxVp1
    153         +lg5/J+lJDLwpDYckE91Uk61YngKDncAdqcP1nMP80YXgDdQMJI32ZLJJr3ETLYpNWD35AaTcysdEPFD
    154         T24gPSxgi5bs/9/7gWuK3DiQGGG9ooxWJ1wPAQVioJIMaM571V9gN9Lt6kywTpa0fXgpNismyYDKzK3a
    155         sEcx2ifmUm2HLKnRbIkQBUSSAcy5sTVEhkxw0DI5CuT0QMXCDokSBAHVGo9MrioCJmaXWbkNIHvfcUeh
    156         W3W+iXyphni6pA0w290UOtVsCShX60hlK3iN57UBpiMXhU7VuAayhR/EPorwR7LaALbZLja44jeHRKaM
    157         UCwHbzDdO6B9cNFEAc/hT9z7kr0D2gcXfPuCx5/C1WO8NwCLWtYEsM1eDED3C6WCFYVQ3tbcAAAAAElF
    158         TkSuQmCC
    159 </value>
    160   </data>
    161129  <metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    162130    <value>230, 17</value>
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/ExpertSystem.cs

    r13485 r13551  
    2828using System.Threading.Tasks;
    2929using HeuristicLab.Analysis;
     30using HeuristicLab.Collections;
    3031using HeuristicLab.Common;
    3132using HeuristicLab.Common.Resources;
     
    3637using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3738using HeuristicLab.Persistence.Default.Xml;
     39using RunCreationClient = HeuristicLab.Clients.OKB.RunCreation.RunCreationClient;
     40using SingleObjectiveOKBProblem = HeuristicLab.Clients.OKB.RunCreation.SingleObjectiveOKBProblem;
    3841
    3942namespace HeuristicLab.OptimizationExpertSystem {
     
    6871
    6972    [Storable]
    70     private ItemList<IAlgorithm> algorithmInstances;
    71     public ItemList<IAlgorithm> AlgorithmInstances {
    72       get { return algorithmInstances; }
     73    private RunCollection knowledgeBase;
     74    public RunCollection KnowledgeBase {
     75      get { return knowledgeBase; }
    7376      set {
    74         if (algorithmInstances == value) return;
    75         algorithmInstances = value;
    76         OnPropertyChanged("AlgorithmInstances");
    77         // TODO: Attach event handlers
    78       }
    79     }
    80 
    81     [Storable]
    82     private ISingleObjectiveHeuristicOptimizationProblem problem;
    83     public ISingleObjectiveHeuristicOptimizationProblem Problem {
     77        if (knowledgeBase == value) return;
     78        knowledgeBase = value;
     79        OnPropertyChanged("KnowledgeBase");
     80      }
     81    }
     82
     83    [Storable]
     84    private SingleObjectiveOKBProblem problem;
     85    public SingleObjectiveOKBProblem Problem {
    8486      get { return problem; }
    8587      set {
     
    109111    }
    110112
     113    [Storable]
     114    private BidirectionalLookup<long, IRun> algorithmId2RunMapping;
     115    [Storable]
     116    private BidirectionalDictionary<long, IAlgorithm> algorithmId2AlgorithmInstanceMapping;
     117
    111118    private bool Maximization {
    112       get { return Problem != null && ((IValueParameter<BoolValue>)Problem.MaximizationParameter).Value.Value; }
     119      get {
     120        return Problem != null && Problem.ProblemId >= 0 && ((IValueParameter<BoolValue>)Problem.MaximizationParameter).Value.Value;
     121      }
    113122    }
    114123
     
    118127      : base(original, cloner) {
    119128      runs = cloner.Clone(original.runs);
    120       algorithmInstances = cloner.Clone(original.algorithmInstances);
    121       problem = cloner.Clone(original.problem);
     129      knowledgeBase = cloner.Clone(original.knowledgeBase);
    122130      suggestedInstances = cloner.Clone(original.suggestedInstances);
    123131      readOnlySuggestedInstances = suggestedInstances.AsReadOnly();
    124132      problemInstances = cloner.Clone(original.problemInstances);
     133      problem = cloner.Clone(original.problem);
     134      algorithmId2RunMapping = new BidirectionalLookup<long, IRun>();
     135      foreach (var kvp in original.algorithmId2RunMapping.FirstEnumerable) {
     136        algorithmId2RunMapping.AddRangeFirst(kvp.Key, kvp.Select(cloner.Clone));
     137      }
     138      algorithmId2AlgorithmInstanceMapping = new BidirectionalDictionary<long, IAlgorithm>();
     139      foreach (var kvp in original.algorithmId2AlgorithmInstanceMapping) {
     140        algorithmId2AlgorithmInstanceMapping.Add(kvp.Key, cloner.Clone(kvp.Value));
     141      }
    125142      RegisterEventHandlers();
    126143    }
     
    129146      Description = ItemDescription;
    130147      runs = new RunCollection();
    131       algorithmInstances = new ItemList<IAlgorithm>();
     148      knowledgeBase = new RunCollection();
    132149      suggestedInstances = new ItemList<IAlgorithm>();
    133150      readOnlySuggestedInstances = suggestedInstances.AsReadOnly();
    134151      problemInstances = new RunCollection();
     152      problem = new SingleObjectiveOKBProblem();
     153      algorithmId2RunMapping = new BidirectionalLookup<long, IRun>();
     154      algorithmId2AlgorithmInstanceMapping = new BidirectionalDictionary<long, IAlgorithm>();
    135155      RegisterEventHandlers();
     156    }
     157
     158    private void ProblemOnProblemChanged(object sender, EventArgs eventArgs) {
     159      if (Problem == null) return;
    136160    }
    137161
     
    147171
    148172    private void RegisterEventHandlers() {
     173      problem.ProblemChanged += ProblemOnProblemChanged;
    149174      runs.CollectionReset += InformationChanged;
    150175      runs.ItemsAdded += InformationChanged;
     
    152177      runs.Reset += InformationChanged;
    153178      runs.UpdateOfRunsInProgressChanged += InformationChanged;
    154       algorithmInstances.CollectionReset += InformationChanged;
    155       algorithmInstances.ItemsAdded += InformationChanged;
    156       algorithmInstances.ItemsRemoved += InformationChanged;
     179      knowledgeBase.CollectionReset += InformationChanged;
     180      knowledgeBase.ItemsAdded += InformationChanged;
     181      knowledgeBase.ItemsRemoved += InformationChanged;
    157182    }
    158183
     
    181206      alglib.pcabuildbasis(ds, instanceCounter, flaValues.Count, out info, out s2, out v);
    182207
    183       var algInstRunDict = AlgorithmInstances.SelectMany(x => x.Runs)
    184                                              .Where(x => x.Parameters.ContainsKey("Problem Name") && x.Parameters["Problem Name"] is StringValue)
    185                                              .GroupBy(x => ((StringValue)x.Parameters["Problem Name"]).Value)
    186                                              .ToDictionary(x => x.Key, x => x.GroupBy(y => ((StringValue)y.Parameters["Algorithm Name"]).Value)
    187                                                                              .ToDictionary(y => y.Key, y => y.ToList()));
    188208      ProblemInstances.UpdateOfRunsInProgress = true;
    189209      try {
    190210        instanceCounter = 0;
    191211        foreach (var instance in ProblemInstances) {
    192           IItem probNameParam;
    193           if (!instance.Parameters.TryGetValue("Problem Name", out probNameParam)) continue;
    194           var probInstanceName = ((StringValue)probNameParam).Value;
    195 
    196212          double x = 0, y = 0;
    197213          for (var feature = 0; feature < flaValues.Count; feature++) {
     
    208224
    209225          instanceCounter++;
    210 
     226        }
     227      } finally { ProblemInstances.UpdateOfRunsInProgress = false; }
     228    }
     229
     230    private static readonly HashSet<string> InterestingValueNames = new HashSet<string>() {
     231      "QualityPerEvaluations", "Problem Name", "Problem Type", "Algorithm Name", "Algorithm Type", "Maximization", "BestKnownQuality"
     232    };
     233
     234    public async void UpdateKnowledgeBaseAsync(IProgress progress) {
     235      progress.Start("Updating Knowledge Base from OKB");
     236      await Task.Factory.StartNew(() => { DoUpdateKnowledgeBase(progress); }, TaskCreationOptions.LongRunning);
     237    }
     238
     239    public void UpdateKnowledgeBase() {
     240      DoUpdateKnowledgeBase(new Progress(string.Empty, ProgressState.Started));
     241    }
     242
     243    private void DoUpdateKnowledgeBase(IProgress progress) {
     244      var queryClient = Clients.OKB.Query.QueryClient.Instance;
     245      var adminClient = Clients.OKB.Administration.AdministrationClient.Instance;
     246      try {
     247        progress.Status = "Downloading run information...";
     248        progress.ProgressValue = 0;
     249        // FIXME: How to tell if refresh is necessary?
     250        queryClient.Refresh();
     251        progress.ProgressValue = 0.5;
     252        progress.Status = "Downloading algorithm and problem instance information...";
     253        // FIXME: How to tell if refresh is necessary?
     254        adminClient.Refresh();
     255
     256        var probInstance = adminClient.Problems.SingleOrDefault(x => x.Id == Problem.ProblemId);
     257        if (probInstance == null) throw new InvalidOperationException("The chosen problem instance cannot be found in the OKB.");
     258        var probClassId = probInstance.ProblemClassId;
     259
     260        var problemClassFilter = (Clients.OKB.Query.StringComparisonAvailableValuesFilter)queryClient.Filters.Single(x => x.Label == "Problem Class Name");
     261        problemClassFilter.Value = adminClient.ProblemClasses.Single(x => x.Id == probClassId).Name;
     262
     263        progress.Status = "Downloading problem instances...";
     264        progress.ProgressValue = 0;
     265        var p = 0;
     266        ProblemInstances.UpdateOfRunsInProgress = true;
     267        ProblemInstances.Clear();
     268        var totalProblems = adminClient.Problems.Count(x => x.ProblemClassId == probClassId);
     269        foreach (var problInst in adminClient.Problems.Where(x => x.ProblemClassId == probClassId)) {
     270          progress.Status = string.Format("Downloading problem {0} (okb-id: {1})....", problInst.Name, problInst.Id);
     271          var data = Clients.OKB.Administration.AdministrationClient.GetProblemData(problInst.Id);
     272          if (data != null) {
     273            using (var stream = new MemoryStream(data)) {
     274              try {
     275                var prob = (IProblem)XmlParser.Deserialize<IContent>(stream);
     276                var probRun = new Run() { Name = prob.Name };
     277                prob.CollectParameterValues(probRun.Parameters);
     278                progress.Status += Environment.NewLine + "Downloading characteristics...";
     279                foreach (var v in RunCreationClient.GetCharacteristicValues(problInst.Id)) {
     280                  probRun.Results.Add("Characteristic." + v.Name, RunCreationClient.Instance.ConvertToItem(v));
     281                }
     282                ProblemInstances.Add(probRun);
     283              } catch { }
     284              stream.Close();
     285            }
     286          }
     287          p++;
     288          progress.ProgressValue = p / (double)totalProblems;
     289        }
     290
     291        algorithmId2AlgorithmInstanceMapping.Clear();
     292        progress.Status = "Downloading algorithm instances...";
     293        progress.ProgressValue = 0;
     294        p = 0;
     295        foreach (var algInst in adminClient.Algorithms) {
     296          progress.Status = string.Format("Downloading algorithm {0} (okb-id: {1})...", algInst.Name, algInst.Id);
     297          var data = Clients.OKB.Administration.AdministrationClient.GetAlgorithmData(algInst.Id);
     298          if (data != null) {
     299            using (var stream = new MemoryStream(data)) {
     300              try {
     301                var alg = (IAlgorithm)XmlParser.Deserialize<IContent>(stream);
     302                algorithmId2AlgorithmInstanceMapping.Add(algInst.Id, alg);
     303              } catch { }
     304              stream.Close();
     305            }
     306          }
     307          p++;
     308          progress.ProgressValue = p / (double)adminClient.Algorithms.Count;
     309        }
     310
     311        var interestingValues = queryClient.ValueNames.Where(x => InterestingValueNames.Contains(x.Name)).ToList();
     312
     313        progress.Status = "Obtaining number of runs...";
     314        progress.ProgressValue = 0;
     315        p = 0;
     316        var count = queryClient.GetNumberOfRuns(problemClassFilter);
     317        if (count == 0) return;
     318
     319        var runIds = queryClient.GetRunIds(problemClassFilter).ToList();
     320        var conversions = new List<Task>();
     321        var runList = new List<IRun>();
     322        while (p < count) {
     323          var nextIds = runIds.Skip(p).Take(500).ToList();
     324          progress.Status = string.Format("Downloading runs {0} to {1} of {2}...", p, p + nextIds.Count, count);
     325          var okbRuns = queryClient.GetRunsWithValues(nextIds, true, interestingValues);
     326          conversions.Add(Task.Factory.StartNew(() => {
     327            var hlRuns = okbRuns.AsParallel().Select(x => new { AlgorithmId = x.Algorithm.Id, Run = queryClient.ConvertToOptimizationRun(x) }).ToList();
     328            lock (runList) {
     329              foreach (var r in hlRuns) {
     330                algorithmId2RunMapping.Add(r.AlgorithmId, r.Run);
     331                runList.Add(r.Run);
     332              }
     333            }
     334          }));
     335          p += nextIds.Count;
     336          progress.ProgressValue = p / (double)count;
     337        }
     338        Task.WaitAll(conversions.ToArray());
     339
     340        progress.Status = "Finishing...";
     341        var algInstRunDict = runList.Where(x => x.Parameters.ContainsKey("Problem Name") && x.Parameters["Problem Name"] is StringValue)
     342                                          .GroupBy(x => ((StringValue)x.Parameters["Problem Name"]).Value)
     343                                          .ToDictionary(x => x.Key, x => x.GroupBy(y => ((StringValue)y.Parameters["Algorithm Name"]).Value)
     344                                                                                  .ToDictionary(y => y.Key, y => y.ToList()));
     345
     346        foreach (var instance in ProblemInstances) {
     347          IItem probNameParam;
     348          if (!instance.Parameters.TryGetValue("Problem Name", out probNameParam)) continue;
     349
     350          var probInstanceName = ((StringValue)probNameParam).Value;
    211351          var bkQuality = ((DoubleValue)instance.Parameters["BestKnownQuality"]).Value;
    212352          var maximization = ((BoolValue)instance.Parameters["Maximization"]).Value;
     
    219359              var result = ExpectedRuntimeHelper.CalculateErt(kvp.Value, "QualityPerEvaluations", bkQuality * target, maximization);
    220360              var resultName = algInstanceName + "@" + ((target - 1) * 100) + "%";
     361              IItem item;
    221362              if (instance.Results.TryGetValue(resultName, out item)) {
    222363                ((DoubleValue)item).Value = Math.Log10(result.ExpectedRuntime);
     
    225366          }
    226367        }
    227       } finally { ProblemInstances.UpdateOfRunsInProgress = false; }
    228     }
    229 
    230     private static readonly HashSet<string> InterestingValueNames = new HashSet<string>() {
    231       "QualityPerEvaluations", "Problem Name", "Problem Type", "Algorithm Name", "Algorithm Type", "Maximization"
    232     };
    233 
    234     public async void UpdateKnowledgeBaseAsync(IProgress progress) {
    235       progress.Start("Updating Knowledge Base from OKB");
    236       await Task.Factory.StartNew(() => { DoUpdateKnowledgeBase(progress); }, TaskCreationOptions.LongRunning);
    237     }
    238 
    239     public void UpdateKnowledgeBase() {
    240       DoUpdateKnowledgeBase(new Progress(string.Empty, ProgressState.Started));
    241     }
    242 
    243     private void DoUpdateKnowledgeBase(IProgress progress) {
    244       var queryClient = Clients.OKB.Query.QueryClient.Instance;
    245       var adminClient = Clients.OKB.Administration.AdministrationClient.Instance;
    246       try {
    247         progress.Status = "Refreshing query client...";
    248         queryClient.Refresh();
    249         var interestingValues = queryClient.ValueNames.Where(x => InterestingValueNames.Contains(x.Name)).ToList();
    250 
    251         var problemTypeFilter = (Clients.OKB.Query.StringComparisonAvailableValuesFilter)queryClient.Filters.Single(x => x.Label == "Problem Data Type Name");
    252         problemTypeFilter.Value = Problem.GetType().Name;
    253 
    254         progress.Status = "Obtaining number of runs...";
    255         var count = queryClient.GetNumberOfRuns(problemTypeFilter);
    256         if (count == 0) return;
    257 
    258         var runIds = queryClient.GetRunIds(problemTypeFilter).ToList();
    259         adminClient.Refresh();
    260         var i = 0;
    261         var conversions = new List<Task>();
    262         var runGroup = new Dictionary<Tuple<long, string>, List<IRun>>();
    263         while (i < count) {
    264           var nextIds = runIds.Skip(i).Take(500).ToList();
    265           progress.Status = string.Format("Downloading runs {0} to {1} of {2}...", i, i + nextIds.Count, count);
    266           var okbRuns = queryClient.GetRunsWithValues(nextIds, true, interestingValues);
    267           conversions.Add(Task.Factory.StartNew(() => {
    268             var hlRuns = okbRuns.AsParallel().Select(x => new { Id = x.Algorithm.Id, Name = x.Algorithm.Name, Run = queryClient.ConvertToOptimizationRun(x) })
    269                                 .GroupBy(x => Tuple.Create(x.Id, x.Name)).ToList();
    270             lock (runGroup) {
    271               foreach (var hr in hlRuns) {
    272                 List<IRun> runList;
    273                 if (!runGroup.TryGetValue(hr.Key, out runList)) {
    274                   runList = new List<IRun>();
    275                   runGroup[hr.Key] = runList;
    276                 }
    277                 runList.AddRange(hr.Select(x => x.Run));
    278               }
    279             }
    280           }));
    281           i += nextIds.Count;
    282           progress.ProgressValue = 0.8 * (i / (double)count);
    283         }
    284         Task.WaitAll(conversions.ToArray());
    285         var list = new ItemList<IAlgorithm>();
    286         i = 0;
    287         foreach (var rGroup in runGroup) {
    288           progress.Status = string.Format("Downloading algorithm {0}...", rGroup.Key.Item2);
    289           var data = Clients.OKB.Administration.AdministrationClient.GetAlgorithmData(rGroup.Key.Item1);
    290           if (data != null) {
    291             using (var stream = new MemoryStream(data)) {
    292               try {
    293                 var alg = (IAlgorithm)XmlParser.Deserialize<IContent>(stream);
    294                 alg.Runs.AddRange(rGroup.Value);
    295                 list.Add(alg);
    296               } catch (Exception) { }
    297               stream.Close();
    298             }
    299           }
    300           i++;
    301           progress.ProgressValue = 0.8 + 0.2 * (i / (double)runGroup.Count);
    302         }
    303         AlgorithmInstances = list;
    304       } finally { progress.Finish(); }
     368        KnowledgeBase = new RunCollection(runList);
     369      } finally { progress.Finish(); ProblemInstances.UpdateOfRunsInProgress = false; }
    305370    }
    306371
     
    308373      if (Problem == null) return;
    309374      var instances = new SortedList<double, IAlgorithm>();
    310       foreach (var instance in algorithmInstances) {
    311         var relevantRuns = instance.Runs.Where(x => ((StringValue)x.Parameters["Problem Type"]).Value == Problem.GetType().Name);
     375      foreach (var relevantRuns in knowledgeBase.GroupBy(x => x.Algorithm)) {
    312376        var avgQuality = 0.0;
    313377        var counter = 0;
     
    320384        }
    321385        avgQuality /= counter;
    322         instances.Add(avgQuality, instance);
     386        instances.Add(avgQuality, relevantRuns.Key);
    323387      }
    324388
    325389      suggestedInstances.Clear();
    326       var instanceLadder = instances.Select(x => x.Value);
     390      var instanceLadder = instances.Select(x => (IAlgorithm)x.Value.Clone());
    327391      suggestedInstances.AddRange(Maximization ? instanceLadder.Reverse() : instanceLadder);
    328392    }
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/HeuristicLab.OptimizationExpertSystem-3.3.csproj

    r13485 r13551  
    117117      <Private>False</Private>
    118118    </Reference>
     119    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     120      <SpecificVersion>False</SpecificVersion>
     121      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
     122      <Private>False</Private>
     123    </Reference>
     124    <Reference Include="HeuristicLab.Problems.QuadraticAssignment-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     125      <SpecificVersion>False</SpecificVersion>
     126      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.QuadraticAssignment-3.3.dll</HintPath>
     127      <Private>False</Private>
     128    </Reference>
    119129    <Reference Include="System" />
    120130    <Reference Include="System.Core" />
     
    131141    <Compile Include="Plugin.cs" />
    132142    <None Include="Properties\AssemblyInfo.cs.frame" />
     143    <Compile Include="ProblemCharacteristicAnalysis\CharacteristicCalculator.cs" />
     144    <Compile Include="ProblemCharacteristicAnalysis\DoubleMatrixCharacteristicCalculator.cs" />
     145    <Compile Include="ProblemCharacteristicAnalysis\QAP\QAPCharacteristicCalculator.cs" />
    133146    <Compile Include="Properties\AssemblyInfo.cs" />
    134147  </ItemGroup>
Note: See TracChangeset for help on using the changeset viewer.