- Timestamp:
- 03/23/11 12:03:24 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/QAPLIBInstancesTest.cs
r5648 r5814 1 1 using System; 2 2 using System.Text; 3 using HeuristicLab.Common; 3 4 using HeuristicLab.Problems.QuadraticAssignment; 4 5 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 20 21 Assert.IsTrue(failedInstances.Length == 0, "Following instances failed to load: " + Environment.NewLine + failedInstances.ToString()); 21 22 } 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 } 22 49 } 23 50 }
Note: See TracChangeset
for help on using the changeset viewer.