Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/23/11 12:03:24 (12 years ago)
Author:
abeham
Message:

#1330

  • Added a test if the reported quality of the solution instances is similar to the evaluated qualities of these solutions
  • Adapted parsing of the solution file and added another parameter whether the permutation should be treated as facility->location (HeuristicLab default) or location->facility.
  • Adapted QuadraticAssignmentProblem to use that method that corresponds with the reported quality since there is no consistent encoding over all files
  • Improved API documentation of the parsing methods
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/QAPLIBInstancesTest.cs

    r5648 r5814  
    11using System;
    22using System.Text;
     3using HeuristicLab.Common;
    34using HeuristicLab.Problems.QuadraticAssignment;
    45using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    2021      Assert.IsTrue(failedInstances.Length == 0, "Following instances failed to load: " + Environment.NewLine + failedInstances.ToString());
    2122    }
     23
     24    [TestMethod]
     25    public void TestReportedSolutionQuality() {
     26      StringBuilder failedInstances = new StringBuilder();
     27      QuadraticAssignmentProblem qap = new QuadraticAssignmentProblem();
     28      foreach (string instance in qap.EmbeddedInstances) {
     29        try {
     30          qap.LoadEmbeddedInstance(instance);
     31        } catch {
     32          Assert.Fail("Not all instances load correctly");
     33        }
     34        if (qap.BestKnownSolution != null) {
     35          double quality = double.NaN;
     36          try {
     37            quality = QAPEvaluator.Apply(qap.BestKnownSolution, qap.Weights, qap.DistanceMatrix);
     38          } catch (Exception ex) {
     39            failedInstances.AppendLine("An unknown problem occurred evaluating solution of instance " + instance + ": " + ex.Message);
     40          }
     41          if (!quality.IsAlmost(qap.BestKnownQuality.Value)) {
     42            failedInstances.AppendLine(instance + ": Reported quality: " + qap.BestKnownQuality.Value.ToString() + ", evaluated fitness: " + quality.ToString() + ".");
     43          }
     44        }
     45
     46      }
     47      Assert.IsTrue(failedInstances.Length == 0, "Following instances report divergent fitness values: " + Environment.NewLine + failedInstances.ToString());
     48    }
    2249  }
    2350}
Note: See TracChangeset for help on using the changeset viewer.