2 let stat = Gc.stat() in
3 let word = float_of_int (Sys.word_size / 8) in
4 let free = float_of_int stat.Gc.free_words *. word /. 1024.0 in
5 let total = float_of_int stat.Gc.heap_words *. word /. 1024.0 in
6 let allocated = total -. free in
7 let str = sprintf "allocated = %f (free = %f; total_size = %f; %f)\n"
8 allocated free total (free /. total) in
12 (* allocated = 85862 *)
15 Gc.set { (Gc.get()) with Gc.verbose = 0x05 };;
18 (* allocated = 60243 *)
22 needs "../formal_lp/formal_interval/m_taylor_arith.hl";;
23 needs "../formal_lp/formal_interval/m_verifier.hl";;
26 Arith_cache.reset_cache();
27 Arith_cache.reset_stat();
28 Arith_float.reset_cache();
29 Arith_float.reset_stat();;
31 Arith_cache.print_stat();;
32 Arith_float.print_stat();;
36 (******************************)
40 let eval_d0 i t1 t2 = failwith "eval_d0";;
41 let eval_dd0 i j t1 t2 = failwith "eval_dd0";;
42 let eval_0 t1 t2 = failwith "eval_0";;
45 (******************************)
54 let tm = (rand o concl o SPEC_ALL o REWRITE_RULE[Sphere.delta_x]) Sphere.delta_y in
55 expr_to_vector_fun tm;;
59 let tm = (rand o concl o SPECL[`y1*y1`; `y2*y2`; `y3*y3`; `y4*y4`; `y5*y5`; `y6*y6`]) Sphere.delta_x4 in
60 expr_to_vector_fun tm;;
62 (* 4 * y1 * delta_y *)
63 let four_y1_delta_y_poly =
64 let x_var, tm = dest_abs delta_y_poly in
65 mk_abs (x_var, mk_binop mul_op_real `&4` (mk_binop mul_op_real `(x:real^6)$1 * x$1` tm));;
68 let neg_delta_y4_poly =
69 let x_var, tm = dest_abs delta_y4_poly in
70 mk_abs (x_var, mk_comb (neg_op_real, tm));;
73 let (_, _, _, eval_neg_delta_y4), tf_neg_delta_y4 =
74 mk_verification_functions pp neg_delta_y4_poly false `&0`;;
76 let (_, _, _, eval_4y1_delta_y), tf_4y1_delta_y =
77 mk_verification_functions pp four_y1_delta_y_poly false `&0`;;
79 let (_, _, _, eval_pi2), tf_pi2 =
80 mk_verification_functions pp `\x:real^6. pi / &2` false `&0`;;
83 let (_, _, _, eval_pi2_plus), tf_pi2_plus =
84 mk_verification_functions pp `\x:real^6. pi / &2 - #1.893` false `&0`;;
89 let denom = Uni_compose (uinv, Uni_compose (usqrt, tf_4y1_delta_y)) in
90 Plus (tf_pi2_plus, Uni_compose (uatan, Product (tf_neg_delta_y4, denom)));;
92 let eval_dih_y_hi th =
93 let inv, atn, sqrt, ( * ), ( + ) =
94 eval_m_taylor_inv n pp, eval_m_taylor_atn n pp, eval_m_taylor_sqrt n pp,
95 eval_m_taylor_mul n pp, eval_m_taylor_add n pp in
96 let poly1 = eval_4y1_delta_y th and
97 poly2 = eval_neg_delta_y4 th and
98 pi2 = eval_pi2_plus th in
99 pi2 + atn (poly2 * inv (sqrt (poly1)));;
105 let xx = `[&2; &2; &2; &2; &2; &2]` and
106 zz = `[#2.52; #2.52; #2.52; #2.52; #2.52; #2.52]`;;
108 let xx1 = convert_to_float_list pp true xx and
109 zz1 = convert_to_float_list pp false zz;;
113 let xx_s = `[&2; &2; &2; &2; &2; &2]` and
114 zz_s = `[#2.1; #2.1; #2.1; #2.1; #2.1; #2.1]`;;
118 let xx1_s = convert_to_float_list pp true xx_s and
119 zz1_s = convert_to_float_list pp false zz_s in
120 mk_m_center_domain n pp xx1_s zz1_s;;
124 (* 10: 9.121 (pp = 15) *)
125 (* 300: 5.5 (pp = 8) *)
126 (* 100 (cached, float_cached, pp = 8): 2.68 *)
127 test 1 eval_dih_y_hi domain_th;;
129 Arith_cache.print_stat();;
130 Arith_float.print_stat();;
135 let xx_s = `[&2; &2; &2; &2; &2; &2]` and
136 zz_s = `[#2.52; #2.1; #2.1; #2.1; #2.1; #2.1]`;;
138 let xx_s2 = `[&2; &2; &2; &2; &2; &2]` and
139 zz_s2 = `[#2.52; #2.2; #2.2; #2.2; #2.2; #2.2]`;;
142 let xx1_s = convert_to_float_list pp true xx_s and
143 zz1_s = convert_to_float_list pp false zz_s;;
145 let xx1_s2 = convert_to_float_list pp true xx_s2 and
146 zz1_s2 = convert_to_float_list pp false zz_s2;;
150 let xx_float, zz_float, xx_s_float, zz_s_float, xx_s2_float, zz_s2_float =
151 let pad = replicate 0.0 (8 - length (dest_list xx1)) in
152 map float_of_float_tm (dest_list xx1) @ pad,
153 map float_of_float_tm (dest_list zz1) @ pad,
154 map float_of_float_tm (dest_list xx1_s) @ pad,
155 map float_of_float_tm (dest_list zz1_s) @ pad,
156 map float_of_float_tm (dest_list xx1_s2) @ pad,
157 map float_of_float_tm (dest_list zz1_s2) @ pad;;
163 let c_dih_y_s = run_test tf_dih_y_hi xx_s_float zz_s_float false 0.0 true false true false 0.0;;
164 let c_dih_y_s2 = run_test tf_dih_y_hi xx_s2_float zz_s2_float false 0.0 true false true false 0.0;;
165 let c_dih_y0 = run_test tf_dih_y_hi xx_float zz_float false 0.0 true false false false 0.0;;
168 result_stat c_dih_y_s;;
170 result_stat c_dih_y_s2;;
171 (* pass = 4294, mono = 10 *)
172 result_stat c_dih_y0;;
179 (* 10 (pp = 15): 38.418 *)
180 (* 300 (pp = 8): 22.289 *)
181 (* 100 (cached, float_cached, pp = 8): 12.229 *)
183 let start = Sys.time() in
184 let result = m_verify_raw0 n pp (eval_d0, eval_dd0, eval_0, eval_dih_y_hi) c_dih_y_s xx1_s zz1_s in
185 let finish = Sys.time() in
187 (sprintf "Verification time: %f" (finish -. start)) in
190 Arith_cache.print_stat();;
191 Arith_float.print_stat();;
204 (* 100 (cached, float_cached, pp = 8): 233.80 *)
206 let start = Sys.time() in
207 let result = m_verify_raw0 n pp (eval_d0, eval_dd0, eval_0, eval_dih_y_hi) c_dih_y_s2 xx1_s2 zz1_s2 in
208 let finish = Sys.time() in
210 (sprintf "Verification time: %f" (finish -. start)) in
213 Arith_cache.print_stat();;
214 Arith_float.print_stat();;
216 (* 135718 (after two runs) *)
230 let start = Sys.time() in
231 let result = m_verify_raw0 n pp (eval_d0, eval_dd0, eval_0, eval_dih_y_hi) c_dih_y0 xx1 zz1 in
232 let finish = Sys.time() in
234 (sprintf "Verification time: %f" (finish -. start)) in