From 9cd20a46e77839c6a7cdd1f9d22ac8e938e283d6 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 6 Mar 2022 15:16:02 +0100 Subject: [PATCH] Added Weight --- bin/mu_opt.py | 6 +++--- ocaml/Qmcchem_result.ml | 8 ++++++-- ocaml/Random_variable.ml | 9 ++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/bin/mu_opt.py b/bin/mu_opt.py index c219ca5..802ae7a 100755 --- a/bin/mu_opt.py +++ b/bin/mu_opt.py @@ -183,10 +183,10 @@ def main(): if sum(x) == 0.: jast_a_up_dn = ezfio.jastrow_jast_a_up_dn x += jast_a_up_dn -# opt = sp.optimize.minimize(f,x,method="Powell", -# options= {'disp':True, 'ftol':thresh,'xtol':0.02}) - opt = sp.optimize.minimize(f,x,method="Nelder-Mead", + opt = sp.optimize.minimize(f,x,method="Powell", options= {'disp':True, 'ftol':thresh,'xtol':0.02}) +# opt = sp.optimize.minimize(f,x,method="Nelder-Mead", +# options= {'disp':True, 'ftol':thresh,'xtol':0.02}) print("x = "+str(opt)) sys.stdout.flush() set_params_b(opt['x'][0]) diff --git a/ocaml/Qmcchem_result.ml b/ocaml/Qmcchem_result.ml index 68106d8..724ee40 100644 --- a/ocaml/Qmcchem_result.ml +++ b/ocaml/Qmcchem_result.ml @@ -131,7 +131,7 @@ let display_histogram ~range property = -(** Display a summary of all the cmoputed quantities *) +(** Display a summary of all the computed quantities *) let display_summary ~range = let properties = @@ -152,12 +152,16 @@ let display_summary ~range = Random_variable.of_raw_data ~range Property.Wall |> Random_variable.max_value_per_compute_node |> Random_variable.sum + and total_weight = + Random_variable.of_raw_data ~range Property.E_loc + |> Random_variable.total_weight in let speedup = cpu /. wall in - Printf.printf "%20s : %10.2f x\n" "Speedup" speedup + Printf.printf "%20s : %10.2f x\n" "Speedup" speedup ; + Printf.printf "%20s : %20.10e\n" "Total weight" total_weight diff --git a/ocaml/Random_variable.ml b/ocaml/Random_variable.ml index f408564..1387a0d 100644 --- a/ocaml/Random_variable.ml +++ b/ocaml/Random_variable.ml @@ -189,6 +189,13 @@ let sum { property ; data } = in accu +. num ) 0. data +(** Compute sum of the weights *) +let total_weight { property ; data } = + List.fold_left (fun accu x -> + let num = (Weight.to_float x.Block.weight) + in accu +. num + ) 0. data + (** Calculation of the average and error bar *) @@ -414,7 +421,7 @@ let create_hash ~create_key ?(update_block_id=(fun x->x)) compute_node = block.compute_node; } | None -> Some - { property = block.property ; + { property = block.property ; weight = block.weight; value = block.value ; block_id = update_block_id block.block_id;