<commit_before>open Def
open Const
open Print
open PrinttoC
open Tools
open Trees
open Algos
open AlgosDiscret
open Format
open Printf

let () = Random.self_init ()

(*Creation of a regular table of speeds*)
let reg_tab_speeds n  max_speed= 
  let sol = Array.make n 0. in
  for i=1 to n-1 do
    sol.(i) <- (float_of_int i)*. ((float_of_int max_speed) /. (float_of_int (n-1)))
  done;
  sol

(*Creation of an irregular table of speeds. There can be equal speeds.*)
let irreg_tab_speeds n  max_speed= 
  let sol = Array.make n 0. in
  for i=1 to n-1 do
    sol.(i) <- ((float_of_int (Random.int (max_speed*100)))/.100.)
  done;
  Array.sort compare sol;
  sol


let parse_config file =
  let chan = open_in file in
  let rmax = int_of_string (input_line chan) in
  let tree_type = int_of_string (input_line chan) in 
  let size_of_tree = int_of_string (input_line chan) in
  let number_of_speeds = int_of_string (input_line chan) in
  let max_speed = int_of_string (input_line chan) in
  let regularity_speed = int_of_string (input_line chan) in
  let number_of_tests = int_of_string (input_line chan) in
  let () = close_in chan in
  {
  rmax = rmax;
  tree_type = tree_type;
  size_of_tree = size_of_tree;
  number_of_speeds = number_of_speeds;
  max_speed = max_speed;
  regularity_speed = regularity_speed;
  number_of_tests = number_of_tests 
  }


let script config_file =
  let param = parse_config config_file in
  let tab_of_speeds =
    match param.regularity_speed with
      | 1 -> reg_tab_speeds param.number_of_speeds param.max_speed
      | _ -> irreg_tab_speeds param.number_of_speeds param.max_speed
    in 
  for i = 1 to (param.number_of_tests) do
    let tree = match param.tree_type with
      | _ -> cree_alea (param.size_of_tree) (param.rmax)
    in 
      let first_matrix = make_prec_matrix_full_tree tree (param.size_of_tree) in
      for j = (param.size_of_tree) to (param.size_of_tree) do
        try 
        let result_discret_intel, matrix = algo_discret 0 tree (param.size_of_tree) j tab_of_speeds in
        let st = sprintf "results/size=%d_serv=%d_iter=%d.dat" (param.size_of_tree) j i in 
        let oo = open_out st in
          fprintf oo "%f \n %d \t %d \t %d \n" result_discret_intel param.number_of_speeds param.size_of_tree j; (*result \n K T S \n*)
          print_set_of_speeds tab_of_speeds oo;
          print_square_matrix first_matrix oo;
          print_square_matrix_int matrix first_matrix oo;
          close_out oo
        with
          | OverloadedNode(_,_) -> ()
      done;
  done

let () = script Sys.argv.(1)<commit_msg>undo some stuff I did for debugging.<commit_after>open Def
open Const
open Print
open PrinttoC
open Tools
open Trees
open Algos
open AlgosDiscret
open Format
open Printf

let () = Random.self_init ()

(*Creation of a regular table of speeds*)
let reg_tab_speeds n  max_speed= 
  let sol = Array.make n 0. in
  for i=1 to n-1 do
    sol.(i) <- (float_of_int i)*. ((float_of_int max_speed) /. (float_of_int (n-1)))
  done;
  sol

(*Creation of an irregular table of speeds. There can be equal speeds.*)
let irreg_tab_speeds n  max_speed= 
  let sol = Array.make n 0. in
  for i=1 to n-1 do
    sol.(i) <- ((float_of_int (Random.int (max_speed*100)))/.100.)
  done;
  Array.sort compare sol;
  sol


let parse_config file =
  let chan = open_in file in
  let rmax = int_of_string (input_line chan) in
  let tree_type = int_of_string (input_line chan) in 
  let size_of_tree = int_of_string (input_line chan) in
  let number_of_speeds = int_of_string (input_line chan) in
  let max_speed = int_of_string (input_line chan) in
  let regularity_speed = int_of_string (input_line chan) in
  let number_of_tests = int_of_string (input_line chan) in
  let () = close_in chan in
  {
  rmax = rmax;
  tree_type = tree_type;
  size_of_tree = size_of_tree;
  number_of_speeds = number_of_speeds;
  max_speed = max_speed;
  regularity_speed = regularity_speed;
  number_of_tests = number_of_tests 
  }


let script config_file =
  let param = parse_config config_file in
  let tab_of_speeds =
    match param.regularity_speed with
      | 1 -> reg_tab_speeds param.number_of_speeds param.max_speed
      | _ -> irreg_tab_speeds param.number_of_speeds param.max_speed
    in 
  for i = 1 to (param.number_of_tests) do
    let tree = match param.tree_type with
      | _ -> cree_alea (param.size_of_tree) (param.rmax)
    in 
      let first_matrix = make_prec_matrix_full_tree tree (param.size_of_tree) in
      for j = 1 to (param.size_of_tree) do
        try 
        let result_discret_intel, matrix = algo_discret 0 tree (param.size_of_tree) j tab_of_speeds in
        let st = sprintf "results/size=%d_serv=%d_iter=%d.dat" (param.size_of_tree) j i in 
        let oo = open_out st in
          fprintf oo "%f \n %d \t %d \t %d \n" result_discret_intel param.number_of_speeds param.size_of_tree j; (*result \n K T S \n*)
          print_set_of_speeds tab_of_speeds oo;
          print_square_matrix first_matrix oo;
          print_square_matrix_int matrix first_matrix oo;
          close_out oo
        with
          | OverloadedNode(_,_) -> ()
      done;
  done

let () = script Sys.argv.(1)
{'fraction_non_alphanumeric': 0.08171959721146398, 'fraction_numerical': 0.006777691711851278, 'mean_word_length': 3.2094539527302364, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2160017', 'n_tokens_mistral': 1931, 'n_tokens_neox': 1865, 'n_words': 541}