Input.read_data C# (CSharp) Method

read_data() public method

public read_data ( ) : void
return void
    public void read_data()
    {
        read_scans_file();

        scans_data = new int [scans.Count,num_boards];

        int scan_idx = 0;
        foreach (InputScan scan in scans)
        {
            string file_path =
                data_file_path(Path.Combine("data", scan.id + ".data.bin"));

            BinaryReader binReader =
                new BinaryReader(File.Open(file_path, FileMode.Open));

            {
                int start, num, iters_limit;

                start = binReader.ReadInt32();
                num = binReader.ReadInt32();
                iters_limit = binReader.ReadInt32();

                if (start != start_board)
                {
                    throw new ArgumentException("Start board does not match in " + scan.id);
                }

                if (num != num_boards)
                {
                    throw new ArgumentException("Num boards does not match in " + scan.id);
                }

                if (iters_limit != 100000)
                {
                    throw  new ArgumentException("Iters limits is wrong in scan No. " + scan.id);
                }
            }

            for (int board_idx = 0; board_idx < num_boards ; board_idx++)
            {
                scans_data[scan_idx,board_idx] = binReader.ReadInt32();
            }

            scan_idx++;
        }
    }

Usage Example

Example #1
0
    static void Main(string[] args)
    {
        string cmd = ((args.Length >= 1) ? args[0] : "");

        if (cmd == "test_blacklist")
        {
            Input i = new Input(start_board, num_boards);
            i.read_scan_black_list();

            foreach (int blacked in i.blacklist)
            {
                Console.WriteLine(blacked);
            }
        }
        else if (cmd == "test_lookup_scan_cmd_line_by_id")
        {
            Input input = new Input(start_board, num_boards);
            input.read_scans_file();

            int id = Convert.ToInt32(args[1]);

            InputScan scan = input.scans.Find(e => e.id == id);
            Console.WriteLine(scan.cmd_line);
        }
        else if (cmd == "test_lookup_iters")
        {
            Input input = new Input(start_board, num_boards);
            input.read_data();

            int scan_id   = Convert.ToInt32(args[1]);
            int board_idx = Convert.ToInt32(args[2]);

            int scan_idx = 0;
            foreach (InputScan scan in input.scans)
            {
                if (scan.id == scan_id)
                {
                    break;
                }
                scan_idx++;
            }

            Console.WriteLine(input.scans_data[scan_idx, (board_idx - input.start_board)]);
        }
        else if (cmd == "test_process_sample_run")
        {
            Input input = new Input(start_board, num_boards);
            input.read_data();

            Process p = new Process(input);
            p.SampleRun();
        }
        else if (cmd == "test_process_sample_run_with_constant_quotas")
        {
            Input input = new Input(start_board, num_boards);
            input.read_data();

            int quota_value = Convert.ToInt32(args[1]);

            Process p = new Process(input);
            p.SampleRunWithConstantQuotas(quota_value);
        }
        else if (cmd == "find_optimal_quotas")
        {
            Input input = new Input(start_board, num_boards);
            input.read_data();

            int iters_num = Convert.ToInt32(args[1]);

            Process p = new Process(input);
            p.FindOptimalQuotas(iters_num);
        }
        // List<double> myList = new List<double>();
        else
        {
            Console.WriteLine("Hello World!");
        }
    }
All Usage Examples Of Input::read_data