Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for writing par file when sub optimal iter, added glm debug optio… #155

Merged
merged 1 commit into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1.8";
#define PESTPP_VERSION "5.1.9";

#if defined(_WIN32) || defined(_WIN64)
#define OS_WIN
Expand Down
19 changes: 14 additions & 5 deletions src/libs/pestpp_common/SVDSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,19 @@ ModelRun SVDSolver::solve(RunManagerAbstract &run_manager, TerminationController
ModelRun prev_run(best_upgrade_run);
bool upgrade_start = (restart_controller.get_restart_option() == RestartController::RestartOption::RESUME_UPGRADE_RUNS);
best_upgrade_run = iteration_upgrd(run_manager, termination_ctl, prev_run, upgrade_start);
if ((global_iter_num == 2) && (pest_scenario.get_pestpp_options().get_glm_debug_high_2nd_iter_phi()))
{
Observations fake_obs(optimum_run.get_obs());
for (auto& oname : fake_obs.get_keys())
{
fake_obs.update_rec(oname,1.0e+10);
}
best_upgrade_run.set_observations(fake_obs);
}
// reload best parameters and set flag to switch to central derivatives next iteration
double prev_phi = prev_run.get_phi(*regul_scheme_ptr);
double best_new_phi = best_upgrade_run.get_phi(*regul_scheme_ptr);

double phi_ratio = best_new_phi / prev_phi;

cout << endl << " ...Lambda testing complete for iteration " << termination_ctl.get_iteration_number() + 1 << endl;
Expand Down Expand Up @@ -288,11 +298,6 @@ ModelRun SVDSolver::solve(RunManagerAbstract &run_manager, TerminationController
best_upgrade_run.get_obs(), *(best_upgrade_run.get_obj_func_ptr()),
best_upgrade_run.get_ctl_pars());
file_manager.close_file(filename.str());
// par file for this iteration
output_file_writer.write_par(file_manager.open_ofile_ext("par"), best_upgrade_run.get_ctl_pars(), *(par_transform.get_offset_ptr()),
*(par_transform.get_scale_ptr()));
file_manager.close_file("par");

filename.str(""); // reset the stringstream
filename << global_iter_num << ".par";
output_file_writer.write_par(file_manager.open_ofile_ext(filename.str()), best_upgrade_run.get_ctl_pars(), *(par_transform.get_offset_ptr()),
Expand Down Expand Up @@ -328,6 +333,10 @@ ModelRun SVDSolver::solve(RunManagerAbstract &run_manager, TerminationController
// jacobian calculated next iteration will be at the current parameters and
// will be more accurate than the one caluculated at the begining of this iteration
save_nextjac = true;
// par file for this iteration
output_file_writer.write_par(file_manager.open_ofile_ext("par"), best_upgrade_run.get_ctl_pars(), *(par_transform.get_offset_ptr()),
*(par_transform.get_scale_ptr()));
file_manager.close_file("par");
}
os << endl;
iteration_update_and_report(os, prev_run, best_upgrade_run, termination_ctl, run_manager);
Expand Down
8 changes: 7 additions & 1 deletion src/libs/pestpp_common/pest_data_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ PestppOptions::ARG_STATUS PestppOptions::assign_value_by_key(string key, const s
passed_args.insert("BASE_JACOBIAN");
passed_args.insert("BASE_JACOBIAN_FILENAME");

//convert_ip(org_value, basejac_filename);
//convert_ip(org_value, basejac_filename);f
basejac_filename = org_value;
}

Expand Down Expand Up @@ -579,6 +579,10 @@ PestppOptions::ARG_STATUS PestppOptions::assign_value_by_key(string key, const s
{
glm_debug_real_fail = pest_utils::parse_string_arg_to_bool(value);
}
else if (key == "GLM_DEBUG_HIGH_2ND_ITER_PHI")
{
glm_debug_high_2nd_iter_phi = pest_utils::parse_string_arg_to_bool(value);
}
else if (key == "UPGRADE_AUGMENT")
{
cout << "++UPGRADE_AUGMENT is deprecated and no longer supported...ignoring" << endl;
Expand Down Expand Up @@ -1565,6 +1569,7 @@ void PestppOptions::summary(ostream& os) const
os << "glm_accept_mc_phi: " << glm_accept_mc_phi << endl;
os << "glm_rebase_super: " << glm_rebase_super << endl;
os << "glm_iter_mc: " << glm_iter_mc << endl;
os << "glm_high_2nd_iter_phi: " << glm_debug_high_2nd_iter_phi << endl;

// if (global_opt == OPT_DE)
// {
Expand Down Expand Up @@ -1774,6 +1779,7 @@ void PestppOptions::set_defaults()
set_glm_accept_mc_phi(false);
set_glm_rebase_super(false);
set_glm_iter_mc(false);
set_glm_debug_high_2nd_iter_phi(false);
set_prediction_names(vector<string>());
set_parcov_filename(string());
set_obscov_filename(string());
Expand Down
4 changes: 4 additions & 0 deletions src/libs/pestpp_common/pest_data_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ class PestppOptions {
void set_glm_rebase_super(bool _flag) { glm_rebase_super = _flag; }
bool get_glm_iter_mc() const { return glm_iter_mc; }
void set_glm_iter_mc(bool _flag) { glm_iter_mc = _flag; }
bool get_glm_debug_high_2nd_iter_phi() const {return glm_debug_high_2nd_iter_phi;}
void set_glm_debug_high_2nd_iter_phi(bool _flag) {glm_debug_high_2nd_iter_phi = _flag;}




Expand Down Expand Up @@ -638,6 +641,7 @@ class PestppOptions {
bool glm_accept_mc_phi;
bool glm_rebase_super;
bool glm_iter_mc;
bool glm_debug_high_2nd_iter_phi;

vector<double> base_lambda_vec;
vector<double> lambda_scale_vec;
Expand Down