Exemple #1
0
        public override GQAPData ImportData(string path)
        {
            var parser = new CordeauGQAPParser();

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

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

            return(instance);
        }
Exemple #2
0
        private GQAPData Load(CordeauGQAPParser parser)
        {
            var instance = new GQAPData();

            instance.BestKnownQuality    = parser.BestKnownQuality;
            instance.Equipments          = parser.Equipments;
            instance.Locations           = parser.Locations;
            instance.Demands             = parser.Demands;
            instance.Capacities          = parser.Capacities;
            instance.Weights             = parser.Weights;
            instance.Distances           = parser.Distances;
            instance.InstallationCosts   = parser.InstallationCosts;
            instance.TransportationCosts = parser.TransportationCosts;
            return(instance);
        }
Exemple #3
0
        public override GQAPData LoadData(IDataDescriptor id)
        {
            var descriptor          = (CordeauGQAPDataDescriptor)id;
            var instanceArchiveName = GetResourceName(FileName + @"\.zip");

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

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

                    return(instance);
                }
            }
        }