Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5641


Ignore:
Timestamp:
03/09/11 03:23:32 (14 years ago)
Author:
abeham
Message:

#1330

  • worked on visualization (and MDS)
Location:
branches/QAP
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/HeuristicLab.Problems.QuadraticAssignment.Views-3.3.csproj

    r5627 r5641  
    102102  </PropertyGroup>
    103103  <ItemGroup>
    104     <Reference Include="HeuristicLab.Common-3.3">
    105       <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
     104    <Reference Include="ALGLIB-3.1.0, Version=3.1.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86">
     105      <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\ALGLIB-3.1.0.dll</HintPath>
     106    </Reference>
     107    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     108      <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
    106109    </Reference>
    107110    <Reference Include="HeuristicLab.Common.Resources-3.3">
     
    143146  </ItemGroup>
    144147  <ItemGroup>
     148    <Compile Include="MultidimensionalScaling.cs" />
    145149    <Compile Include="QAPAssignmentView.cs">
    146150      <SubType>UserControl</SubType>
     
    148152    <Compile Include="QAPAssignmentView.Designer.cs">
    149153      <DependentUpon>QAPAssignmentView.cs</DependentUpon>
     154    </Compile>
     155    <Compile Include="QAPView.cs">
     156      <SubType>UserControl</SubType>
     157    </Compile>
     158    <Compile Include="QAPView.Designer.cs">
     159      <DependentUpon>QAPView.cs</DependentUpon>
    150160    </Compile>
    151161    <Compile Include="QuadraticAssignmentProblemView.cs">
     
    172182    <EmbeddedResource Include="QAPAssignmentView.resx">
    173183      <DependentUpon>QAPAssignmentView.cs</DependentUpon>
     184    </EmbeddedResource>
     185    <EmbeddedResource Include="QAPView.resx">
     186      <DependentUpon>QAPView.cs</DependentUpon>
    174187    </EmbeddedResource>
    175188    <EmbeddedResource Include="QuadraticAssignmentProblemView.resx">
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.Designer.cs

    r5598 r5641  
    1 namespace HeuristicLab.Problems.QuadraticAssignment.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Problems.QuadraticAssignment.Views {
    223  partial class QAPAssignmentView {
    324    /// <summary>
     
    2950      this.tabControl = new HeuristicLab.MainForm.WindowsForms.DragOverTabControl();
    3051      this.visualizationTabPage = new System.Windows.Forms.TabPage();
     52      this.distancesRadioButton = new System.Windows.Forms.RadioButton();
     53      this.weightsRadioButton = new System.Windows.Forms.RadioButton();
    3154      this.pictureBox = new System.Windows.Forms.PictureBox();
    3255      this.valueTabPage = new System.Windows.Forms.TabPage();
    3356      this.assignmentGroupBox = new System.Windows.Forms.GroupBox();
    3457      this.assignmentViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    35       this.weightsRadioButton = new System.Windows.Forms.RadioButton();
    36       this.distancesRadioButton = new System.Windows.Forms.RadioButton();
     58      this.redrawButton = new System.Windows.Forms.Button();
    3759      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    3860      this.splitContainer.Panel1.SuspendLayout();
     
    110132      // visualizationTabPage
    111133      //
     134      this.visualizationTabPage.Controls.Add(this.redrawButton);
    112135      this.visualizationTabPage.Controls.Add(this.distancesRadioButton);
    113136      this.visualizationTabPage.Controls.Add(this.weightsRadioButton);
     
    121144      this.visualizationTabPage.UseVisualStyleBackColor = true;
    122145      //
     146      // distancesRadioButton
     147      //
     148      this.distancesRadioButton.AutoSize = true;
     149      this.distancesRadioButton.Checked = true;
     150      this.distancesRadioButton.Location = new System.Drawing.Point(6, 6);
     151      this.distancesRadioButton.Name = "distancesRadioButton";
     152      this.distancesRadioButton.Size = new System.Drawing.Size(72, 17);
     153      this.distancesRadioButton.TabIndex = 2;
     154      this.distancesRadioButton.TabStop = true;
     155      this.distancesRadioButton.Text = "Distances";
     156      this.distancesRadioButton.UseVisualStyleBackColor = true;
     157      this.distancesRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
     158      //
     159      // weightsRadioButton
     160      //
     161      this.weightsRadioButton.AutoSize = true;
     162      this.weightsRadioButton.Location = new System.Drawing.Point(6, 29);
     163      this.weightsRadioButton.Name = "weightsRadioButton";
     164      this.weightsRadioButton.Size = new System.Drawing.Size(64, 17);
     165      this.weightsRadioButton.TabIndex = 1;
     166      this.weightsRadioButton.Text = "Weights";
     167      this.weightsRadioButton.UseVisualStyleBackColor = true;
     168      this.weightsRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
     169      //
    123170      // pictureBox
    124171      //
     
    175222      this.assignmentViewHost.ViewType = null;
    176223      //
    177       // weightsRadioButton
    178       //
    179       this.weightsRadioButton.AutoSize = true;
    180       this.weightsRadioButton.Location = new System.Drawing.Point(6, 29);
    181       this.weightsRadioButton.Name = "weightsRadioButton";
    182       this.weightsRadioButton.Size = new System.Drawing.Size(64, 17);
    183       this.weightsRadioButton.TabIndex = 1;
    184       this.weightsRadioButton.Text = "Weights";
    185       this.weightsRadioButton.UseVisualStyleBackColor = true;
    186       this.weightsRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
    187       //
    188       // distancesRadioButton
    189       //
    190       this.distancesRadioButton.AutoSize = true;
    191       this.distancesRadioButton.Checked = true;
    192       this.distancesRadioButton.Location = new System.Drawing.Point(6, 6);
    193       this.distancesRadioButton.Name = "distancesRadioButton";
    194       this.distancesRadioButton.Size = new System.Drawing.Size(72, 17);
    195       this.distancesRadioButton.TabIndex = 2;
    196       this.distancesRadioButton.TabStop = true;
    197       this.distancesRadioButton.Text = "Distances";
    198       this.distancesRadioButton.UseVisualStyleBackColor = true;
    199       this.distancesRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
     224      // redrawButton
     225      //
     226      this.redrawButton.Location = new System.Drawing.Point(4, 53);
     227      this.redrawButton.Name = "redrawButton";
     228      this.redrawButton.Size = new System.Drawing.Size(74, 23);
     229      this.redrawButton.TabIndex = 3;
     230      this.redrawButton.Text = "Redraw";
     231      this.redrawButton.UseVisualStyleBackColor = true;
     232      this.redrawButton.Click += new System.EventHandler(this.redrawButton_Click);
    200233      //
    201234      // QAPAssignmentView
     
    234267    private System.Windows.Forms.RadioButton distancesRadioButton;
    235268    private System.Windows.Forms.RadioButton weightsRadioButton;
     269    private System.Windows.Forms.Button redrawButton;
    236270  }
    237271}
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs

    r5598 r5641  
    7878      pictureBox.Enabled = Content != null;
    7979      assignmentGroupBox.Enabled = Content != null;
     80      distancesRadioButton.Enabled = Content != null;
     81      weightsRadioButton.Enabled = Content != null;
     82      redrawButton.Enabled = Content != null;
    8083    }
    8184
     
    8790          bitmap = null;
    8891        } else {
    89           Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
    9092          bool drawDistances = distancesRadioButton.Checked;
    9193          DoubleMatrix coordinates = Content.Coordinates;
     
    9496          if ((coordinates == null || coordinates.Rows == 0)
    9597            && (distances == null || distances.Rows == 0)) {
     98            Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
    9699            using (Graphics g = Graphics.FromImage(newBitmap)) {
    97100              string str = "No coordinates and no distance matrix specified.";
     
    99102              g.DrawString(str, Font, Brushes.Black, (float)(newBitmap.Width - strSize.Width) / 2.0f, (float)(newBitmap.Height - strSize.Height) / 2.0f);
    100103            }
     104            pictureBox.Image = newBitmap;
     105            if (bitmap != null) bitmap.Dispose();
     106            bitmap = newBitmap;
    101107          } else {
    102108            if ((coordinates == null || coordinates.Rows == 0)
    103109              && Content.ViewCoordinates == null) {
    104               coordinates = new DoubleMatrix(distances.Rows, 2);
    105               double rad = (2 * Math.PI) / coordinates.Rows;
    106               for (int i = 0; i < coordinates.Rows; i++) {
    107                 coordinates[i, 0] = 10 * Math.Cos(rad * i);
    108                 coordinates[i, 1] = 10 * Math.Sin(rad * i);
    109               }
     110              coordinates = GetCoordinatesByMDS(distances);
    110111              Content.ViewCoordinates = coordinates;
    111112            } else if ((coordinates == null || coordinates.Rows == 0)
     
    117118            Permutation assignment = Content.Assignment;
    118119
    119             double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
    120             double maxWeight = double.MinValue, maxDistance = double.MinValue;
    121             for (int i = 0; i < coordinates.Rows; i++) {
    122               if (xMin > coordinates[i, 0]) xMin = coordinates[i, 0];
    123               if (yMin > coordinates[i, 1]) yMin = coordinates[i, 1];
    124               if (xMax < coordinates[i, 0]) xMax = coordinates[i, 0];
    125               if (yMax < coordinates[i, 1]) yMax = coordinates[i, 1];
    126 
    127               for (int j = i + 1; j < coordinates.Rows; j++) {
    128                 if (weights[i, j] + weights[j, i] > maxWeight)
    129                   maxWeight = weights[i, j] + weights[j, i];
    130 
    131                 if (distances[i, j] > maxDistance)
    132                   maxDistance = distances[i, j];
    133                 else if (distances[j, i] > maxDistance)
    134                   maxDistance = distances[j, i];
    135               }
    136             }
    137 
    138             int border = 20;
    139             double xStep = xMax != xMin ? (pictureBox.Width - 2 * border) / (xMax - xMin) : 1;
    140             double yStep = yMax != yMin ? (pictureBox.Height - 2 * border) / (yMax - yMin) : 1;
    141 
    142             Point[] points = new Point[coordinates.Rows];
    143             for (int i = 0; i < coordinates.Rows; i++)
    144               points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)),
    145                                     newBitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));
    146 
    147             Random rand = new Random();
    148             using (Graphics graphics = Graphics.FromImage(newBitmap)) {
    149               graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    150               graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
    151               if ((assignment != null) && (assignment.Length == coordinates.Rows) && (assignment.Validate())) {
    152                 for (int i = 0; i < assignment.Length - 1; i++) {
    153                   for (int j = i + 1; j < assignment.Length; j++) {
    154                     Point start = points[assignment[i]], end = points[assignment[j]];
    155                     string caption = String.Empty;
    156                     double d = Math.Max(distances[i, j], distances[j, i]);
    157                     if (drawDistances) {
    158                       float width = (float)Math.Ceiling(5.0 * d / maxDistance);
    159                       graphics.DrawLine(new Pen(Color.IndianRed, width), start, end);
    160                       if (distances[i, j] != distances[j, i])
    161                         caption = distances[i, j].ToString(CultureInfo.InvariantCulture.NumberFormat)
    162                           + " / " + distances[j, i].ToString(CultureInfo.InvariantCulture.NumberFormat);
    163                       else
    164                         caption = distances[i, j].ToString(CultureInfo.InvariantCulture.NumberFormat);
    165                     } else {
    166                       double w = weights[i, j] + weights[j, i];
    167                       if (w > 0) {
    168                         float width = (float)Math.Ceiling(5.0 * w / maxWeight);
    169                         graphics.DrawLine(new Pen(Color.MediumBlue, width), start, end);
    170                         caption = w.ToString(CultureInfo.InvariantCulture.NumberFormat);
    171                       }
    172                       if (!String.IsNullOrEmpty(caption)) {
    173                         double r = rand.NextDouble();
    174                         while (r < 0.2 || r > 0.8) r = rand.NextDouble();
    175                         float x = (float)(start.X + (end.X - start.X) * r + 5);
    176                         float y = (float)(start.Y + (end.Y - start.Y) * r + 5);
    177                         graphics.DrawString(caption, Font, Brushes.Black, x, y);
    178                       }
    179                     }
    180                   }
     120            GenerateImage(drawDistances, coordinates, distances, weights, assignment);
     121          }
     122        }
     123      }
     124    }
     125
     126    private void GenerateImage(bool drawDistances, DoubleMatrix coordinates, DoubleMatrix distances, DoubleMatrix weights, Permutation assignment) {
     127      Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
     128      double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
     129      double maxWeight = double.MinValue, maxDistance = double.MinValue;
     130      for (int i = 0; i < coordinates.Rows; i++) {
     131        if (xMin > coordinates[i, 0]) xMin = coordinates[i, 0];
     132        if (yMin > coordinates[i, 1]) yMin = coordinates[i, 1];
     133        if (xMax < coordinates[i, 0]) xMax = coordinates[i, 0];
     134        if (yMax < coordinates[i, 1]) yMax = coordinates[i, 1];
     135
     136        for (int j = i + 1; j < coordinates.Rows; j++) {
     137          if (weights[i, j] + weights[j, i] > maxWeight)
     138            maxWeight = weights[i, j] + weights[j, i];
     139
     140          if (distances[i, j] > maxDistance)
     141            maxDistance = distances[i, j];
     142          else if (distances[j, i] > maxDistance)
     143            maxDistance = distances[j, i];
     144        }
     145      }
     146
     147      int border = 20;
     148      double xStep = xMax != xMin ? (pictureBox.Width - 2 * border) / (xMax - xMin) : 1;
     149      double yStep = yMax != yMin ? (pictureBox.Height - 2 * border) / (yMax - yMin) : 1;
     150
     151      Point[] points = new Point[coordinates.Rows];
     152      for (int i = 0; i < coordinates.Rows; i++)
     153        points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)),
     154                              newBitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));
     155
     156      Random rand = new Random();
     157      using (Graphics graphics = Graphics.FromImage(newBitmap)) {
     158        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
     159        graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
     160        if ((assignment != null) && (assignment.Length == coordinates.Rows) && (assignment.Validate())) {
     161          for (int i = 0; i < assignment.Length - 1; i++) {
     162            for (int j = i + 1; j < assignment.Length; j++) {
     163              Point start, end;
     164              string caption = String.Empty;
     165              double d = Math.Max(distances[i, j], distances[j, i]);
     166              if (drawDistances) {
     167                start = points[i];
     168                end = points[j];
     169                float width = (float)Math.Ceiling(5.0 * d / maxDistance);
     170                graphics.DrawLine(new Pen(Color.IndianRed, width), start, end);
     171                if (distances[i, j] != distances[j, i])
     172                  caption = distances[i, j].ToString(CultureInfo.InvariantCulture.NumberFormat)
     173                    + " / " + distances[j, i].ToString(CultureInfo.InvariantCulture.NumberFormat);
     174                else
     175                  caption = distances[i, j].ToString(CultureInfo.InvariantCulture.NumberFormat);
     176              } else {
     177                start = points[assignment[i]];
     178                end = points[assignment[j]];
     179                double w = weights[i, j] + weights[j, i];
     180                if (w > 0) {
     181                  float width = (float)Math.Ceiling(5.0 * w / maxWeight);
     182                  graphics.DrawLine(new Pen(Color.MediumBlue, width), start, end);
     183                  caption = w.ToString(CultureInfo.InvariantCulture.NumberFormat);
     184                }
     185                if (!String.IsNullOrEmpty(caption)) {
     186                  double r = rand.NextDouble();
     187                  while (r < 0.2 || r > 0.8) r = rand.NextDouble();
     188                  float x = (float)(start.X + (end.X - start.X) * r + 5);
     189                  float y = (float)(start.Y + (end.Y - start.Y) * r + 5);
     190                  graphics.DrawString(caption, Font, Brushes.Black, x, y);
    181191                }
    182192              }
    183               for (int i = 0; i < points.Length; i++) {
    184                 Point p = new Point(points[assignment[i]].X - 3, points[assignment[i]].Y - 3);
    185                 graphics.FillRectangle(Brushes.Black, p.X, p.Y, 8, 8);
    186                 graphics.DrawString(i.ToString(), Font, Brushes.Black, p.X, p.Y + 10);
    187               }
    188193            }
    189194          }
    190           pictureBox.Image = newBitmap;
    191           if (bitmap != null) bitmap.Dispose();
    192           bitmap = newBitmap;
    193         }
    194       }
     195        }
     196        for (int i = 0; i < points.Length; i++) {
     197          Point p = new Point(points[assignment[i]].X - 3, points[assignment[i]].Y - 3);
     198          graphics.FillRectangle(Brushes.Black, p.X, p.Y, 8, 8);
     199          graphics.DrawString(i.ToString(), Font, Brushes.Black, p.X, p.Y + 10);
     200        }
     201      }
     202      pictureBox.Image = newBitmap;
     203      if (bitmap != null) bitmap.Dispose();
     204      bitmap = newBitmap;
     205    }
     206
     207    private DoubleMatrix GetCoordinatesByMDS(DoubleMatrix distances) {
     208      /*Random random = new Random();
     209      int points = distances.Rows;
     210      DoubleMatrix coordinates = new DoubleMatrix(points, 2);
     211      double rad = (2 * Math.PI) / coordinates.Rows;
     212      for (int i = 0; i < coordinates.Rows; i++) {
     213        coordinates[i, 0] = 10 * Math.Cos(rad * i);
     214        coordinates[i, 1] = 10 * Math.Sin(rad * i);
     215      }
     216      for (int iterations = 0; iterations < 1000; iterations++) {
     217        for (int i = 0; i < points; i++) {
     218          double x = coordinates[i, 0], y = coordinates[i, 1];
     219          for (int j = 0; j < points; j++) {
     220            if (i != j) {
     221              double dx = coordinates[i, 0] - coordinates[j, 0];
     222              double dy = coordinates[i, 1] - coordinates[j, 1];
     223              double l = Math.Sqrt(dx * dx + dy * dy);
     224              double dl = distances[i, j];
     225              if (Math.Abs(dx) < double.Epsilon) dx = random.NextDouble() + 1;
     226              if (Math.Abs(dy) < double.Epsilon) dy = random.NextDouble() + 1;
     227              x += random.NextDouble() * ((coordinates[j, 0] + (dx / l) * dl) - x);
     228              y += random.NextDouble() * ((coordinates[j, 1] + (dy / l) * dl) - y);
     229            }
     230          }
     231          coordinates[i, 0] = x;
     232          coordinates[i, 1] = y;
     233        }
     234        Content.ViewCoordinates = coordinates;
     235      }
     236      return coordinates;*/
     237      double error;
     238      return MultidimensionalScaling.Classic(distances, out error);
    195239    }
    196240
     
    211255          case "Quality":
    212256            break;
     257          case "ViewCoordinates":
     258            if (Content.ViewCoordinates != null)
     259              GenerateImage(distancesRadioButton.Checked, Content.ViewCoordinates, Content.Distances, Content.Weights, Content.Assignment);
     260            break;
    213261          default:
    214262            break;
     
    224272      GenerateImage();
    225273    }
     274
     275    private void redrawButton_Click(object sender, EventArgs e) {
     276      Content.ViewCoordinates = null;
     277      GenerateImage();
     278    }
    226279  }
    227280}
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.Designer.cs

    r5583 r5641  
    5050      this.instancesComboBox = new System.Windows.Forms.ComboBox();
    5151      this.loadInstanceButton = new System.Windows.Forms.Button();
     52      this.tabControl = new System.Windows.Forms.TabControl();
     53      this.problemTabPage = new System.Windows.Forms.TabPage();
     54      this.visualizationTabPage = new System.Windows.Forms.TabPage();
     55      this.qapView = new HeuristicLab.Problems.QuadraticAssignment.Views.QAPView();
    5256      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     57      this.tabControl.SuspendLayout();
     58      this.visualizationTabPage.SuspendLayout();
    5359      this.SuspendLayout();
    5460      //
    5561      // parameterCollectionView
    5662      //
    57       this.parameterCollectionView.Location = new System.Drawing.Point(0, 81);
    58       this.parameterCollectionView.Size = new System.Drawing.Size(490, 272);
     63      this.parameterCollectionView.Location = new System.Drawing.Point(8, 107);
     64      this.parameterCollectionView.Size = new System.Drawing.Size(629, 375);
    5965      //
    6066      // nameTextBox
     
    6369      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    6470      this.nameTextBox.Location = new System.Drawing.Point(86, 29);
    65       this.nameTextBox.Size = new System.Drawing.Size(404, 20);
     71      this.nameTextBox.Size = new System.Drawing.Size(561, 20);
    6672      //
    6773      // nameLabel
     
    7682      //
    7783      this.descriptionTextBox.Location = new System.Drawing.Point(86, 55);
    78       this.descriptionTextBox.Size = new System.Drawing.Size(404, 20);
     84      this.descriptionTextBox.Size = new System.Drawing.Size(561, 20);
    7985      //
    8086      // importInstanceButton
    8187      //
    8288      this.importInstanceButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    83       this.importInstanceButton.Location = new System.Drawing.Point(391, 0);
     89      this.importInstanceButton.Location = new System.Drawing.Point(548, 0);
    8490      this.importInstanceButton.Name = "importInstanceButton";
    8591      this.importInstanceButton.Size = new System.Drawing.Size(99, 23);
     
    117123      this.instancesComboBox.Location = new System.Drawing.Point(105, 2);
    118124      this.instancesComboBox.Name = "instancesComboBox";
    119       this.instancesComboBox.Size = new System.Drawing.Size(201, 21);
     125      this.instancesComboBox.Size = new System.Drawing.Size(358, 21);
    120126      this.instancesComboBox.TabIndex = 7;
    121127      this.instancesComboBox.SelectedValueChanged += new System.EventHandler(this.instancesComboBox_SelectedValueChanged);
     
    124130      //
    125131      this.loadInstanceButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    126       this.loadInstanceButton.Location = new System.Drawing.Point(312, 0);
     132      this.loadInstanceButton.Location = new System.Drawing.Point(469, 0);
    127133      this.loadInstanceButton.Name = "loadInstanceButton";
    128134      this.loadInstanceButton.Size = new System.Drawing.Size(73, 23);
     
    134140      this.loadInstanceButton.Click += new System.EventHandler(this.loadInstanceButton_Click);
    135141      //
     142      // tabControl
     143      //
     144      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     145                  | System.Windows.Forms.AnchorStyles.Left)
     146                  | System.Windows.Forms.AnchorStyles.Right)));
     147      this.tabControl.Controls.Add(this.problemTabPage);
     148      this.tabControl.Controls.Add(this.visualizationTabPage);
     149      this.tabControl.Location = new System.Drawing.Point(0, 81);
     150      this.tabControl.Name = "tabControl";
     151      this.tabControl.SelectedIndex = 0;
     152      this.tabControl.Size = new System.Drawing.Size(647, 411);
     153      this.tabControl.TabIndex = 8;
     154      //
     155      // problemTabPage
     156      //
     157      this.problemTabPage.Location = new System.Drawing.Point(4, 22);
     158      this.problemTabPage.Name = "problemTabPage";
     159      this.problemTabPage.Padding = new System.Windows.Forms.Padding(3);
     160      this.problemTabPage.Size = new System.Drawing.Size(639, 385);
     161      this.problemTabPage.TabIndex = 0;
     162      this.problemTabPage.Text = "Problem";
     163      this.problemTabPage.UseVisualStyleBackColor = true;
     164      //
     165      // visualizationTabPage
     166      //
     167      this.visualizationTabPage.Controls.Add(this.qapView);
     168      this.visualizationTabPage.Location = new System.Drawing.Point(4, 22);
     169      this.visualizationTabPage.Name = "visualizationTabPage";
     170      this.visualizationTabPage.Padding = new System.Windows.Forms.Padding(3);
     171      this.visualizationTabPage.Size = new System.Drawing.Size(639, 385);
     172      this.visualizationTabPage.TabIndex = 1;
     173      this.visualizationTabPage.Text = "Visualization";
     174      this.visualizationTabPage.UseVisualStyleBackColor = true;
     175      //
     176      // qapView
     177      //
     178      this.qapView.Assignment = null;
     179      this.qapView.Distances = null;
     180      this.qapView.Dock = System.Windows.Forms.DockStyle.Fill;
     181      this.qapView.Location = new System.Drawing.Point(3, 3);
     182      this.qapView.Name = "qapView";
     183      this.qapView.Size = new System.Drawing.Size(633, 379);
     184      this.qapView.TabIndex = 0;
     185      this.qapView.Weights = null;
     186      //
    136187      // QuadraticAssignmentProblemView
    137188      //
     
    139190      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    140191      this.Controls.Add(this.instancesComboBox);
     192      this.Controls.Add(this.tabControl);
    141193      this.Controls.Add(this.importInstanceButton);
    142194      this.Controls.Add(this.loadInstanceButton);
    143195      this.Controls.Add(this.QAPLIBInstancesLabel);
    144196      this.Name = "QuadraticAssignmentProblemView";
     197      this.Size = new System.Drawing.Size(647, 492);
     198      this.Controls.SetChildIndex(this.parameterCollectionView, 0);
    145199      this.Controls.SetChildIndex(this.descriptionLabel, 0);
    146200      this.Controls.SetChildIndex(this.nameLabel, 0);
     
    150204      this.Controls.SetChildIndex(this.loadInstanceButton, 0);
    151205      this.Controls.SetChildIndex(this.importInstanceButton, 0);
     206      this.Controls.SetChildIndex(this.tabControl, 0);
    152207      this.Controls.SetChildIndex(this.instancesComboBox, 0);
    153       this.Controls.SetChildIndex(this.parameterCollectionView, 0);
    154208      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     209      this.tabControl.ResumeLayout(false);
     210      this.visualizationTabPage.ResumeLayout(false);
    155211      this.ResumeLayout(false);
    156212      this.PerformLayout();
     
    165221    private System.Windows.Forms.ComboBox instancesComboBox;
    166222    private System.Windows.Forms.Button loadInstanceButton;
     223    private System.Windows.Forms.TabControl tabControl;
     224    private System.Windows.Forms.TabPage problemTabPage;
     225    private System.Windows.Forms.TabPage visualizationTabPage;
     226    private QAPView qapView;
    167227  }
    168228}
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.cs

    r5583 r5641  
    2020#endregion
    2121
     22using System;
    2223using System.Windows.Forms;
    2324using HeuristicLab.Common.Resources;
     
    3839      InitializeComponent();
    3940      importInstanceButton.Image = VSImageLibrary.Open;
     41      Controls.Remove(parameterCollectionView);
     42      parameterCollectionView.Dock = DockStyle.Fill;
     43      problemTabPage.Controls.Add(parameterCollectionView);
     44    }
     45
     46    protected override void RegisterContentEvents() {
     47      base.RegisterContentEvents();
     48      Content.DistanceMatrixParameter.ValueChanged += new EventHandler(DistanceMatrixParameter_ValueChanged);
     49      Content.WeightsParameter.ValueChanged += new EventHandler(WeightsParameter_ValueChanged);
     50      Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
     51    }
     52
     53    protected override void DeregisterContentEvents() {
     54      Content.DistanceMatrixParameter.ValueChanged -= new EventHandler(DistanceMatrixParameter_ValueChanged);
     55      Content.WeightsParameter.ValueChanged -= new EventHandler(WeightsParameter_ValueChanged);
     56      Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged);
     57      base.DeregisterContentEvents();
     58    }
     59
     60    private void DistanceMatrixParameter_ValueChanged(object sender, System.EventArgs e) {
     61      qapView.Distances = Content.DistanceMatrix;
     62    }
     63
     64    private void WeightsParameter_ValueChanged(object sender, System.EventArgs e) {
     65      qapView.Weights = Content.Weights;
     66    }
     67
     68    private void BestKnownSolutionParameter_ValueChanged(object sender, System.EventArgs e) {
     69      qapView.Assignment = Content.BestKnownSolution;
    4070    }
    4171
     
    4777          instancesComboBox.Items.Add(instance);
    4878        }
     79        qapView.Distances = Content.DistanceMatrix;
     80        qapView.Weights = Content.Weights;
     81        qapView.Assignment = Content.BestKnownSolution;
     82      } else {
     83        qapView.Distances = null;
     84        qapView.Weights = null;
     85        qapView.Assignment = null;
    4986      }
    5087    }
     
    63100    private void loadInstanceButton_Click(object sender, System.EventArgs e) {
    64101      string instance = instancesComboBox.SelectedItem as string;
    65       Content.LoadEmbeddedInstance(instance);
     102      try {
     103        Content.LoadEmbeddedInstance(instance);
     104      } catch (Exception ex) {
     105        PluginInfrastructure.ErrorHandling.ShowErrorDialog(ex);
     106      }
    66107    }
    67108
    68109    private void importInstanceButton_Click(object sender, System.EventArgs e) {
    69110      if (openFileDialog.ShowDialog() == DialogResult.OK) {
    70         Content.ImportFileInstance(openFileDialog.FileName);
     111        try {
     112          Content.ImportFileInstance(openFileDialog.FileName);
     113        } catch (Exception ex) {
     114          PluginInfrastructure.ErrorHandling.ShowErrorDialog(ex);
     115        }
    71116      }
    72117    }
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs

    r5583 r5641  
    2121    }
    2222
    23     public DoubleMatrix ViewCoordinates { get; set; }
     23    [Storable]
     24    private DoubleMatrix viewCoordinates;
     25    public DoubleMatrix ViewCoordinates {
     26      get { return viewCoordinates; }
     27      set {
     28        bool changed = (viewCoordinates != value);
     29        viewCoordinates = value;
     30        if (changed) OnPropertyChanged("ViewCoordinates");
     31      }
     32    }
    2433
    2534    [Storable]
     
    7685      assignment = cloner.Clone(original.assignment);
    7786      quality = cloner.Clone(original.quality);
     87      viewCoordinates = cloner.Clone(original.viewCoordinates);
    7888    }
    7989    public QAPAssignment(DoubleMatrix weights, Permutation assignment) {
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs

    r5598 r5641  
    4747
    4848    #region Parameter Properties
    49     public ValueParameter<Permutation> BestKnownSolutionParameter {
    50       get { return (ValueParameter<Permutation>)Parameters["BestKnownSolution"]; }
    51     }
    52     public ValueParameter<DoubleMatrix> CoordinatesParameter {
    53       get { return (ValueParameter<DoubleMatrix>)Parameters["Coordinates"]; }
    54     }
    55     public ValueParameter<DoubleMatrix> WeightsParameter {
    56       get { return (ValueParameter<DoubleMatrix>)Parameters["Weights"]; }
    57     }
    58     public ValueParameter<DoubleMatrix> DistanceMatrixParameter {
    59       get { return (ValueParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
     49    public IValueParameter<Permutation> BestKnownSolutionParameter {
     50      get { return (IValueParameter<Permutation>)Parameters["BestKnownSolution"]; }
     51    }
     52    public IValueParameter<DoubleMatrix> CoordinatesParameter {
     53      get { return (IValueParameter<DoubleMatrix>)Parameters["Coordinates"]; }
     54    }
     55    public IValueParameter<DoubleMatrix> WeightsParameter {
     56      get { return (IValueParameter<DoubleMatrix>)Parameters["Weights"]; }
     57    }
     58    public IValueParameter<DoubleMatrix> DistanceMatrixParameter {
     59      get { return (IValueParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
    6060    }
    6161    #endregion
     
    288288      QAPLIBParser parser = new QAPLIBParser();
    289289      parser.Parse(filename);
     290      if (parser.Error != null) throw parser.Error;
    290291      Coordinates = new DoubleMatrix();
    291292      DistanceMatrix = new DoubleMatrix(parser.Distances);
     
    303304        QAPLIBParser parser = new QAPLIBParser();
    304305        parser.Parse(stream);
     306        if (parser.Error != null) throw parser.Error;
    305307        Coordinates = new DoubleMatrix();
    306308        DistanceMatrix = new DoubleMatrix(parser.Distances);
     
    319321          QAPLIBSolutionParser solParser = new QAPLIBSolutionParser();
    320322          solParser.Parse(solStream);
     323          if (solParser.Error != null) throw solParser.Error;
    321324          BestKnownQuality = new DoubleValue(solParser.Qualiy);
    322325          BestKnownSolution = new Permutation(PermutationTypes.Absolute, solParser.Assignment);
Note: See TracChangeset for help on using the changeset viewer.