Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/07/11 23:45:06 (13 years ago)
Author:
abeham
Message:

#1619, #1628

  • reintegrated changes from branch
Location:
trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views

    • Property svn:mergeinfo set to (toggle deleted branches)
      /branches/GP.Grammar.Editor/HeuristicLab.Problems.QuadraticAssignment.Viewsmergedeligible
      /branches/GeneralizedQAP/HeuristicLab.Problems.QuadraticAssignment.Viewsmergedeligible
      /branches/CloningRefactoring/HeuristicLab.Problems.QuadraticAssignment.Views4656-4721
      /branches/DataAnalysis Refactoring/HeuristicLab.Problems.QuadraticAssignment.Views5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Problems.QuadraticAssignment.Views5815-6180
      /branches/DataAnalysis/HeuristicLab.Problems.QuadraticAssignment.Views4458-4459,​4462,​4464
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.QuadraticAssignment.Views5060
      /branches/NET40/sources/HeuristicLab.Problems.QuadraticAssignment.Views5138-5162
      /branches/ParallelEngine/HeuristicLab.Problems.QuadraticAssignment.Views5175-5192
      /branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment.Views6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Problems.QuadraticAssignment.Views6828
      /branches/SuccessProgressAnalysis/HeuristicLab.Problems.QuadraticAssignment.Views5370-5682
      /branches/Trunk/HeuristicLab.Problems.QuadraticAssignment.Views6829-6865
      /branches/VNS/HeuristicLab.Problems.QuadraticAssignment.Views5594-5752
      /branches/histogram/HeuristicLab.Problems.QuadraticAssignment.Views5959-6341
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/HeuristicLab.Problems.QuadraticAssignment.Views-3.3.csproj

    r6866 r6891  
    104104    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86" />
    105105    <Reference Include="HeuristicLab.Data.Views-3.3">
    106       <HintPath>..\..\HeuristicLab.Data.Views\3.3\bin\x86\Debug\HeuristicLab.Data.Views-3.3.dll</HintPath>
     106      <HintPath>..\..\HeuristicLab.Data.Views\3.3\bin\Debug\HeuristicLab.Data.Views-3.3.dll</HintPath>
    107107    </Reference>
    108108    <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3">
    109       <HintPath>..\..\HeuristicLab.Visualization.ChartControlsExtensions\3.3\bin\x86\Debug\HeuristicLab.Visualization.ChartControlsExtensions-3.3.dll</HintPath>
     109      <HintPath>..\..\HeuristicLab.Visualization.ChartControlsExtensions\3.3\bin\Debug\HeuristicLab.Visualization.ChartControlsExtensions-3.3.dll</HintPath>
    110110    </Reference>
    111111    <Reference Include="System" />
     
    113113    <Reference Include="System.Data" />
    114114    <Reference Include="System.Drawing" />
     115    <Reference Include="System.Runtime.Serialization" />
     116    <Reference Include="System.ServiceModel" />
    115117    <Reference Include="System.Windows.Forms" />
    116118    <Reference Include="System.Windows.Forms.DataVisualization" />
    117     <Reference Include="System.Xml" />
    118119  </ItemGroup>
    119120  <ItemGroup>
     
    210211      <Private>False</Private>
    211212    </ProjectReference>
     213  </ItemGroup>
     214  <ItemGroup>
     215    <WCFMetadata Include="Service References\" />
    212216  </ItemGroup>
    213217  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/Plugin.cs.frame

    r6548 r6891  
    2626  [PluginFile("HeuristicLab.Problems.QuadraticAssignment.Views-3.3.dll", PluginFileType.Assembly)]
    2727  [PluginDependency("HeuristicLab.Analysis", "3.3")]
     28  [PluginDependency("HeuristicLab.Collections", "3.3")]
    2829  [PluginDependency("HeuristicLab.Common", "3.3")]
    2930  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     
    3435  [PluginDependency("HeuristicLab.MainForm", "3.3")]
    3536  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
     37  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    3638  [PluginDependency("HeuristicLab.Problems.QuadraticAssignment", "3.3")]
    3739  public class HeuristicLabProblemsQuadraticAssignmentViewsPlugin : PluginBase {
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.Designer.cs

    r6342 r6891  
    5454      this.visualizationTabPage = new System.Windows.Forms.TabPage();
    5555      this.qapView = new HeuristicLab.Problems.QuadraticAssignment.Views.QAPVisualizationControl();
     56      this.reloadInstancesButton = new System.Windows.Forms.Button();
     57      this.loadInstanceWorker = new System.ComponentModel.BackgroundWorker();
     58      this.progressBar = new System.Windows.Forms.ProgressBar();
     59      this.getInstancesWorker = new System.ComponentModel.BackgroundWorker();
    5660      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5761      this.tabControl.SuspendLayout();
     
    9094      this.toolTip.SetToolTip(this.importInstanceButton, "Import files in QAPLIB format.");
    9195      this.importInstanceButton.UseVisualStyleBackColor = true;
    92       this.importInstanceButton.Click += new System.EventHandler(this.importInstanceButton_Click);
     96      this.importInstanceButton.Click += new System.EventHandler(this.importFileInstanceButton_Click);
    9397      //
    9498      // openFileDialog
     
    120124      this.instancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    121125      this.instancesComboBox.FormattingEnabled = true;
    122       this.instancesComboBox.Location = new System.Drawing.Point(105, 2);
     126      this.instancesComboBox.Location = new System.Drawing.Point(137, 1);
    123127      this.instancesComboBox.Name = "instancesComboBox";
    124       this.instancesComboBox.Size = new System.Drawing.Size(358, 21);
     128      this.instancesComboBox.Size = new System.Drawing.Size(326, 21);
    125129      this.instancesComboBox.TabIndex = 7;
    126130      this.instancesComboBox.SelectedValueChanged += new System.EventHandler(this.instancesComboBox_SelectedValueChanged);
     
    184188      this.qapView.Weights = null;
    185189      //
     190      // reloadInstancesButton
     191      //
     192      this.reloadInstancesButton.Location = new System.Drawing.Point(105, 0);
     193      this.reloadInstancesButton.Name = "reloadInstancesButton";
     194      this.reloadInstancesButton.Size = new System.Drawing.Size(26, 23);
     195      this.reloadInstancesButton.TabIndex = 9;
     196      this.reloadInstancesButton.Text = "Reload";
     197      this.reloadInstancesButton.UseVisualStyleBackColor = true;
     198      this.reloadInstancesButton.Click += new System.EventHandler(this.reloadInstancesButton_Click);
     199      //
     200      // loadInstanceWorker
     201      //
     202      this.loadInstanceWorker.WorkerReportsProgress = true;
     203      this.loadInstanceWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.loadInstanceWorker_DoWork);
     204      this.loadInstanceWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.worker_ProgressChanged);
     205      this.loadInstanceWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.worker_RunWorkerCompleted);
     206      //
     207      // progressBar
     208      //
     209      this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     210                  | System.Windows.Forms.AnchorStyles.Right)));
     211      this.progressBar.Location = new System.Drawing.Point(137, 0);
     212      this.progressBar.Name = "progressBar";
     213      this.progressBar.Size = new System.Drawing.Size(326, 23);
     214      this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
     215      this.progressBar.TabIndex = 10;
     216      this.progressBar.Visible = false;
     217      //
     218      // getInstancesWorker
     219      //
     220      this.getInstancesWorker.WorkerReportsProgress = true;
     221      this.getInstancesWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.getInstancesWorker_DoWork);
     222      this.getInstancesWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.worker_ProgressChanged);
     223      this.getInstancesWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.worker_RunWorkerCompleted);
     224      //
    186225      // QuadraticAssignmentProblemView
    187226      //
    188227      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    189228      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     229      this.Controls.Add(this.progressBar);
    190230      this.Controls.Add(this.instancesComboBox);
    191231      this.Controls.Add(this.tabControl);
    192232      this.Controls.Add(this.importInstanceButton);
    193233      this.Controls.Add(this.loadInstanceButton);
     234      this.Controls.Add(this.reloadInstancesButton);
    194235      this.Controls.Add(this.QAPLIBInstancesLabel);
    195236      this.Name = "QuadraticAssignmentProblemView";
    196237      this.Size = new System.Drawing.Size(647, 492);
    197238      this.Controls.SetChildIndex(this.QAPLIBInstancesLabel, 0);
     239      this.Controls.SetChildIndex(this.reloadInstancesButton, 0);
    198240      this.Controls.SetChildIndex(this.loadInstanceButton, 0);
    199241      this.Controls.SetChildIndex(this.importInstanceButton, 0);
     
    204246      this.Controls.SetChildIndex(this.nameLabel, 0);
    205247      this.Controls.SetChildIndex(this.nameTextBox, 0);
     248      this.Controls.SetChildIndex(this.progressBar, 0);
    206249      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    207250      this.tabControl.ResumeLayout(false);
     
    223266    private System.Windows.Forms.TabPage visualizationTabPage;
    224267    private QAPVisualizationControl qapView;
     268    private System.Windows.Forms.Button reloadInstancesButton;
     269    private System.ComponentModel.BackgroundWorker loadInstanceWorker;
     270    private System.Windows.Forms.ProgressBar progressBar;
     271    private System.ComponentModel.BackgroundWorker getInstancesWorker;
    225272  }
    226273}
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.cs

    r6342 r6891  
    2121
    2222using System;
     23using System.ComponentModel;
    2324using System.Drawing;
     25using System.Linq;
    2426using System.Windows.Forms;
    2527using HeuristicLab.Common.Resources;
     28using HeuristicLab.Core;
    2629using HeuristicLab.Core.Views;
     30using HeuristicLab.Data;
     31using HeuristicLab.Encodings.PermutationEncoding;
    2732using HeuristicLab.MainForm;
    2833using HeuristicLab.MainForm.WindowsForms;
     34using HeuristicLab.Problems.QuadraticAssignment.QAPInstanceService;
    2935
    3036namespace HeuristicLab.Problems.QuadraticAssignment.Views {
     
    4046      InitializeComponent();
    4147      importInstanceButton.Image = VSImageLibrary.Open;
     48      reloadInstancesButton.Text = String.Empty;
     49      reloadInstancesButton.Image = VSImageLibrary.Refresh;
     50      loadInstanceButton.Image = VSImageLibrary.Internet;
    4251      Controls.Remove(parameterCollectionView);
    4352      parameterCollectionView.Dock = DockStyle.Fill;
     
    5059      Content.WeightsParameter.ValueChanged += new EventHandler(WeightsParameter_ValueChanged);
    5160      Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
     61      Content.Instances.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);
     62      Content.Instances.ItemsMoved += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);
     63      Content.Instances.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);
     64      Content.Instances.ItemsReplaced += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);
     65      Content.Instances.CollectionReset += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);
    5266    }
    5367
     
    5670      Content.WeightsParameter.ValueChanged -= new EventHandler(WeightsParameter_ValueChanged);
    5771      Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged);
     72      Content.Instances.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);
     73      Content.Instances.ItemsMoved -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);
     74      Content.Instances.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);
     75      Content.Instances.ItemsReplaced -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);
     76      Content.Instances.CollectionReset -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);
    5877      base.DeregisterContentEvents();
     78    }
     79
     80    private void Content_Instances_Changed(object sender, EventArgs e) {
     81      instancesComboBox.Items.Clear();
     82      foreach (string name in Content.Instances)
     83        instancesComboBox.Items.Add(name);
     84      if (instancesComboBox.Items.Count > 0)
     85        instancesComboBox.SelectedIndex = 0;
    5986    }
    6087
     
    73100    protected override void OnContentChanged() {
    74101      base.OnContentChanged();
    75       instancesComboBox.Items.Clear();
    76102      if (Content != null) {
    77         foreach (string instance in Content.EmbeddedInstances) {
    78           instancesComboBox.Items.Add(instance);
    79         }
    80103        qapView.Distances = Content.Distances;
    81104        qapView.Weights = Content.Weights;
     
    90113    protected override void SetEnabledStateOfControls() {
    91114      base.SetEnabledStateOfControls();
     115      reloadInstancesButton.Enabled = !ReadOnly && !Locked && Content != null;
    92116      instancesComboBox.Enabled = !ReadOnly && !Locked && Content != null;
    93       loadInstanceButton.Enabled = !ReadOnly && !Locked && Content != null && instancesComboBox.SelectedItem != null;
     117      loadInstanceButton.Enabled = !ReadOnly && !Locked && Content != null && !String.IsNullOrEmpty((string)instancesComboBox.SelectedItem);
    94118      importInstanceButton.Enabled = !ReadOnly && !Locked && Content != null;
    95119    }
    96120
    97121    private void instancesComboBox_SelectedValueChanged(object sender, System.EventArgs e) {
    98       loadInstanceButton.Enabled = instancesComboBox.SelectedItem != null;
     122      SetEnabledStateOfControls();
    99123    }
    100124
    101125    private void loadInstanceButton_Click(object sender, System.EventArgs e) {
    102       string instance = instancesComboBox.SelectedItem as string;
    103       try {
    104         Content.LoadEmbeddedInstance(instance);
    105       } catch (Exception ex) {
    106         PluginInfrastructure.ErrorHandling.ShowErrorDialog(ex);
    107       }
    108     }
    109 
    110     private void importInstanceButton_Click(object sender, System.EventArgs e) {
     126      ReadOnly = true;
     127      string instanceStr = instancesComboBox.SelectedItem as string;
     128      progressBar.Visible = true;
     129      loadInstanceWorker.RunWorkerAsync(instanceStr);
     130    }
     131
     132    private void importFileInstanceButton_Click(object sender, System.EventArgs e) {
    111133      if (openFileDialog.ShowDialog() == DialogResult.OK) {
    112134        try {
    113           Content.ImportFileInstance(openFileDialog.FileName);
     135          Content.LoadInstanceFromFile(openFileDialog.FileName);
    114136        } catch (Exception ex) {
    115137          PluginInfrastructure.ErrorHandling.ShowErrorDialog(ex);
    116138        }
    117139      }
     140    }
     141
     142    private void reloadInstancesButton_Click(object sender, EventArgs e) {
     143      ReadOnly = true;
     144      progressBar.Visible = true;
     145      getInstancesWorker.RunWorkerAsync();
     146    }
     147
     148    private void loadInstanceWorker_DoWork(object sender, DoWorkEventArgs e) {
     149      string instance = (string)e.Argument;
     150      if (String.IsNullOrEmpty(instance)) return;
     151      using (var client = new QAPClient()) {
     152        loadInstanceWorker.ReportProgress(10);
     153        var data = client.GetProblemInstanceData(instance);
     154        loadInstanceWorker.ReportProgress(60);
     155        DoubleMatrix weights = new DoubleMatrix(data.Weights.Length, data.Weights.Length);
     156        DoubleMatrix distances = new DoubleMatrix(data.Weights.Length, data.Weights.Length);
     157        try {
     158          for (int i = 0; i < data.Weights.Length; i++)
     159            for (int j = 0; j < data.Weights.Length; j++) {
     160              weights[i, j] = data.Weights[i][j];
     161              distances[i, j] = data.Distances[i][j];
     162            }
     163        } catch (IndexOutOfRangeException) {
     164          MessageBox.Show("The problem data is malformed, the problem could not be loaded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     165        }
     166        loadInstanceWorker.ReportProgress(65);
     167        Content.Name = data.Name;
     168        Content.Description = data.Description;
     169        Content.Maximization.Value = data.Maximization;
     170        Content.Weights = weights;
     171        Content.Distances = distances;
     172
     173        Content.BestKnownQualityParameter.Value = null;
     174        Content.BestKnownSolution = null;
     175        Content.BestKnownSolutions = new ItemSet<Permutation>();
     176        var solutions = client.GetBestSolutionsData(instance);
     177        loadInstanceWorker.ReportProgress(90);
     178        if (solutions.Any()) {
     179          Content.BestKnownQualityParameter.Value = new DoubleValue(solutions.First().Quality);
     180          Content.BestKnownSolution = new Permutation(PermutationTypes.Absolute, solutions.First().Assignment);
     181          foreach (var solution in solutions) {
     182            Content.BestKnownSolutions.Add(new Permutation(PermutationTypes.Absolute, solution.Assignment));
     183          }
     184        }
     185        loadInstanceWorker.ReportProgress(100);
     186      }
     187    }
     188
     189    private void getInstancesWorker_DoWork(object sender, DoWorkEventArgs e) {
     190      using (var client = new QAPClient()) {
     191        getInstancesWorker.ReportProgress(10);
     192        var instances = client.GetProblemInstances();
     193        getInstancesWorker.ReportProgress(85);
     194        Content.Instances.Replace(instances);
     195        getInstancesWorker.ReportProgress(100);
     196      }
     197    }
     198
     199    private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) {
     200      progressBar.Value = e.ProgressPercentage;
     201    }
     202
     203    private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
     204      progressBar.Visible = false;
     205      ReadOnly = false;
     206      if (e.Error != null)
     207        PluginInfrastructure.ErrorHandling.ShowErrorDialog(e.Error);
    118208    }
    119209
Note: See TracChangeset for help on using the changeset viewer.