Changeset 17252 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.Instances.QAPLIB/3.3/QAPLIBInstanceProvider.cs
- Timestamp:
- 09/16/19 11:57:18 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Instances.QAPLIB/3.3/QAPLIBInstanceProvider.cs
r17226 r17252 230 230 } 231 231 232 public override bool CanImportData {233 get { return true; }234 } 232 public override IEnumerable<string> ImportFileExtensions => new[] { "dat" }; 233 public override bool CanImportData => true; 234 235 235 public override QAPData ImportData(string path) { 236 236 var parser = new QAPLIBParser(); … … 250 250 } 251 251 252 public override IEnumerable<string> ExportFileExtensions => new[] { "dat" }; 253 public override bool CanExportData => true; 254 public override void ExportData(QAPData instance, string path) { 255 using (var writer = new StreamWriter(path, append: false)) { 256 writer.WriteLine(instance.Dimension); 257 writer.WriteLine(); 258 WriteMatrix(instance.Weights, writer); 259 writer.WriteLine(); 260 WriteMatrix(instance.Distances, writer); 261 writer.WriteLine(); 262 writer.Flush(); 263 } 264 } 265 266 private static void WriteMatrix(double[,] matrix, StreamWriter writer) { 267 for (var i = 0; i < matrix.GetLength(0); i++) { 268 for (var j = 0; j < matrix.GetLength(1); j++) { 269 writer.Write(matrix[i, j] + " "); 270 } 271 writer.WriteLine(); 272 } 273 } 274 252 275 private string GetDescription() { 253 276 return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + ".";
Note: See TracChangeset
for help on using the changeset viewer.