Commit 2f7cdf33 authored by Lukas Weber's avatar Lukas Weber

pt_statistics option to save all the replica trajectories

parent bdbb9cfa
...@@ -274,8 +274,19 @@ void runner_pt_master::write_params_json() { ...@@ -274,8 +274,19 @@ void runner_pt_master::write_params_json() {
file << params.dump(1) << "\n"; file << params.dump(1) << "\n";
} }
void runner_pt_master::write_param_optimization_stats() { void runner_pt_master::write_statistics(const pt_chain_run &chain_run) {
std::string stat_name = job_.jobdir() + "/pt_param_stats.h5"; std::string stat_name = job_.jobdir() + "/pt_statistics.h5";
iodump stat = iodump::open_readwrite(stat_name);
auto g = stat.get_root();
g.write("chain_length", chain_len_);
auto cg = g.open_group(fmt::format("chain{:04d}_run{:04d}", chain_run.id, chain_run.run_id));
cg.insert_back("rank_to_pos", chain_run.rank_to_pos);
}
void runner_pt_master::write_param_optimization_statistics() {
std::string stat_name = job_.jobdir() + "/pt_statistics.h5";
iodump stat = iodump::open_readwrite(stat_name); iodump stat = iodump::open_readwrite(stat_name);
auto g = stat.get_root(); auto g = stat.get_root();
...@@ -420,7 +431,7 @@ void runner_pt_master::pt_param_optimization(pt_chain &chain) { ...@@ -420,7 +431,7 @@ void runner_pt_master::pt_param_optimization(pt_chain &chain) {
"convergence={:.2g}", "convergence={:.2g}",
chain.id, chain.rejection_rate_entries[0], efficiency, convergence)); chain.id, chain.rejection_rate_entries[0], efficiency, convergence));
checkpoint_write(); checkpoint_write();
write_param_optimization_stats(); write_param_optimization_statistics();
chain.clear_histograms(); chain.clear_histograms();
} }
} }
...@@ -512,6 +523,10 @@ void runner_pt_master::react() { ...@@ -512,6 +523,10 @@ void runner_pt_master::react() {
MPI_Send(&new_param, 1, MPI_DOUBLE, rank_section * chain_len_ + target + 1, 0, MPI_Send(&new_param, 1, MPI_DOUBLE, rank_section * chain_len_ + target + 1, 0,
MPI_COMM_WORLD); MPI_COMM_WORLD);
} }
if(job_.jobfile["jobconfig"].get<bool>("pt_statistics", false)) {
write_statistics(chain_run);
}
} else { // S_TIMEUP } else { // S_TIMEUP
num_active_ranks_--; num_active_ranks_--;
} }
......
...@@ -77,7 +77,8 @@ private: ...@@ -77,7 +77,8 @@ private:
void checkpoint_write(); void checkpoint_write();
void checkpoint_read(); void checkpoint_read();
void write_params_json(); void write_params_json();
void write_param_optimization_stats(); void write_statistics(const pt_chain_run &chain_run);
void write_param_optimization_statistics();
int schedule_chain_run(); int schedule_chain_run();
void pt_global_update(pt_chain &chain, pt_chain_run &chain_run); void pt_global_update(pt_chain &chain, pt_chain_run &chain_run);
......
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