Changeset 5641
- Timestamp:
- 03/09/11 03:23:32 (14 years ago)
- 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 102 102 </PropertyGroup> 103 103 <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> 106 109 </Reference> 107 110 <Reference Include="HeuristicLab.Common.Resources-3.3"> … … 143 146 </ItemGroup> 144 147 <ItemGroup> 148 <Compile Include="MultidimensionalScaling.cs" /> 145 149 <Compile Include="QAPAssignmentView.cs"> 146 150 <SubType>UserControl</SubType> … … 148 152 <Compile Include="QAPAssignmentView.Designer.cs"> 149 153 <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> 150 160 </Compile> 151 161 <Compile Include="QuadraticAssignmentProblemView.cs"> … … 172 182 <EmbeddedResource Include="QAPAssignmentView.resx"> 173 183 <DependentUpon>QAPAssignmentView.cs</DependentUpon> 184 </EmbeddedResource> 185 <EmbeddedResource Include="QAPView.resx"> 186 <DependentUpon>QAPView.cs</DependentUpon> 174 187 </EmbeddedResource> 175 188 <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 22 namespace HeuristicLab.Problems.QuadraticAssignment.Views { 2 23 partial class QAPAssignmentView { 3 24 /// <summary> … … 29 50 this.tabControl = new HeuristicLab.MainForm.WindowsForms.DragOverTabControl(); 30 51 this.visualizationTabPage = new System.Windows.Forms.TabPage(); 52 this.distancesRadioButton = new System.Windows.Forms.RadioButton(); 53 this.weightsRadioButton = new System.Windows.Forms.RadioButton(); 31 54 this.pictureBox = new System.Windows.Forms.PictureBox(); 32 55 this.valueTabPage = new System.Windows.Forms.TabPage(); 33 56 this.assignmentGroupBox = new System.Windows.Forms.GroupBox(); 34 57 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(); 37 59 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 38 60 this.splitContainer.Panel1.SuspendLayout(); … … 110 132 // visualizationTabPage 111 133 // 134 this.visualizationTabPage.Controls.Add(this.redrawButton); 112 135 this.visualizationTabPage.Controls.Add(this.distancesRadioButton); 113 136 this.visualizationTabPage.Controls.Add(this.weightsRadioButton); … … 121 144 this.visualizationTabPage.UseVisualStyleBackColor = true; 122 145 // 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 // 123 170 // pictureBox 124 171 // … … 175 222 this.assignmentViewHost.ViewType = null; 176 223 // 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); 200 233 // 201 234 // QAPAssignmentView … … 234 267 private System.Windows.Forms.RadioButton distancesRadioButton; 235 268 private System.Windows.Forms.RadioButton weightsRadioButton; 269 private System.Windows.Forms.Button redrawButton; 236 270 } 237 271 } -
branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs
r5598 r5641 78 78 pictureBox.Enabled = Content != null; 79 79 assignmentGroupBox.Enabled = Content != null; 80 distancesRadioButton.Enabled = Content != null; 81 weightsRadioButton.Enabled = Content != null; 82 redrawButton.Enabled = Content != null; 80 83 } 81 84 … … 87 90 bitmap = null; 88 91 } else { 89 Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);90 92 bool drawDistances = distancesRadioButton.Checked; 91 93 DoubleMatrix coordinates = Content.Coordinates; … … 94 96 if ((coordinates == null || coordinates.Rows == 0) 95 97 && (distances == null || distances.Rows == 0)) { 98 Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height); 96 99 using (Graphics g = Graphics.FromImage(newBitmap)) { 97 100 string str = "No coordinates and no distance matrix specified."; … … 99 102 g.DrawString(str, Font, Brushes.Black, (float)(newBitmap.Width - strSize.Width) / 2.0f, (float)(newBitmap.Height - strSize.Height) / 2.0f); 100 103 } 104 pictureBox.Image = newBitmap; 105 if (bitmap != null) bitmap.Dispose(); 106 bitmap = newBitmap; 101 107 } else { 102 108 if ((coordinates == null || coordinates.Rows == 0) 103 109 && 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); 110 111 Content.ViewCoordinates = coordinates; 111 112 } else if ((coordinates == null || coordinates.Rows == 0) … … 117 118 Permutation assignment = Content.Assignment; 118 119 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); 181 191 } 182 192 } 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 }188 193 } 189 194 } 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); 195 239 } 196 240 … … 211 255 case "Quality": 212 256 break; 257 case "ViewCoordinates": 258 if (Content.ViewCoordinates != null) 259 GenerateImage(distancesRadioButton.Checked, Content.ViewCoordinates, Content.Distances, Content.Weights, Content.Assignment); 260 break; 213 261 default: 214 262 break; … … 224 272 GenerateImage(); 225 273 } 274 275 private void redrawButton_Click(object sender, EventArgs e) { 276 Content.ViewCoordinates = null; 277 GenerateImage(); 278 } 226 279 } 227 280 } -
branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.Designer.cs
r5583 r5641 50 50 this.instancesComboBox = new System.Windows.Forms.ComboBox(); 51 51 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(); 52 56 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 57 this.tabControl.SuspendLayout(); 58 this.visualizationTabPage.SuspendLayout(); 53 59 this.SuspendLayout(); 54 60 // 55 61 // parameterCollectionView 56 62 // 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); 59 65 // 60 66 // nameTextBox … … 63 69 this.errorProvider.SetIconPadding(this.nameTextBox, 2); 64 70 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); 66 72 // 67 73 // nameLabel … … 76 82 // 77 83 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); 79 85 // 80 86 // importInstanceButton 81 87 // 82 88 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); 84 90 this.importInstanceButton.Name = "importInstanceButton"; 85 91 this.importInstanceButton.Size = new System.Drawing.Size(99, 23); … … 117 123 this.instancesComboBox.Location = new System.Drawing.Point(105, 2); 118 124 this.instancesComboBox.Name = "instancesComboBox"; 119 this.instancesComboBox.Size = new System.Drawing.Size( 201, 21);125 this.instancesComboBox.Size = new System.Drawing.Size(358, 21); 120 126 this.instancesComboBox.TabIndex = 7; 121 127 this.instancesComboBox.SelectedValueChanged += new System.EventHandler(this.instancesComboBox_SelectedValueChanged); … … 124 130 // 125 131 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); 127 133 this.loadInstanceButton.Name = "loadInstanceButton"; 128 134 this.loadInstanceButton.Size = new System.Drawing.Size(73, 23); … … 134 140 this.loadInstanceButton.Click += new System.EventHandler(this.loadInstanceButton_Click); 135 141 // 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 // 136 187 // QuadraticAssignmentProblemView 137 188 // … … 139 190 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 140 191 this.Controls.Add(this.instancesComboBox); 192 this.Controls.Add(this.tabControl); 141 193 this.Controls.Add(this.importInstanceButton); 142 194 this.Controls.Add(this.loadInstanceButton); 143 195 this.Controls.Add(this.QAPLIBInstancesLabel); 144 196 this.Name = "QuadraticAssignmentProblemView"; 197 this.Size = new System.Drawing.Size(647, 492); 198 this.Controls.SetChildIndex(this.parameterCollectionView, 0); 145 199 this.Controls.SetChildIndex(this.descriptionLabel, 0); 146 200 this.Controls.SetChildIndex(this.nameLabel, 0); … … 150 204 this.Controls.SetChildIndex(this.loadInstanceButton, 0); 151 205 this.Controls.SetChildIndex(this.importInstanceButton, 0); 206 this.Controls.SetChildIndex(this.tabControl, 0); 152 207 this.Controls.SetChildIndex(this.instancesComboBox, 0); 153 this.Controls.SetChildIndex(this.parameterCollectionView, 0);154 208 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 209 this.tabControl.ResumeLayout(false); 210 this.visualizationTabPage.ResumeLayout(false); 155 211 this.ResumeLayout(false); 156 212 this.PerformLayout(); … … 165 221 private System.Windows.Forms.ComboBox instancesComboBox; 166 222 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; 167 227 } 168 228 } -
branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.cs
r5583 r5641 20 20 #endregion 21 21 22 using System; 22 23 using System.Windows.Forms; 23 24 using HeuristicLab.Common.Resources; … … 38 39 InitializeComponent(); 39 40 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; 40 70 } 41 71 … … 47 77 instancesComboBox.Items.Add(instance); 48 78 } 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; 49 86 } 50 87 } … … 63 100 private void loadInstanceButton_Click(object sender, System.EventArgs e) { 64 101 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 } 66 107 } 67 108 68 109 private void importInstanceButton_Click(object sender, System.EventArgs e) { 69 110 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 } 71 116 } 72 117 } -
branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs
r5583 r5641 21 21 } 22 22 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 } 24 33 25 34 [Storable] … … 76 85 assignment = cloner.Clone(original.assignment); 77 86 quality = cloner.Clone(original.quality); 87 viewCoordinates = cloner.Clone(original.viewCoordinates); 78 88 } 79 89 public QAPAssignment(DoubleMatrix weights, Permutation assignment) { -
branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
r5598 r5641 47 47 48 48 #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"]; } 60 60 } 61 61 #endregion … … 288 288 QAPLIBParser parser = new QAPLIBParser(); 289 289 parser.Parse(filename); 290 if (parser.Error != null) throw parser.Error; 290 291 Coordinates = new DoubleMatrix(); 291 292 DistanceMatrix = new DoubleMatrix(parser.Distances); … … 303 304 QAPLIBParser parser = new QAPLIBParser(); 304 305 parser.Parse(stream); 306 if (parser.Error != null) throw parser.Error; 305 307 Coordinates = new DoubleMatrix(); 306 308 DistanceMatrix = new DoubleMatrix(parser.Distances); … … 319 321 QAPLIBSolutionParser solParser = new QAPLIBSolutionParser(); 320 322 solParser.Parse(solStream); 323 if (solParser.Error != null) throw solParser.Error; 321 324 BestKnownQuality = new DoubleValue(solParser.Qualiy); 322 325 BestKnownSolution = new Permutation(PermutationTypes.Absolute, solParser.Assignment);
Note: See TracChangeset
for help on using the changeset viewer.