Skip to content

Commit

Permalink
Merge branch 'hotfix_mourestart' of https://github.com/jtwhite79/pestpp
Browse files Browse the repository at this point in the history
… into hotfix_mourestart
  • Loading branch information
jtwhite79 committed Aug 15, 2023
2 parents c8f9f3e + c52755f commit 8fd3eae
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/libs/common/config_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define CONFIG_OS_H_


#define PESTPP_VERSION "5.2.5";
#define PESTPP_VERSION "5.2.6";

#if defined(_WIN32) || defined(_WIN64)
#define OS_WIN
Expand Down
8 changes: 7 additions & 1 deletion src/libs/pestpp_common/EnsembleMethodUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,8 @@ void UpgradeThread::ensemble_solution(const int iter, const int verbose_level,co

Eigen::MatrixXd ivec, s, s2, V, Ut, d_dash;
string key;
local_utils::save_mat(verbose_level, thread_id, iter, t_count, "weights", weights.toDenseMatrix());
Eigen::MatrixXd wtemp = weights.diagonal().matrix();
local_utils::save_mat(verbose_level, thread_id, iter, t_count, "weights", wtemp);
local_utils::save_mat(verbose_level, thread_id, iter, t_count, "obs_resid", obs_resid);
obs_resid = weights * obs_resid;
local_utils::save_mat(verbose_level, thread_id, iter, t_count, "scaled_obs_resid", obs_resid);
Expand All @@ -1368,6 +1369,11 @@ void UpgradeThread::ensemble_solution(const int iter, const int verbose_level,co
Eigen::MatrixXd temp = parcov_inv.toDenseMatrix();
local_utils::save_mat(verbose_level, thread_id, iter, t_count, "parcov_inv", temp);
}
else
{
Eigen::MatrixXd temp = parcov_inv.diagonal().matrix();
local_utils::save_mat(verbose_level, thread_id, iter, t_count, "parcov_inv", temp);
}
if (act_obs_names.size() > 0) { //this works bc the mm solve doesnt pass these names...
ss.str("");
ss << "solution scaling factor: " << scale << endl;
Expand Down
3 changes: 2 additions & 1 deletion src/libs/pestpp_common/OutputFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ void OutputFileWriter::scenario_report(std::ostream &os, bool report_mode)
os << setw(0) << " Number of parameters = " << pest_scenario.get_ctl_ordered_par_names().size() << endl;
os << setw(0) << " Number of adjustable parameters = " << pest_scenario.get_n_adj_par() << endl;
os << setw(0) << " Number of observations = " << pest_scenario.get_ctl_ordered_obs_names().size() << endl;
os << setw(0) << " Number of prior estimates = " << pest_scenario.get_ctl_ordered_pi_names().size() << endl << endl;
os << setw(0) << " Number of non-zero weighted observations = " << pest_scenario.get_ctl_ordered_nz_obs_names().size() << endl;
os << setw(0) << " Number of prior estimates = " << pest_scenario.get_ctl_ordered_pi_names().size() << endl << endl;

os << pest_scenario.get_control_info() << endl;
pest_scenario.get_pestpp_options().summary(os);
Expand Down
36 changes: 27 additions & 9 deletions src/libs/pestpp_common/pest_data_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ const ParameterGroupInfo& ParameterGroupInfo::operator=(const ParameterGroupInfo
if (it_find != old2new.end())
parameter2group[(*it).first] = (*it_find).second;
}
unordered_map<ParameterGroupRec*, ParameterGroupRec*>::iterator iit(old2new.begin());
unordered_map<ParameterGroupRec*, ParameterGroupRec*>::iterator eend(old2new.end());

for (; iit != eend; ++iit) {
delete (*iit).second;
delete (*iit).first;
}
// unordered_map<ParameterGroupRec*, ParameterGroupRec*>::iterator iit(old2new.begin());
// unordered_map<ParameterGroupRec*, ParameterGroupRec*>::iterator eend(old2new.end());
//
// for (; iit != eend; ++iit) {
// delete (*iit).second;
// delete (*iit).first;
// }

return *this;
}
Expand Down Expand Up @@ -204,18 +204,36 @@ bool ParameterGroupInfo::have_switch_derivative() const

ParameterGroupInfo::~ParameterGroupInfo()
{
unordered_map<string, ParameterGroupRec*>::iterator it(groups.begin());
// unordered_map<string, ParameterGroupRec*>::iterator it(groups.begin());
// unordered_map<string, ParameterGroupRec*>::iterator end(groups.end());
// for (; it != end; ++it) {
// delete (*it).second;
// }
//
// it = parameter2group.begin();
// end = parameter2group.end();
//
// for (; it != end; ++it) {
// delete (*it).second;
// }
}

void ParameterGroupInfo::free_mem()
{
unordered_map<string, ParameterGroupRec*>::iterator it(groups.begin());
unordered_map<string, ParameterGroupRec*>::iterator end(groups.end());
for (; it != end; ++it) {
delete (*it).second;
}

it = parameter2group.begin();
end = parameter2group.end();

for (; it != end; ++it) {
delete (*it).second;
}
groups.clear();
parameter2group.clear();
}

ostream& operator<< (ostream &os, const ParameterGroupInfo &val)
Expand Down
3 changes: 2 additions & 1 deletion src/libs/pestpp_common/pest_data_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ParameterGroupInfo {
void par_erase(const string& par_name) { parameter2group.erase(par_name); }
void grp_erase(const string& grp_name) { groups.erase(grp_name);
}
void free_mem();
~ParameterGroupInfo();
private:
unordered_map<string, ParameterGroupRec*> groups;
Expand Down Expand Up @@ -127,7 +128,7 @@ class ParameterInfo {
Parameters get_init_value(const vector<string> &keys) const;
const ParameterRec* get_parameter_rec_ptr(const string &name) const;
ParameterRec* get_parameter_rec_ptr_4_mod(const string &name);
void insert(const string &name, const ParameterRec &rec) {parameter_info[name] = rec;}
void insert(const string &name, ParameterRec rec) {parameter_info[name] = rec;}
void erase(const string& name) { parameter_info.erase(name);}
ParameterInfo() {}
~ParameterInfo() {}
Expand Down
2 changes: 1 addition & 1 deletion src/programs/pestpp-da/pestpp-da.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ int main(int argc, char* argv[])
{
delete run_manager_ptr;
}
childPest.get_base_group_info_ptr_4_mod()->~ParameterGroupInfo();
//childPest.get_base_group_info_ptr_4_mod()->free_mem();

} // end cycle loop

Expand Down

0 comments on commit 8fd3eae

Please sign in to comment.