Commit 46c1af31 authored by Benoit Barbot's avatar Benoit Barbot
Browse files

pb size

parent 60cf85e7
Pipeline #2150 failed with stages
in 49 seconds
......@@ -163,7 +163,7 @@ struct
let w = rg.statelist.(rg.init).loc_weight in
let dw = diff w s in
let ddw = diff dw s in
if verbose > 1 then (
if verbose > 3 then (
Format.printf "\nWeight : %a@." P.print w;
Format.printf "Weight': %a@." P.print dw );
......@@ -171,14 +171,14 @@ struct
let wts = svarexp *.. w in
let dwts = svarexp *.. dw in
let ddwts = svarexp *.. ddw in
if verbose > 2 then (
if verbose > 4 then (
Format.printf "Weight2 : %a@." P.print wts;
Format.printf "Weight2': %a@." P.print dwts );
let we = taylor_exp_s w (rg.nb_poly + 1) in
let de = taylor_exp_s dw (rg.nb_poly + 2) in
let dde = taylor_exp_s ddw (rg.nb_poly + 3) in
if verbose > 3 then (
if verbose > 5 then (
Format.printf "Weight_taylor : %a@." P.print we;
Format.printf "Weight_taylor': %a@." P.print de );
......@@ -268,22 +268,26 @@ struct
|>>| true
then (0, -.t_length -. 1.0, 0.0, smp_full)
else
let a, b, c =
let n, size, duration =
Samp.sample ~out_style:t_length ~max_iter:100 ~boltz ?seed
~sampler:Low_disc_sampler.random rgp2
[| (Fixed, Fixed); (Fixed, Fixed) |]
n
in
(a, b, c, smp_full)
(n, size, duration, smp_full)
in
let b, v, smp_full =
Math.bisect_increasing ~factor:0.001 ~relax:0.1 ~up_bound:false
~low:(0.0, -.t_length, None) (0.0, 1.0) (fun b ->
let n, size, _, smp = make_estimate 10000 b in
if verbose > 0 then Format.printf "|%i@?" n;
Math.bisect_increasing ~factor:0.001 ~strict:false ~relax:0.1
~up_bound:false ~low:(0.0, -.t_length, None) (0.0, 1.0) (fun b ->
let n, size, duration, smp = make_estimate 10000 b in
if verbose > 1 then
Format.printf "|%i->%.2f@?" n (size +. t_length);
if verbose > 2 then
Format.printf " samples with z:%g -> %g@." b (size +. t_length);
Format.printf " samples with z:%g s:%s -> size:%g duration:%g@."
b
(smp |>>> (fun (a, _, _) -> a) |>>> string_of_float |>>| "?")
(size +. t_length) duration;
(size, 0.0, smp))
in
(Some (b, 0.0, v +. t_length), smp_full)
......
......@@ -37,21 +37,22 @@ let string_of_file f =
close_in fo;
!b
let precomputation_exists ?debug filename frequency npoly s_formal
let precomputation_exists ?debug filename frequency boltzmann npoly s_formal
exact_rational =
try
let fd = open_in (Filename.remove_extension filename ^ ".pcmp") in
let hashmod = Digest.file filename in
let hashpcmp = (input_value fd : Digest.t) in
let freq = (input_value fd : float option) in
let boltz = (input_value fd : float option) in
let polyn = (input_value fd : int) in
let exact_rat = (input_value fd : bool) in
let s_formal_in = (input_value fd : bool) in
let rg = input_value fd in
(*let weight = input_value fd in*)
if
hashpcmp = hashmod && frequency = freq && npoly = polyn
&& exact_rational = exact_rat && s_formal = s_formal_in
hashpcmp = hashmod && frequency = freq && boltzmann = boltz
&& npoly = polyn && exact_rational = exact_rat && s_formal = s_formal_in
then (
(debug |>>| fun _ -> ()) true;
Some rg )
......@@ -64,11 +65,13 @@ let precomputation_exists ?debug filename frequency npoly s_formal
| End_of_file -> None (* Corrupt file *)
| _ -> None
let save_precomputation file rg frequency npoly s_formal exact_rational =
let save_precomputation file rg frequency boltzmann npoly s_formal
exact_rational =
let fd = open_out (Filename.remove_extension file ^ ".pcmp") in
let hashmod = Digest.file file in
output_value fd (hashmod : Digest.t);
output_value fd (frequency : float option);
output_value fd (boltzmann : float option);
output_value fd (npoly : int);
output_value fd (exact_rational : bool);
output_value fd (s_formal : bool);
......
......@@ -229,7 +229,7 @@ let main print_rg infile frequency npoly expected_duration boltzmann_param
else
printf
"Precomputation file found but file have change discard !@.")
infile frequency npoly
infile frequency boltzmann_param npoly
(frequency = None && expected_duration <> None)
rational_impl
in
......@@ -273,7 +273,8 @@ let main print_rg infile frequency npoly expected_duration boltzmann_param
in
(*Save computation*)
ZoneGraphInput.save_precomputation infile rgpoly frequency npoly
ZoneGraphInput.save_precomputation infile rgpoly frequency boltzmann_param
npoly
(frequency = None && expected_duration <> None)
rational_impl;
......
......@@ -54,7 +54,7 @@ let newton_raphson_iterate ?(factor = 1e-9) ?(max_iter = 20) ?bound f guess_p =
raise (Not_converging (!result, f0))
with Exit -> !result
let rec bisect_increasing ?(factor = 1e-10) ?(relax = 0.0) ?low
let rec bisect_increasing ?(factor = 1e-10) ?(strict = true) ?(relax = 0.0) ?low
?(up_bound = true) (bmin, bmax) f_to_evaluate =
(* fmin use to detect vertical asymptote *)
let xfmin, yfmin, a_val =
......@@ -80,34 +80,33 @@ let rec bisect_increasing ?(factor = 1e-10) ?(relax = 0.0) ?low
if m < xfmin then false
else
let cf = classify_float (fx *. yfmin) in
cf = FP_nan || cf = FP_infinite
(*|| fx < yfmin*)
cf = FP_nan || cf = FP_infinite || (fx < yfmin && strict)
in
if detect_asymptote then
Format.printf "detect asymptot fx:%f yfmin:%f m:%f" fx yfmin m;
let width = bmax -. bmin in
if abs_float fx < factor || width < factor /. 10. then (*stop *) (m, fx, a)
else if detect_asymptote || fx > 0.0 then (
else if detect_asymptote || fx > 0.0 then
(* go left *)
Format.printf "left\n";
bisect_increasing ~relax ~factor ?low
(*Format.printf "left\n";*)
bisect_increasing ~relax ~strict ~factor ?low
(bmin -. (relax *. width), m +. (relax *. width))
f_to_evaluate )
else (
f_to_evaluate
else
(* go right *)
Format.printf "right\n";
bisect_increasing ~relax ~factor ~low:(m, fx, a)
(*Format.printf "right\n";*)
bisect_increasing ~relax ~strict ~factor ~low:(m, fx, a)
(m -. (relax *. width), bmax +. (relax *. width))
f_to_evaluate ) )
f_to_evaluate )
else
let fx, _, _ = f_to_evaluate bmax in
if classify_float fx = FP_nan || fx > 0.0 || fx < yfmin then
(* Go left true upperbound *)
bisect_increasing ~factor ~relax ~up_bound:true ?low (bmin, bmax)
bisect_increasing ~factor ~strict ~relax ~up_bound:true ?low (bmin, bmax)
f_to_evaluate
else
(* Go right extend upperbound *)
bisect_increasing ~factor ~relax ~up_bound:false ?low
bisect_increasing ~factor ~strict ~relax ~up_bound:false ?low
(bmin, 2.0 *. bmax)
f_to_evaluate
......
......@@ -429,6 +429,7 @@ struct
( (size, dur),
(n + 1, nmsize, nmsize2, mduration +. dur, mduration2 +. (dur *. dur))
);
(*Format.printf "new traj size:%i@." size;*)
if
( (cilow < target && ciup < target +. 0.1)
|| (cilow > target && ciup > target -. 0.1) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment