コード例 #1
0
        public override OPData ImportData(string path)
        {
            var parser = new SchildeParser();

            parser.Parse(path);
            var instance = LoadInstance(parser);

            instance.Name        = Path.GetFileName(path);
            instance.Description = "Loaded from file \"" + path + "\" on " + DateTime.Now.ToString();

            return(instance);
        }
コード例 #2
0
 private OPData LoadInstance(SchildeParser parser)
 {
     return(new OPData {
         Dimension = parser.Coordinates.GetLength(0),
         Coordinates = parser.Coordinates,
         Distances = parser.Distances,
         DistanceMeasure = parser.Distances != null ? DistanceMeasure.Direct : DistanceMeasure.Euclidean,
         MaximumDistance = parser.UpperBoundConstraint,
         StartingPoint = parser.StartingPoint,
         TerminalPoint = parser.TerminalPoint,
         Scores = Enumerable.Range(0, parser.Scores.GetLength(0)).Select(i => parser.Scores[i, 0]).ToArray()
     });
 }
コード例 #3
0
        public override OPData LoadData(IDataDescriptor id)
        {
            var descriptor          = (OPDataDescriptor)id;
            var instanceArchiveName = GetResourceName(FileName + @"\.zip");
            var parser = new SchildeParser();

            using (var instancesZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {
                var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier);
                using (var stream = entry.Open()) {
                    parser.Parse(stream);
                    var instance = LoadInstance(parser);

                    instance.Name        = id.Name;
                    instance.Description = id.Description;

                    return(instance);
                }
            }
        }