- Timestamp:
- 03/29/11 16:54:52 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.cs
r5855 r5871 216 216 Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height); 217 217 218 for (int i = 0; i < distances.Rows; i++) {219 for (int j = i + 1; j < distances.Rows; j++)220 if (distances[i, j] != distances[j, i]){221 WriteCenteredTextToBitmap(ref newBitmap, "Distance matrix is not symmetric");222 return newBitmap;223 }224 } 225 226 double stress;227 DoubleMatrix coordinates = MultidimensionalScaling.MetricByDistance(distances, out stress);228 stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat);218 DoubleMatrix coordinates; 219 double stress = double.NaN; 220 try { 221 coordinates = MultidimensionalScaling.KruskalShepard(distances); 222 stress = MultidimensionalScaling.CalculateNormalizedStress(distances, coordinates); 223 stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat); 224 } catch { 225 WriteCenteredTextToBitmap(ref newBitmap, "Distance matrix is not symmetric"); 226 stressLabel.Text = "-"; 227 return newBitmap; 228 } 229 229 double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue; 230 230 double maxDistance = double.MinValue; … … 302 302 if (weights[i, j] > maxWeight) 303 303 maxWeight = weights[i, j] + weights[j, i]; 304 305 if (weights[i, j] != weights[j, i]) {306 WriteCenteredTextToBitmap(ref newBitmap, "Weights matrix is not symmetric");307 return newBitmap;308 }309 304 } 310 305 … … 315 310 } 316 311 317 double stress; 318 DoubleMatrix coordinates = MultidimensionalScaling.MetricByDistance(distances, out stress); 319 stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat); 312 DoubleMatrix coordinates; 313 double stress = double.NaN; 314 try { 315 coordinates = MultidimensionalScaling.KruskalShepard(distances); 316 stress = MultidimensionalScaling.CalculateNormalizedStress(distances, coordinates); 317 stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat); 318 } catch { 319 WriteCenteredTextToBitmap(ref newBitmap, "Weights matrix is not symmetric"); 320 stressLabel.Text = "-"; 321 return newBitmap; 322 } 320 323 double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue; 321 324 for (int i = 0; i < coordinates.Rows; i++) { … … 382 385 if (distances[i, j] != distances[j, i]) { 383 386 WriteCenteredTextToBitmap(ref newBitmap, "Distance matrix is not symmetric"); 387 stressLabel.Text = "-"; 384 388 return newBitmap; 385 389 } 386 390 if (weights[i, j] != weights[j, i]) { 387 391 WriteCenteredTextToBitmap(ref newBitmap, "Weights matrix is not symmetric"); 392 stressLabel.Text = "-"; 393 return newBitmap; 388 394 } 389 395 } 390 396 } 391 397 392 double stress; 393 DoubleMatrix coordinates = MultidimensionalScaling.MetricByDistance(distances, out stress); 394 stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat); 398 DoubleMatrix coordinates = null; 399 double stress = double.NaN; 400 try { 401 coordinates = MultidimensionalScaling.KruskalShepard(distances); 402 stress = MultidimensionalScaling.CalculateNormalizedStress(distances, coordinates); 403 stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat); 404 } catch { 405 WriteCenteredTextToBitmap(ref newBitmap, "Unknown error"); 406 stressLabel.Text = "-"; 407 return newBitmap; 408 } 409 395 410 double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue; 396 411 double maxWeight = double.MinValue;
Note: See TracChangeset
for help on using the changeset viewer.