Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/04/11 22:30:39 (14 years ago)
Author:
abeham
Message:

#1330

  • some remaining problems with benchmark data, two instances had quality values and solutions that did not go together
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/QAPLIBInstancesTest.cs

    r5933 r5949  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.IO;
     25using System.Linq;
     26using System.Reflection;
    2327using System.Text;
    2428using HeuristicLab.Common;
     
    3842        } catch (Exception ex) {
    3943          failedInstances.AppendLine(instance + ": " + ex.Message);
     44        }
     45      }
     46      Assert.IsTrue(failedInstances.Length == 0, "Following instances failed to load: " + Environment.NewLine + failedInstances.ToString());
     47    }
     48
     49    [TestMethod]
     50    public void LoadAllEmbeddedSolutions() {
     51      IEnumerable<string> solutionFiles = Assembly.GetAssembly(typeof(QuadraticAssignmentProblem))
     52          .GetManifestResourceNames()
     53          .Where(x => x.EndsWith(".sln"));
     54      QAPLIBSolutionParser parser = new QAPLIBSolutionParser();
     55      StringBuilder failedInstances = new StringBuilder();
     56      foreach (string solution in solutionFiles) {
     57        using (Stream stream = Assembly.GetAssembly(typeof(QuadraticAssignmentProblem)).GetManifestResourceStream(solution)) {
     58          parser.Reset();
     59          parser.Parse(stream, true);
     60          if (parser.Error != null)
     61            failedInstances.AppendLine(solution + ": " + parser.Error.Message);
    4062        }
    4163      }
     
    6385            failedInstances.AppendLine(instance + ": Reported quality: " + qap.BestKnownQuality.Value.ToString() + ", evaluated fitness: " + quality.ToString() + ".");
    6486          }
     87        } else if (qap.BestKnownQuality != null) {
     88          failedInstances.AppendLine(instance + ": The solution failed to load, only the quality value is available!");
    6589        }
    6690
Note: See TracChangeset for help on using the changeset viewer.