text
stringlengths 12
786k
|
---|
let rcount = let doc = " Number of random characters to generate . " in Arg . ( value & opt nat 1_000_000 & info [ " rcount " ] ~ doc ) |
let file = let doc = " The input file . Reads from stdin if unspecified . " in Arg . ( value & pos 0 string " " - & info [ ] ~ doc ~ docv " : FILE " ) |
let cmd = let doc = " Output the input text as Unicode scalar values or malformed sequences , one per line , in the US - ASCII charset with their position ( see POSITION INFORMATION for more details ) . " in let ascii = ` Ascii , Arg . info [ " a " ; " ascii " ] ~ doc in let doc = " Only guess an UTF encoding . The result of a guess can only be UTF - 8 or UTF - 16 { LE , BE } . " in let guess = ` Guess , Arg . info [ " g " ; " guess " ] ~ doc in let doc = " Decode only , no encoding . " in let dec = ` Decode , Arg . info [ " decode " ] ~ doc in let doc = " Encode only ( random ) , no decoding . See option ( $ b , -- rcount ) . " in let enc = ` Encode , Arg . info [ " encode " ] ~ doc in Arg . ( value & vflag ` Trip [ ascii ; guess ; dec ; enc ] ) |
let cmd = let doc = " Recode UTF { - 8 , 16 , 16LE , 16BE } and latin1 from stdin to stdout . " in let man = [ ` S " DESCRIPTION " ; ` P " ( $ tname ) inputs Unicode text from stdin and rewrites it to stdout in various ways . If no input encoding is specified , it is guessed . If no output encoding is specified , the input encoding is used . " ; ` P " Invalid byte sequences in the input are reported on stderr and replaced by the Unicode replacement character ( U + FFFD ) in the output . " ; ` S " POSITION INFORMATION " ; ` P " The format for position information is " ; : ` P " filename : line . col ( : count , byte ) " ; ` I ( " line " , " one - based line number that increments with each newline . A newline is always determined as being anything that would be normalized by the option ` ( $ b , -- nln ) = readline ` . " ) ; ` I ( " col " , " zero - based column number that increment with each new decoded character and zeroes after a newline is decoded . Note that the column number may not correspond to user - perceived columns , as any Unicode scalar value , including combining characters are deemed to have a width of 1 . " ) ; ` I ( " count " , " the one - based Unicode scalar value count . " ) ; ` I ( " byte " , " the zero - based end byte offset of the scalar value in the input stream in hexadecimal . " ) ; ` S " EXIT STATUS " ; ` P " ( $ tname ) exits with one of the following values " ; : ` I ( " 0 " , " no error occured " ) ; ` I ( " 1 " , " a command line parsing error occured " ) ; ` I ( " 2 " , " the input text was malformed " ) ; ` S " BUGS " ; ` P " This program is distributed with the Uutf OCaml library . See http :// erratique . ch / software / uutf for contact information . " ; ] in Cmd . v ( Cmd . info " utftrip " ~ version " :%% VERSION " %% ~ doc ~ man ) Term . ( const do_cmd $ cmd $ file $ sin $ sout $ use_unix $ usize $ ienc $ oenc $ nln $ rseed $ rcount ) |
let ( ) = match Cmd . eval_value cmd with |
let ( >> ) f g x = g ( f x ) |
let ( ) >>> f g x y = g ( f x y ) |
let flip f x y = f y x |
let double x = ( x , x ) |
let k_comb x _y = x |
let s_comb x y z = x z ( y z ) ; ; |
module ExStream = struct open Stream let rec take n s = if n > 0 then icons ( next s ) @@ slazy ( fun _ -> take ( n - 1 ) s ) else sempty let rec take_int32 n s = if n > 0l then icons ( next s ) @@ slazy ( fun _ -> take_int32 ( Int32 . sub n 1l ) s ) else sempty let rec take_while f s = slazy ( fun _ -> match peek s with | Some h -> junk s ; if f h then icons h ( slazy ( fun _ -> take_while f s ) ) else sempty | None -> sempty ) let to_list s = let buf = ref [ ] in ( iter ( fun x -> buf := x :: ! buf ) s ; List . rev ! buf ) let to_string_opt ( ? len = 16 ) s = let buf = Buffer . create len in iter ( fun ch -> Buffer . add_char buf ch ) s ; Buffer . contents buf let to_string s = to_string_opt ~ len : 16 s let to_string_fun fn s = let buf = Buffer . create 16 in iter ( fun it -> Buffer . add_string buf @@ fn it ) s ; Buffer . contents buf let take_string = take >>> to_string let take_string_int32 = take_int32 >>> to_string end |
let list_length_int32 l = List . length l |> Int32 . of_int |
let list_unfold cons pred start = let rec loop step acc = if pred step then acc else let ( value , step ' ) = cons step in loop step ' ( value :: acc ) in loop start [ ] |
let range ( ? start = 0 ) stop = list_unfold ( pred >> double ) ( ( ) == start ) stop |
let str_length_int32 s = Int32 . of_int @@ String . length s |
let try_finally action finally = try let result = action ( ) in finally ( ) ; result ; with x -> finally ( ) ; raise x |
let with_resource resource action post = try_finally ( fun ( ) -> action resource ) ( fun ( ) -> post resource ) |
let with_file_in filename action = with_resource ( open_in filename ) action close_in |
let with_file_out filename action = with_resource ( open_out filename ) action close_out |
type buffer = { mutable buffer : string ; mutable position : int ; mutable length : int ; initial_buffer : string } |
let buffer_change_substring buf pos str = let b = buffer_of_t buf in String . blit str 0 b . buffer pos ( String . length str ) |
type shall_we = ( parameter -> bool ) |
type step_with_side_effects = step * S . PH . B . PB . CI . Po . K . side_effect |
type trace = { compressed_trace : step_with_side_effects list option ; pretrace : step list ; with_potential_ambiguity : bool } |
type trace_runtime_info = profiling_info Trace . Simulation_info . t |
type ' a with_handlers = parameter -> ? shall_we_compute : shall_we -> ? shall_we_compute_profiling_information : shall_we -> ? print_if_zero : shall_we -> kappa_handler -> profiling_info -> error_log -> ' a |
type ' a zeroary = ( error_log * profiling_info * ' a ) with_handlers |
type ( ' a , ' b ) unary = ( ' a -> error_log * profiling_info * ' b ) with_handlers |
type ( ' a , ' b , ' c ) binary = ( ' a -> ' b -> error_log * profiling_info * ' c ) with_handlers |
type ( ' a , ' b , ' c , ' d ) ternary = ( ' a -> ' b -> ' c -> error_log * profiling_info * ' d ) with_handlers |
type ( ' a , ' b , ' c , ' d , ' e ) quaternary = ( ' a -> ' b -> ' c -> ' d -> error_log * profiling_info * ' e ) with_handlers |
type ( ' a , ' b , ' c , ' d , ' e , ' f ) quinternary = ( ' a -> ' b -> ' c -> ' d -> ' e -> error_log * profiling_info * ' f ) with_handlers |
type ( ' a , ' b , ' c , ' d , ' e , ' f , ' g ) sexternary = ( ' a -> ' b -> ' c -> ' d -> ' e -> ' f -> error_log * profiling_info * ' g ) with_handlers |
let ( we_shall : shall_we ) = ( fun _ -> true ) |
let ( we_shall_not : shall_we ) = ( fun _ -> false ) |
let get_pretrace_of_trace trace = trace . pretrace |
let size_of_pretrace trace = List . length ( get_pretrace_of_trace trace ) |
let may_initial_sites_be_ambiguous trace = trace . with_potential_ambiguity |
let set_ambiguity_level trace x = { trace with with_potential_ambiguity = x } |
let _set_pretrace trace x = { trace with pretrace = x } |
let _set_compressed_trace trace x = { trace with compressed_trace = x } |
let get_compressed_trace trace = match trace . compressed_trace with | Some x -> x | None -> List . rev_map ( fun x -> x , [ ] ) ( List . rev ( get_pretrace_of_trace trace ) ) |
let is_compressed_trace trace = trace . compressed_trace != None |
let trace_of_pretrace_with_ambiguity with_ambiguity pretrace = { pretrace = pretrace ; compressed_trace = None ; with_potential_ambiguity = with_ambiguity ; } |
let trace_of_pretrace = trace_of_pretrace_with_ambiguity true |
let build_compressed_trace x y = { compressed_trace = Some y ; pretrace = x ; with_potential_ambiguity = false } |
let _extend_trace_with_dummy_side_effects l = List . rev_map ( fun a -> a , [ ] ) ( List . rev l ) |
let print_pretrace parameter _handler = Loggers . fprintf ( S . PH . B . PB . CI . Po . K . H . get_out_channel parameter ) " [ @< v >% a ] . " @@ ( Pp . list Pp . space ( Trace . print_step ~ compact : true ? env : None ) ) |
let print_trace parameter handler trace = print_pretrace parameter handler ( get_pretrace_of_trace trace ) |
let transform_trace_gen f log_message debug_message profiling_event = ( fun parameters ( ? shall_we_compute = we_shall ) ? shall_we_compute_profiling_information ( : _ ) ( ? print_if_zero = we_shall ) kappa_handler profiling_info error trace -> if shall_we_compute parameters then let error , profiling_info = StoryProfiling . StoryStats . add_event ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameters ) error profiling_event ( Some ( fun ( ) -> size_of_pretrace trace ) ) profiling_info in let bool = if S . PH . B . PB . CI . Po . K . H . get_log_step parameters then match log_message with | Some log_message -> let ( ) = Loggers . fprintf ( S . PH . B . PB . CI . Po . K . H . get_logger parameters ) " % s % s " ( Remanent_parameters . get_prefix ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameters ) ) log_message in let ( ) = Loggers . flush_logger ( S . PH . B . PB . CI . Po . K . H . get_logger parameters ) in true | None -> false else false in let pretrace = get_pretrace_of_trace trace in let error , profiling_info , ( pretrace ' , n ) = f parameters kappa_handler profiling_info error pretrace in let trace ' = trace_of_pretrace pretrace ' in let trace = if trace == trace ' then trace else set_ambiguity_level trace ' ( may_initial_sites_be_ambiguous trace ) in let ( ) = if bool then if n = 0 then if print_if_zero parameters then Loggers . fprintf ( S . PH . B . PB . CI . Po . K . H . get_logger parameters ) " : nothing has changed . " @ else Loggers . fprintf ( S . PH . B . PB . CI . Po . K . H . get_logger parameters ) " . " @ else if n > 0 then Loggers . fprintf ( S . PH . B . PB . CI . Po . K . H . get_logger parameters ) " : -% i events . " @ n else Loggers . fprintf ( S . PH . B . PB . CI . Po . K . H . get_logger parameters ) " : +% i events . " @ ( - n ) in let ( ) = if S . PH . B . PB . CI . Po . K . H . get_debugging_mode parameters then let _ = match ( Loggers . formatter_of_logger ( S . PH . B . PB . CI . Po . K . H . get_debugging_channel parameters ) ) with | Some fmt -> Format . fprintf fmt debug_message | None -> ( ) in print_trace parameters kappa_handler trace in let error , profiling_info = StoryProfiling . StoryStats . close_event ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameters ) error profiling_event ( Some ( fun ( ) -> size_of_pretrace trace ) ) profiling_info in error , profiling_info , trace else error , profiling_info , trace ) |
type kind = | May_add_ambiguities | Neutral |
let handle_ambiguities kind b = match kind with | Neutral -> b | May_add_ambiguities -> true |
type ambiquities_precondition = Do_not_care | Require_the_abscence_of_ambiguity |
let must_we_solve_ambiguity _parameters x = match x with | Do_not_care -> false | Require_the_abscence_of_ambiguity -> true |
let monadic_lift f = ( fun _ _ log_info error t -> let t ' = f t in error , log_info , ( t ' , List . length t - List . length t ' ) ) |
let _dummy_profiling = ( fun _ p -> p ) |
let disambiguate = transform_trace_gen ( monadic_lift S . PH . B . PB . CI . Po . K . disambiguate ) ( Some " \ t - alpha - conversion " ) " Trace after having renames agents :\ n " StoryProfiling . Agent_ids_disambiguation |
let make_unambiguous parameters ( ? shall_we_compute = we_shall ) ( ? shall_we_compute_profiling_information = we_shall_not ) ( ? print_if_zero = we_shall_not ) kappa_handler profiling_info error trace = if may_initial_sites_be_ambiguous trace then let error , profiling_info , trace ' = disambiguate parameters ~ shall_we_compute ( : fun parameters -> may_initial_sites_be_ambiguous trace && shall_we_compute parameters ) ~ shall_we_compute_profiling_information ~ print_if_zero kappa_handler profiling_info error trace in error , profiling_info , if trace ' == trace then set_ambiguity_level trace false else set_ambiguity_level trace ' false else error , profiling_info , trace |
let lift_to_care_about_ambiguities f requirement effect = ( fun parameters ( ? shall_we_compute = we_shall ) ( ? shall_we_compute_profiling_information = we_shall ) ( ? print_if_zero = we_shall ) kappa_handler profiling_info error trace -> if shall_we_compute parameters then let error , profiling_info , trace = if must_we_solve_ambiguity parameters requirement then make_unambiguous parameters ~ shall_we_compute kappa_handler profiling_info error trace else error , profiling_info , trace in let error , log_info , trace = ( f : S . PH . B . PB . CI . Po . K . H . parameter -> ? shall_we_compute : shall_we -> ? shall_we_compute_profiling_information : shall_we -> ? print_if_zero : shall_we -> S . PH . B . PB . CI . Po . K . H . handler -> StoryProfiling . StoryStats . log_info -> Exception . method_handler -> trace -> Exception . method_handler * StoryProfiling . StoryStats . log_info * trace ) parameters ~ shall_we_compute ~ shall_we_compute_profiling_information ~ print_if_zero kappa_handler profiling_info error trace in let trace = set_ambiguity_level trace ( handle_ambiguities effect true ) in error , log_info , trace else error , profiling_info , trace ) |
let split_init = lift_to_care_about_ambiguities ( transform_trace_gen ( monadic_lift S . PH . B . PB . CI . Po . K . split_init ) ( Some " \ t - splitting initial events " ) " Trace after having split initial events :\ n " StoryProfiling . Decompose_initial_state ) Do_not_care Neutral |
let cut = lift_to_care_about_ambiguities ( transform_trace_gen S . PH . B . PB . CI . Po . cut ( Some " \ t - cutting concurrent events " ) " Trace after having removed concurrent events :\ n " StoryProfiling . Partial_order_reduction ) Require_the_abscence_of_ambiguity Neutral |
let on_the_fly_cut_finalize cut_state = fst ( S . PH . B . PB . CI . Po . finalize_cut cut_state ) |
let cut_rev_trace rev_trace = on_the_fly_cut_finalize ( List . fold_left on_the_fly_cut_step on_the_fly_cut_init rev_trace ) |
let remove_obs_before _parameter _handler log_info error last_eid trace = error , log_info , ( let rec aux l score output = match l with [ ] -> List . rev output , score | t :: q -> if Trace . step_is_obs t then match Trace . simulation_info_of_step t with None -> aux q score ( t :: output ) | Some x -> if Trace . Simulation_info . story_id x >= last_eid then List . rev ( List . fold_left ( fun list a -> a :: list ) output l ) , score else aux q ( succ score ) output else aux q score ( t :: output ) in aux trace 0 [ ] ) |
let remove_obs_before parameter handler log_info error last_info trace = lift_to_care_about_ambiguities ( transform_trace_gen ( fun parameter handler log_info error -> remove_obs_before parameter handler log_info error last_info ) ( Some " \ t - Removing already visited observable hits " ) " Trace after having removed seen observable hits \ n " StoryProfiling . Partial_order_reduction ) Do_not_care Neutral parameter handler log_info error trace |
let remove_obs_before parameter ? shall_we_compute ( : _ ) ? shall_we_compute_profiling_information ( : _ ) ? print_if_zero ( : _ ) handler log_info error last_info trace = match last_info with | None -> error , log_info , trace | Some l -> let last = List . fold_left ( fun result x -> let last_eid = Trace . Simulation_info . story_id x in max result last_eid ) 0 l in remove_obs_before parameter handler log_info error last trace |
let fill_siphon = lift_to_care_about_ambiguities ( transform_trace_gen ( monadic_lift S . PH . B . PB . CI . Po . K . fill_siphon ) ( Some " \ t - detecting siphons " ) " Trace after having detected siphons :\ n " StoryProfiling . Siphon_detection ) Require_the_abscence_of_ambiguity May_add_ambiguities |
let ( remove_events_after_last_obs : ( trace , trace ) unary ) = lift_to_care_about_ambiguities ( transform_trace_gen ( monadic_lift ( ( List_util . remove_suffix_after_last_occurrence Trace . step_is_obs ) ) ) ( Some " \ t - removing events occurring after the last observable " ) " Trace after having removed the events after the last observable " StoryProfiling . Remove_events_after_last_observable ) Do_not_care Neutral |
let remove_pseudo_inverse_events = lift_to_care_about_ambiguities ( transform_trace_gen S . PH . B . PB . CI . cut ( Some " \ t - detecting pseudo inverse events " ) " Trace after having removed pseudo inverse events :\ n " StoryProfiling . Pseudo_inverse_deletion ) Do_not_care Neutral |
type story_table = { story_counter : int ; story_list : D . table ; } |
let count_stories story_table = D . count_stories story_table . story_list |
type observable_hit = { list_of_actions : S . PH . update_order list ; list_of_events : step_id list ; runtime_info : unit Trace . Simulation_info . t option } |
let get_event_list_from_observable_hit a = a . list_of_events |
let get_runtime_info_from_observable_hit a = a . runtime_info |
let _get_list_order a = a . list_of_actions |
let extract_observable_hits_from_musical_notation a ? shall_we_compute ( : _ ) ? shall_we_compute_profiling_information ( : _ ) ? print_if_zero ( : _ ) b profiling_info c d = let error , profiling_info , l = S . PH . forced_events a b profiling_info c d in error , profiling_info , List . rev_map ( fun ( a , b , c ) -> { list_of_actions = a ; list_of_events = b ; runtime_info = c } ) ( List . rev l ) |
let extract_observable_hit_from_musical_notation a ? shall_we_compute ( : _ ) ? shall_we_compute_profiling_information ( : _ ) ? print_if_zero ( : _ ) b profiling_info c string d = let error , profiling_info , l = S . PH . forced_events a b profiling_info c d in match l with | [ a , b , c ] -> error , profiling_info , { list_of_actions = a ; list_of_events = b ; runtime_info = c } | [ ] -> failwith ( string " ^ no story " ) | _ :: _ -> failwith ( string " ^ several stories " ) |
let translate p h profiling_info e b list = let error , profiling_info , ( list , _ ) = S . translate p h profiling_info e b list in error , profiling_info , trace_of_pretrace list |
let causal_prefix_of_an_observable_hit parameter ? shall_we_compute ( : _ ) ? shall_we_compute_profiling_information ( : _ ) ? print_if_zero ( : _ ) handler profiling_info error string blackboard ( enriched_grid : enriched_cflow_grid ) observable_id = let eid = match get_event_list_from_observable_hit observable_id with | [ a ] -> a | [ ] -> failwith ( " no observable in that story " ^ string ) | _ -> failwith ( " several observables in that story " ^ string ) in let event_id_list = Graph_closure . get_list_in_increasing_order_with_last_event ( S . PH . B . PB . int_of_step_id ( S . PH . B . PB . inc_step_id eid ) ) enriched_grid . Causal . prec_star in let error , profiling_info , output = translate parameter handler profiling_info error blackboard ( List . rev_map S . PH . B . PB . step_id_of_int ( List . rev event_id_list ) ) in error , profiling_info , output |
let export_musical_grid_to_xls a ? shall_we_compute ( : _ ) ? shall_we_compute_profiling_information ( : _ ) ? print_if_zero ( : _ ) b ( p : StoryProfiling . StoryStats . log_info ) c d e f g = S . PH . B . export_blackboard_to_xls a b p c d e f g |
let print_musical_grid a ? shall_we_compute ( : _ ) ? shall_we_compute_profiling_information ( : _ ) ? print_if_zero ( : _ ) b p c d = S . PH . B . print_blackboard a b p c d |
let create_story_table parameters ? shall_we_compute ( : _ ) ? shall_we_compute_profiling_information ( : _ ) ? print_if_zero ( : _ ) handler profiling_info error = let error , profiling_info , init = D . init_table parameters handler profiling_info error in error , profiling_info , { story_counter = 1 ; story_list = init ; } |
let _get_trace_of_story ( _ , _ , _ , y , _ ) = trace_of_pretrace y |
let _get_info_of_story ( _ , _ , _ , _ , t ) = t |
let tick_opt parameter bar = match bar with | None -> bar | Some ( logger , bar ) -> Some ( logger , Tick_stories . tick_stories logger Configuration . empty ( S . PH . B . PB . CI . Po . K . H . save_progress_bar parameter ) bar ) |
let close_progress_bar_opt logger = Loggers . print_newline logger |
let print_fails logger s n = match n with | 0 -> ( ) | 1 -> Loggers . fprintf logger " . @\ t 1 % s has failed . " @ s | _ -> Loggers . fprintf logger " . @\ t % i % ss have failed . " @ n s |
let inc_fails a a ' b = if a == a ' then succ b else b |
let fold_story_table_gen logger parameter ( ? shall_we_compute = we_shall ) ( ? shall_we_compute_profiling_information = we_shall ) ( handler : kappa_handler ) ( profiling_info : profiling_info ) error s ( f ( ( : trace , trace_runtime_info list , ' a , ' a ) ternary ) ) l a = let n_stories_input = count_stories l in let progress_bar = Some ( logger , Tick_stories . tick_stories logger Configuration . empty ( S . PH . B . PB . CI . Po . K . H . save_progress_bar parameter ) ( false , 0 , 0 , n_stories_input ) ) in let g parameter handler profiling_info error story info ( k , progress_bar , a , n_fails ) = let event = StoryProfiling . Story k in let error , profiling_info = P . add_event ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameter ) error event None profiling_info in let error , profiling_info , a ' = f parameter ~ shall_we_compute : shall_we_compute ~ shall_we_compute_profiling_information : shall_we_compute_profiling_information handler profiling_info error ( trace_of_pretrace_with_ambiguity false story ) info a in let progress_bar = tick_opt parameter progress_bar in let n_fails = inc_fails a a ' n_fails in let error , profiling_info = P . close_event ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameter ) error event None profiling_info in error , profiling_info , ( succ k , progress_bar , a ' , n_fails ) in let error , profiling_info , ( _ , _ , a , n_fails ) = D . fold_table parameter handler profiling_info error g l . story_list ( 1 , progress_bar , a , 0 ) in let ( ) = close_progress_bar_opt logger in let ( ) = print_fails parameter . S . PH . B . PB . CI . Po . K . H . logger_err s n_fails in error , ( profiling_info : profiling_info ) , a |
let fold_story_table_with_progress_bar parameter ? shall_we_compute ? shall_we_compute_profiling_information ? print_if_zero : _ handler profiling_info error s f l a = fold_story_table_gen ( S . PH . B . PB . CI . Po . K . H . get_logger parameter ) parameter ? shall_we_compute ? shall_we_compute_profiling_information handler profiling_info error s f l a |
let fold_story_table_without_progress_bar parameter ? shall_we_compute ? shall_we_compute_profiling_information ? print_if_zero : _ handler profiling_info error s f l a = fold_story_table_gen Loggers . dummy_txt_logger parameter ? shall_we_compute ? shall_we_compute_profiling_information handler profiling_info error s f l a |
let get_counter story_list = story_list . story_counter |
let get_stories story_list = story_list . story_list |
let _inc_counter story_list = { story_list with story_counter = succ story_list . story_counter } |
let build_grid parameter handler computation_info error trace bool = let error , computation_info = StoryProfiling . StoryStats . add_event ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameter ) error StoryProfiling . Build_grid None computation_info in let grid = S . PH . B . PB . CI . Po . K . build_grid trace bool handler in let error , computation_info = StoryProfiling . StoryStats . close_event ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameter ) error StoryProfiling . Build_grid None computation_info in error , computation_info , grid |
let store_trace ( parameter : parameter ) ? shall_we_compute : _ ? shall_we_compute_profiling_information : _ ? print_if_zero : _ handler computation_info error trace obs_info story_table = let error , computation_info = StoryProfiling . StoryStats . add_event ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameter ) error StoryProfiling . Store_trace None computation_info in let pretrace = get_pretrace_of_trace trace in let trace2 = get_compressed_trace trace in let bool = not ( is_compressed_trace trace ) in let error , computation_info , grid = build_grid parameter handler computation_info error trace2 bool in let computation_info = P . set_grid_generation computation_info in let story_info = List . rev_map ( Trace . Simulation_info . update_profiling_info ( P . copy computation_info ) ) ( List . rev obs_info ) in let error , computation_info , story_list = D . add_story parameter handler computation_info error grid pretrace story_info story_table . story_list in let story_table = { story_list = story_list ; story_counter = story_table . story_counter + 1 } in let error , computation_info = StoryProfiling . StoryStats . close_event ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameter ) error StoryProfiling . Store_trace None computation_info in error , computation_info , story_table |
let flatten_story_table parameter ? shall_we_compute : _ ? shall_we_compute_profiling_information : _ ? print_if_zero : _ handler log_info error story_table = let error , log_info , list = D . hash_list parameter handler log_info error story_table . story_list in error , log_info , { story_table with story_list = list } |
let compress ? heuristic parameter ? shall_we_compute : _ ? shall_we_compute_profiling_information : _ ? print_if_zero : _ handler log_info error trace = match parameter . S . PH . B . PB . CI . Po . K . H . current_compression_mode with | None -> error , log_info , [ trace ] | Some Story_json . Causal -> let ( ) = if S . PH . B . PB . CI . Po . K . H . is_server_mode parameter && S . PH . B . PB . CI . Po . K . H . is_server_channel_on parameter then S . PH . B . PB . CI . Po . K . H . push_json parameter ( Story_json . Phase ( Story_json . Inprogress , " Start one causal compression " ) ) in let error , log_info , trace = cut parameter ~ shall_we_compute : we_shall handler log_info error trace in error , log_info , [ trace ] | Some ( Story_json . Weak | Story_json . Strong ) -> let event , s = match parameter . S . PH . B . PB . CI . Po . K . H . current_compression_mode with Some Story_json . Weak -> StoryProfiling . Weak_compression , " Start one weak compression " | _ -> StoryProfiling . Strong_compression , " Start one strong compression " in let ( ) = if S . PH . B . PB . CI . Po . K . H . is_server_mode parameter && S . PH . B . PB . CI . Po . K . H . is_server_channel_on parameter then S . PH . B . PB . CI . Po . K . H . push_json parameter ( Story_json . Phase ( Story_json . Inprogress , s ) ) in let error , log_info = P . add_event ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameter ) error event ( Some ( fun ( ) -> size_of_pretrace trace ) ) log_info in let event_list = get_pretrace_of_trace trace in let error , log_info , blackboard = S . PH . B . import ? heuristic parameter handler log_info error event_list in let error , log_info , list = S . PH . forced_events parameter handler log_info error blackboard in let list_order = match list with | ( list_order , _ , _ ) :: _ -> list_order | _ -> [ ] in let error , log_info , ( blackboard , output , list ) = S . compress parameter handler log_info error blackboard list_order in let list = List . rev_map ( fun pretrace -> let event_list = S . translate_result pretrace in let event_list = S . PH . B . PB . CI . Po . K . clean_events event_list in ( build_compressed_trace event_list pretrace ) ) list in let log_info = P . set_story_research_time log_info in let error , log_info = P . close_event ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameter ) error event ( Some ( fun ( ) -> size_of_pretrace trace ) ) log_info in let error , ( ) = if S . PH . B . is_failed output then Exception . warn ( S . PH . B . PB . CI . Po . K . H . get_kasa_parameters parameter ) error __POS__ ~ message " : One compression has failed " Exit ( ) else error , ( ) in let error = if debug_mode then let ( ) = Loggers . fprintf parameter . S . PH . B . PB . CI . Po . K . H . logger_err " \ t \ t * result " in let error = if S . PH . B . is_failed output then let error , _log_info , ( ) = S . PH . B . export_blackboard_to_xls parameter handler log_info error " FAIL " 0 0 blackboard in let ( ) = Loggers . fprintf parameter . S . PH . B . PB . CI . Po . K . H . logger_err " Fail_to_compress " in error else let ( ) = Loggers . fprintf parameter . S . PH . B . PB . CI . Po . K . H . logger_err " Succeed_to_compress " in error in error else error in error , log_info , list |
let strongly_compress ? heuristic parameter = compress ? heuristic ( S . PH . B . PB . CI . Po . K . H . set_compression_strong parameter ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.