- Timestamp:
- 01/26/12 16:28:17 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis/3.3/MultidimensionalScaling/MultidimensionalScaling.cs
r7259 r7416 103 103 private static void StressFitness(double[] x, double[] fi, object obj) { 104 104 Info info = (obj as Info); 105 int idx = 0; 105 106 for (int i = 0; i < info.Coordinates.Rows; i++) { 106 double f = Stress(x, info.Dissimilarities[info.Row, i], info.Coordinates[i, 0], info.Coordinates[i, 1]); 107 if (i < info.Row) fi[i] = f; 108 else if (i > info.Row) fi[i - 1] = f; 107 if (i == info.Row) continue; 108 if (!double.IsNaN(info.Dissimilarities[info.Row, i])) 109 fi[idx++] = Stress(x, info.Dissimilarities[info.Row, i], info.Coordinates[i, 0], info.Coordinates[i, 1]); 110 else fi[idx++] = 0.0; 109 111 } 110 112 } … … 114 116 int idx = 0; 115 117 for (int i = 0; i < info.Coordinates.Rows; i++) { 116 if (i != info.Row) {117 118 119 120 double f = Stress(x, c, a, b);121 fi[idx] = f;118 if (i == info.Row) continue; 119 double c = info.Dissimilarities[info.Row, i]; 120 double a = info.Coordinates[i, 0]; 121 double b = info.Coordinates[i, 1]; 122 if (!double.IsNaN(c)) { 123 fi[idx] = Stress(x, c, a, b); ; 122 124 jac[idx, 0] = 2 * (x[0] - a) * (Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])) - c) / Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])); 123 125 jac[idx, 1] = 2 * (x[1] - b) * (Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])) - c) / Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])); 124 idx++; 126 } else { 127 fi[idx] = jac[idx, 0] = jac[idx, 1] = 0; 125 128 } 129 idx++; 126 130 } 127 131 } … … 153 157 for (int i = 0; i < dimension - 1; i++) { 154 158 for (int j = i + 1; j < dimension; j++) { 155 if (dissimilarities[i, j] != dissimilarities[j, i]) throw new ArgumentException("Dissimilarities is not a symmetric matrix.", "dissimilarities"); 156 if (dissimilarities[i, j] != 0) { 159 if (dissimilarities[i, j] != dissimilarities[j, i] && !(double.IsNaN(dissimilarities[i, j]) && double.IsNaN(dissimilarities[j, i]))) 160 throw new ArgumentException("Dissimilarities is not a symmetric matrix.", "dissimilarities"); 161 if (!double.IsNaN(dissimilarities[i, j])) { 157 162 stress += Stress(coordinates[i, 0], coordinates[i, 1], dissimilarities[i, j], coordinates[j, 0], coordinates[j, 1]); 158 163 normalization += (dissimilarities[i, j] * dissimilarities[i, j]); -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPVisualizationControl.cs
r7259 r7416 205 205 Bitmap newBitmap = null; 206 206 stressLabel.Text = "-"; 207 stressLabel.ForeColor = Color.Black; 207 208 if (distancesRadioButton.Checked && Distances != null && Distances.Rows > 0 208 209 && Distances.Rows == Distances.Columns) { 209 if (Distances.Rows > 35) {210 if (Distances.Rows > 50) { 210 211 newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height); 211 212 WriteCenteredTextToBitmap(ref newBitmap, "Problem dimension is too large for visualization."); … … 214 215 } else if (weightsRadioButton.Checked && Weights != null && Weights.Rows > 0 215 216 && Weights.Rows == Weights.Columns) { 216 if (Weights.Rows > 35) {217 if (Weights.Rows > 50) { 217 218 newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height); 218 219 WriteCenteredTextToBitmap(ref newBitmap, "Problem dimension is too large for visualization."); … … 228 229 && Assignment.Length == Distances.Rows 229 230 && Assignment.Validate()) { 230 if (Assignment.Length > 35) {231 if (Assignment.Length > 50) { 231 232 newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height); 232 233 WriteCenteredTextToBitmap(ref newBitmap, "Problem dimension is too large for visualization."); … … 249 250 Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height); 250 251 stressLabel.Text = "-"; 252 stressLabel.ForeColor = Color.Black; 251 253 WriteCenteredTextToBitmap(ref newBitmap, "Please refresh view."); 252 254 showingMessage = false; // we're showing a message, but we should be showing the visualization, so this is false … … 270 272 stress = MultidimensionalScaling.CalculateNormalizedStress(distances, coordinates); 271 273 stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat); 274 if (stress < 0.1) stressLabel.ForeColor = Color.DarkGreen; 275 else if (stress < 0.2) stressLabel.ForeColor = Color.DarkOrange; 276 else stressLabel.ForeColor = Color.DarkRed; 272 277 } catch { 273 278 WriteCenteredTextToBitmap(ref newBitmap, "Distance matrix is not symmetric"); 274 279 showingMessage = true; 275 280 stressLabel.Text = "-"; 281 stressLabel.ForeColor = Color.Black; 276 282 return newBitmap; 277 283 } … … 349 355 for (int i = 0; i < weights.Rows; i++) 350 356 for (int j = i + 1; j < weights.Rows; j++) { 351 if (weights[i, j] > maxWeight) 352 maxWeight = weights[i, j] +weights[j, i];357 if (weights[i, j] > maxWeight) maxWeight = weights[i, j]; 358 if (weights[j, i] > maxWeight) maxWeight = weights[j, i]; 353 359 } 354 360 … … 356 362 for (int i = 0; i < distances.Rows; i++) 357 363 for (int j = 0; j < distances.Columns; j++) { 358 distances[i, j] = maxWeight + 1 - weights[i, j]; 364 if (weights[i, j] == 0) distances[i, j] = double.NaN; 365 else distances[i, j] = maxWeight / weights[i, j]; 359 366 } 360 367 … … 365 372 stress = MultidimensionalScaling.CalculateNormalizedStress(distances, coordinates); 366 373 stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat); 374 if (stress < 0.1) stressLabel.ForeColor = Color.DarkGreen; 375 else if (stress < 0.2) stressLabel.ForeColor = Color.DarkOrange; 376 else stressLabel.ForeColor = Color.DarkRed; 367 377 } catch { 368 378 WriteCenteredTextToBitmap(ref newBitmap, "Weights matrix is not symmetric"); 369 379 showingMessage = true; 370 380 stressLabel.Text = "-"; 381 stressLabel.ForeColor = Color.Black; 371 382 return newBitmap; 372 383 } … … 454 465 stress = MultidimensionalScaling.CalculateNormalizedStress(distances, coordinates); 455 466 stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat); 467 if (stress < 0.1) stressLabel.ForeColor = Color.DarkGreen; 468 else if (stress < 0.2) stressLabel.ForeColor = Color.DarkOrange; 469 else stressLabel.ForeColor = Color.DarkRed; 456 470 } catch { 457 471 WriteCenteredTextToBitmap(ref newBitmap, "Unknown error"); 458 472 showingMessage = true; 459 473 stressLabel.Text = "-"; 474 stressLabel.ForeColor = Color.Black; 460 475 return newBitmap; 461 476 } -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/Data/els19.dat
r5562 r7416 1 1 19 2 3 0 12 36 28 52 44 110 126 94 63 130 102 65 98 132 132 126 120 1264 12 0 24 75 82 75 108 70 124 86 93 106 58 124 161 161 70 64 705 36 24 0 47 71 47 110 73 126 71 95 110 46 127 163 163 73 67 736 28 75 47 0 42 34 148 111 160 52 94 148 49 117 104 109 111 105 1117 52 82 71 42 0 42 125 136 102 22 73 125 32 94 130 130 136 130 1368 44 75 47 34 42 0 148 111 162 52 96 148 49 117 152 152 111 105 1119 110 108 110 148 125 148 0 46 46 136 47 30 108 51 79 79 46 47 4110 126 70 73 111 136 111 46 0 69 141 63 46 119 68 121 121 27 24 3611 94 124 126 160 102 162 46 69 0 102 34 45 84 23 80 80 69 64 5112 63 86 71 52 22 52 136 141 102 0 64 118 29 95 131 131 141 135 14113 130 93 95 94 73 96 47 63 34 64 0 47 56 54 94 94 63 46 2414 102 106 110 148 125 148 30 46 45 118 47 0 100 51 89 89 46 40 3615 65 58 46 49 32 49 108 119 84 29 56 100 0 77 113 113 119 113 11916 98 124 127 117 94 117 51 68 23 95 54 51 77 0 79 79 68 62 5117 132 161 163 104 130 152 79 121 80 131 94 89 113 79 0 10 113 107 11918 132 161 163 109 130 152 79 121 80 131 94 89 113 79 10 0 113 107 11919 126 70 73 111 136 111 46 27 69 141 63 46 119 68 113 113 0 6 2420 120 64 67 105 130 105 47 24 64 135 46 40 113 62 107 107 6 0 1221 126 70 73 111 136 111 41 36 51 141 24 36 119 51 119 119 24 12 022 2 23 3 0 76687 0 415 545 819 135 1368 819 5630 … … 59 39 1783 0 0 0 0 0 0 0 0 0 60 40 0 0 0 0 0 0 0 0 0 41 42 0 12 36 28 52 44 110 126 94 63 130 102 65 98 132 132 126 120 126 43 12 0 24 75 82 75 108 70 124 86 93 106 58 124 161 161 70 64 70 44 36 24 0 47 71 47 110 73 126 71 95 110 46 127 163 163 73 67 73 45 28 75 47 0 42 34 148 111 160 52 94 148 49 117 104 109 111 105 111 46 52 82 71 42 0 42 125 136 102 22 73 125 32 94 130 130 136 130 136 47 44 75 47 34 42 0 148 111 162 52 96 148 49 117 152 152 111 105 111 48 110 108 110 148 125 148 0 46 46 136 47 30 108 51 79 79 46 47 41 49 126 70 73 111 136 111 46 0 69 141 63 46 119 68 121 121 27 24 36 50 94 124 126 160 102 162 46 69 0 102 34 45 84 23 80 80 69 64 51 51 63 86 71 52 22 52 136 141 102 0 64 118 29 95 131 131 141 135 141 52 130 93 95 94 73 96 47 63 34 64 0 47 56 54 94 94 63 46 24 53 102 106 110 148 125 148 30 46 45 118 47 0 100 51 89 89 46 40 36 54 65 58 46 49 32 49 108 119 84 29 56 100 0 77 113 113 119 113 119 55 98 124 127 117 94 117 51 68 23 95 54 51 77 0 79 79 68 62 51 56 132 161 163 104 130 152 79 121 80 131 94 89 113 79 0 10 113 107 119 57 132 161 163 109 130 152 79 121 80 131 94 89 113 79 10 0 113 107 119 58 126 70 73 111 136 111 46 27 69 141 63 46 119 68 113 113 0 6 24 59 120 64 67 105 130 105 47 24 64 135 46 40 113 62 107 107 6 0 12 60 126 70 73 111 136 111 41 36 51 141 24 36 119 51 119 119 24 12 0
Note: See TracChangeset
for help on using the changeset viewer.