Commit e9f7fa0d authored by Lukas Weber's avatar Lukas Weber

parameter name parallel tempering

parent ec60b5ae
......@@ -69,7 +69,7 @@ void mc::_do_update() {
}
}
void mc::_pt_update_param(double new_param, const std::string &new_dir) {
void mc::_pt_update_param(const std::string& param_name, double new_param, const std::string &new_dir) {
// take over the bins of the new target dir
{
iodump dump_file = iodump::open_readonly(new_dir + ".dump.h5");
......@@ -86,7 +86,7 @@ void mc::_pt_update_param(double new_param, const std::string &new_dir) {
*unclean));
}
pt_update_param(new_param);
pt_update_param(param_name, new_param);
}
void mc::pt_measure_statistics() {
......@@ -97,8 +97,8 @@ void mc::pt_measure_statistics() {
}
}
double mc::_pt_weight_ratio(double new_param) {
double wr = pt_weight_ratio(new_param);
double mc::_pt_weight_ratio(const std::string& param_name, double new_param) {
double wr = pt_weight_ratio(param_name, new_param);
return wr;
}
......
......@@ -32,10 +32,10 @@ protected:
virtual void write_output(const std::string &filename);
virtual void do_update() = 0;
virtual void do_measurement() = 0;
virtual void pt_update_param(double /*new_param*/) {
virtual void pt_update_param(const std::string& /*param_name*/, double /*new_param*/) {
throw std::runtime_error{"running parallel tempering, but pt_update_param not implemented"};
}
virtual double pt_weight_ratio(double /*new_param*/) {
virtual double pt_weight_ratio(const std::string& /*param_name*/, double /*new_param*/) {
throw std::runtime_error{"running parallel tempering, but pt_weight_ratio not implemented"};
return 1;
}
......@@ -61,8 +61,8 @@ public:
void _do_update();
void _do_measurement();
void _pt_update_param(double new_param, const std::string &new_dir);
double _pt_weight_ratio(double new_param);
void _pt_update_param(const std::string& param_name, double new_param, const std::string &new_dir);
double _pt_weight_ratio(const std::string& param_name, double new_param);
void pt_measure_statistics();
......
......@@ -406,7 +406,7 @@ int runner_pt_master::assign_new_chain(int rank_section) {
for(int target = 0; target < chain_len_; target++) {
int msg[3] = {-1, 0, 0};
if(chain_run_id >= 0) {
if(chain_run_id > 0) {
auto &chain_run = pt_chain_runs_[chain_run_id];
auto &chain = pt_chains_[chain_run.id];
msg[0] = chain.task_ids[target];
......@@ -634,10 +634,12 @@ void runner_pt_slave::pt_global_update() {
MPI_Recv(&response, 1, MPI_INT, MASTER, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
// job_.log(fmt::format(" * rank {}: ready for global update", rank_));
const std::string& param_name = job_.jobfile["jobconfig"].get<std::string>("parallel_tempering_parameter");
if(response == GA_CALC_WEIGHT) {
double partner_param;
MPI_Recv(&partner_param, 1, MPI_DOUBLE, MASTER, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
double weight_ratio = sys_->_pt_weight_ratio(partner_param);
double weight_ratio = sys_->_pt_weight_ratio(param_name, partner_param);
MPI_Send(&weight_ratio, 1, MPI_DOUBLE, MASTER, 0, MPI_COMM_WORLD);
// job_.log(fmt::format(" * rank {}: weight sent", rank_));
} else {
......@@ -663,7 +665,7 @@ void runner_pt_slave::pt_global_update() {
task_id_ = new_task_id;
sweeps_per_global_update_ = job_.jobfile["tasks"][job_.task_names[task_id_]].get<int>(
"pt_sweeps_per_global_update");
sys_->_pt_update_param(new_param, job_.rundir(task_id_, run_id_));
sys_->_pt_update_param(param_name, new_param, job_.rundir(task_id_, run_id_));
}
current_param_ = new_param;
}
......
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