Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/26/12 16:28:17 (13 years ago)
Author:
abeham
Message:

#1767

  • added NaN check to MultidimensionalScaling
  • fixed a bug in StressFitness and now ignore distance to self
  • changed transformation of the weights matrix to a dissimiliarity matrix (set entries to NaN when weight was 0)
  • swapped weights and distance matrix for the els19
File:
1 edited

Legend:

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

    r7259 r7416  
    205205        Bitmap newBitmap = null;
    206206        stressLabel.Text = "-";
     207        stressLabel.ForeColor = Color.Black;
    207208        if (distancesRadioButton.Checked && Distances != null && Distances.Rows > 0
    208209          && Distances.Rows == Distances.Columns) {
    209           if (Distances.Rows > 35) {
     210          if (Distances.Rows > 50) {
    210211            newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
    211212            WriteCenteredTextToBitmap(ref newBitmap, "Problem dimension is too large for visualization.");
     
    214215        } else if (weightsRadioButton.Checked && Weights != null && Weights.Rows > 0
    215216          && Weights.Rows == Weights.Columns) {
    216           if (Weights.Rows > 35) {
     217          if (Weights.Rows > 50) {
    217218            newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
    218219            WriteCenteredTextToBitmap(ref newBitmap, "Problem dimension is too large for visualization.");
     
    228229          && Assignment.Length == Distances.Rows
    229230          && Assignment.Validate()) {
    230           if (Assignment.Length > 35) {
     231          if (Assignment.Length > 50) {
    231232            newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
    232233            WriteCenteredTextToBitmap(ref newBitmap, "Problem dimension is too large for visualization.");
     
    249250        Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
    250251        stressLabel.Text = "-";
     252        stressLabel.ForeColor = Color.Black;
    251253        WriteCenteredTextToBitmap(ref newBitmap, "Please refresh view.");
    252254        showingMessage = false; // we're showing a message, but we should be showing the visualization, so this is false
     
    270272          stress = MultidimensionalScaling.CalculateNormalizedStress(distances, coordinates);
    271273          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;
    272277        } catch {
    273278          WriteCenteredTextToBitmap(ref newBitmap, "Distance matrix is not symmetric");
    274279          showingMessage = true;
    275280          stressLabel.Text = "-";
     281          stressLabel.ForeColor = Color.Black;
    276282          return newBitmap;
    277283        }
     
    349355        for (int i = 0; i < weights.Rows; i++)
    350356          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];
    353359          }
    354360
     
    356362        for (int i = 0; i < distances.Rows; i++)
    357363          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];
    359366          }
    360367
     
    365372          stress = MultidimensionalScaling.CalculateNormalizedStress(distances, coordinates);
    366373          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;
    367377        } catch {
    368378          WriteCenteredTextToBitmap(ref newBitmap, "Weights matrix is not symmetric");
    369379          showingMessage = true;
    370380          stressLabel.Text = "-";
     381          stressLabel.ForeColor = Color.Black;
    371382          return newBitmap;
    372383        }
     
    454465          stress = MultidimensionalScaling.CalculateNormalizedStress(distances, coordinates);
    455466          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;
    456470        } catch {
    457471          WriteCenteredTextToBitmap(ref newBitmap, "Unknown error");
    458472          showingMessage = true;
    459473          stressLabel.Text = "-";
     474          stressLabel.ForeColor = Color.Black;
    460475          return newBitmap;
    461476        }
Note: See TracChangeset for help on using the changeset viewer.