Exemplo n.º 1
0
        internal object ReadInstance(UnExport export, InstanceReader reader)
        {
            long oldPos = _stream.Position;

            try
            {
                _stream.Position = export.ExportOffset;
                return(reader.ReadInstance(this, new BinaryReader(_stream), export));
            }
            finally
            {
                _stream.Position = oldPos;
            }
        }
Exemplo n.º 2
0
        public override int Execute(CommandContext context, Settings settings)
        {
            var iReader = new InstanceReader(_parser);
            var fi      = GetInstanceFile(settings);

            if (fi == null)
            {
                return(4);
            }
            _logger.LogInformation($"Attempting to read MRECs and Normals from {fi.Name}...");
            WriteSeparator();
            var mrecs = iReader.FindMREC(fi.FullName).ToList();

            foreach (var mrec in mrecs)
            {
                _logger.LogInformation($"MREC path found for {mrec.Identifier.BaseObjectName}: {mrec.Identifier.RawValue}");
                _logger.LogInformation($"Target MREC packing path: {Identifier.BaseObjectPath + mrec.Path.TrimEnd('/')}/{mrec.Identifier.RawValue}.*");
                WriteSeparator();
            }
            var normals = iReader.FindNormal(fi.FullName).ToList();

            foreach (var(path, identifier) in normals)
            {
                _logger.LogInformation($"Normals path found for {identifier.BaseObjectName}: {identifier.RawValue}");
                _logger.LogInformation($"Target Normals packing path: {Identifier.BaseObjectPath + path.TrimEnd('/')}/{identifier.RawValue}.*");
                WriteSeparator();
            }
            if (mrecs.Any() && normals.Any())
            {
                WriteSummary();
                _console.WriteLine();
                _console.WriteLine();
                _console.WriteLine(string.Empty.PadLeft(9) + "Press <ENTER> to continue...");
                System.Console.ReadLine();
                return(0);
            }
            else
            {
                return(1);
            }
        }
Exemplo n.º 3
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            XMLgeneratorReader xmlreader = new XMLgeneratorReader();

            xmlreader.OpenConnection();


            instance             = InstanceReader.Read();
            instance.courses     = xmlreader.ReadCourse();
            instance.rooms       = xmlreader.ReadRoom();
            instance.curricula   = xmlreader.ReadCurriculum();
            instance.constraints = xmlreader.GenerateAllConstraints();

            try
            {
                XmlGeneratorFiles.GenerateXml(instance);
                txtXmlContent.Text = System.IO.File.ReadAllText("instance.xml");
                ShowNiceView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
 internal void RegisterInstanceReader(string className, InstanceReader reader)
 {
     _instanceReaders.Add(className, reader);
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            var upperBounds = new Dictionary <Tuple <int, double, int>, int>
            {
                { new Tuple <int, double, int>(10, 0.2, 1), 1936 },
                { new Tuple <int, double, int>(10, 0.2, 2), 1042 },
                { new Tuple <int, double, int>(10, 0.2, 3), 1586 },
                { new Tuple <int, double, int>(10, 0.2, 4), 2139 },
                { new Tuple <int, double, int>(10, 0.2, 5), 1187 },
                { new Tuple <int, double, int>(10, 0.2, 6), 1521 },
                { new Tuple <int, double, int>(10, 0.2, 7), 2170 },
                { new Tuple <int, double, int>(10, 0.2, 8), 1720 },
                { new Tuple <int, double, int>(10, 0.2, 9), 1574 },
                { new Tuple <int, double, int>(10, 0.2, 10), 1869 },
                { new Tuple <int, double, int>(50, 0.4, 1), 24868 },
                { new Tuple <int, double, int>(50, 0.4, 2), 19279 },
                { new Tuple <int, double, int>(50, 0.4, 3), 21353 },
                { new Tuple <int, double, int>(50, 0.4, 4), 17495 },
                { new Tuple <int, double, int>(50, 0.4, 5), 18441 },
                { new Tuple <int, double, int>(50, 0.4, 6), 21497 },
                { new Tuple <int, double, int>(50, 0.4, 7), 23883 },
                { new Tuple <int, double, int>(50, 0.4, 8), 25402 },
                { new Tuple <int, double, int>(50, 0.4, 9), 21929 },
                { new Tuple <int, double, int>(50, 0.4, 10), 20048 },
                { new Tuple <int, double, int>(100, 0.4, 1), 89588 },
                { new Tuple <int, double, int>(100, 0.4, 2), 74854 },
                { new Tuple <int, double, int>(100, 0.4, 3), 85363 },
                { new Tuple <int, double, int>(100, 0.4, 4), 87730 },
                { new Tuple <int, double, int>(100, 0.4, 5), 76424 },
                { new Tuple <int, double, int>(100, 0.4, 6), 86724 },
                { new Tuple <int, double, int>(100, 0.4, 7), 79854 },
                { new Tuple <int, double, int>(100, 0.4, 8), 95361 },
                { new Tuple <int, double, int>(100, 0.4, 9), 73605 },
                { new Tuple <int, double, int>(100, 0.4, 10), 72399 },
                { new Tuple <int, double, int>(200, 0.6, 1), 254268 },
                { new Tuple <int, double, int>(200, 0.6, 2), 266028 },
                { new Tuple <int, double, int>(200, 0.6, 3), 254647 },
                { new Tuple <int, double, int>(200, 0.6, 4), 297269 },
                { new Tuple <int, double, int>(200, 0.6, 5), 260455 },
                { new Tuple <int, double, int>(200, 0.6, 6), 236160 },
                { new Tuple <int, double, int>(200, 0.6, 7), 247555 },
                { new Tuple <int, double, int>(200, 0.6, 8), 225572 },
                { new Tuple <int, double, int>(200, 0.6, 9), 255029 },
                { new Tuple <int, double, int>(200, 0.6, 10), 269236 },
                { new Tuple <int, double, int>(500, 0.6, 1), 1581233 },
                { new Tuple <int, double, int>(500, 0.6, 2), 1715332 },
                { new Tuple <int, double, int>(500, 0.6, 3), 1644947 },
                { new Tuple <int, double, int>(500, 0.6, 4), 1640942 },
                { new Tuple <int, double, int>(500, 0.6, 5), 1468325 },
                { new Tuple <int, double, int>(500, 0.6, 6), 1413345 },
                { new Tuple <int, double, int>(500, 0.6, 7), 1634912 },
                { new Tuple <int, double, int>(500, 0.6, 8), 1542090 },
                { new Tuple <int, double, int>(500, 0.6, 9), 1684055 },
                { new Tuple <int, double, int>(500, 0.6, 10), 1520515 },
                { new Tuple <int, double, int>(1000, 0.8, 1), 6411581 },
                { new Tuple <int, double, int>(1000, 0.8, 2), 6112598 },
                { new Tuple <int, double, int>(1000, 0.8, 3), 5985538 },
                { new Tuple <int, double, int>(1000, 0.8, 4), 6096729 },
                { new Tuple <int, double, int>(1000, 0.8, 5), 6348242 },
                { new Tuple <int, double, int>(1000, 0.8, 6), 6082142 },
                { new Tuple <int, double, int>(1000, 0.8, 7), 6575879 },
                { new Tuple <int, double, int>(1000, 0.8, 8), 6069658 },
                { new Tuple <int, double, int>(1000, 0.8, 9), 6188416 },
                { new Tuple <int, double, int>(1000, 0.8, 10), 6147295 }
            };

            var veryfier = new InstanceVerifier();

            var instances = new List <Instance>();
            var fileNames = new List <string>
            {
                "sch10.txt", "sch20.txt", "sch50.txt", "sch100.txt", "sch200.txt", "sch500.txt", "sch1000.txt"
            };

            fileNames.ForEach(fileName =>
            {
                using (var sr = new StreamReader(fileName))
                {
                    int instancesAmount = FromStreamListReader.ReadIntList(sr).First();
                    var instanceReader  = new InstanceReader()
                    {
                        StreamReader             = sr,
                        FileNameWithoutExtension = fileName.Split('.')[0]
                    };

                    for (int i = 0; i < instancesAmount; i++)
                    {
                        instances.Add(instanceReader.ReadNext(i + 1));
                    }
                }
            });

            //Solve("sch10", 0.2, instances, upperBounds, true);
            Console.Clear();

            for (int i = 0; i < 1; i++)
            {
                ConsoleAndFileWriter.WriteLine($"ilość zadań " +
                                               $"| K" +
                                               $"| F biblioteki " +
                                               $"| F obliczone (naive) " +
                                               $"| błąd %" +
                                               $"| t (s)" +
                                               $"| F obliczone (heur) " +
                                               $"| błąd %" +
                                               $"| t (s)" +
                                               $"| heurystyka lepsza o (%)");

                Solve("sch10", 0.2, instances, upperBounds);
                Solve("sch50", 0.4, instances, upperBounds);
                Solve("sch200", 0.6, instances, upperBounds);
                Solve("sch1000", 0.8, instances, upperBounds);
            }
        }
Exemplo n.º 6
0
 internal void RegisterInstanceReader(string className, InstanceReader reader)
 {
     _instanceReaders.Add(className, reader);
 }
Exemplo n.º 7
0
 internal object ReadInstance(UnExport export, InstanceReader reader)
 {
     long oldPos = _stream.Position;
     try
     {
         _stream.Position = export.ExportOffset;
         return reader.ReadInstance(this, new BinaryReader(_stream), export);
     }
     finally
     {
         _stream.Position = oldPos;
     }
 }