Skip to content

Commit

Permalink
initial attempt at updatebyreals
Browse files Browse the repository at this point in the history
  • Loading branch information
jtwhite79 committed Aug 16, 2024
1 parent 04cc328 commit bcdf40a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/libs/pestpp_common/EnsembleMethodUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7110,8 +7110,8 @@ bool EnsembleMethod::solve(bool use_mda, vector<double> inflation_factors, vecto
}
if (best_idx == -1)
{
message(0, "WARNING: unsuccessful upgrade testing, resetting lambda to 10000.0 and returning to upgrade calculations");
last_best_lam = 10000.0;
message(0, "WARNING: unsuccessful upgrade testing, multiplying lambda by 10000.0 and returning to upgrade calculations");
last_best_lam *= 10000.0;
return false;

}
Expand All @@ -7121,7 +7121,6 @@ bool EnsembleMethod::solve(bool use_mda, vector<double> inflation_factors, vecto

if ((best_idx != -1) && (use_subset) && (local_subset_size < pe.shape().first))
{

double acc_phi = last_best_mean * acc_fac;

if (pest_scenario.get_pestpp_options().get_ies_debug_high_subset_phi())
Expand Down Expand Up @@ -7348,9 +7347,15 @@ bool EnsembleMethod::solve(bool use_mda, vector<double> inflation_factors, vecto
message(0, "updating parameter ensemble");
performance_log->log_event("updating parameter ensemble");
last_best_mean = best_mean;

pe = pe_lams[best_idx];
oe = oe_lam_best;
if (pest_scenario.get_pestpp_options().get_ies_updatebyreals())
{
message(0, "only updating realizations with reduced phi");
update_reals_by_phi(pe_lams[best_idx], oe_lam_best);
}
else {
pe = pe_lams[best_idx];
oe = oe_lam_best;
}
if (best_std < last_best_std * acc_fac)
{
double new_lam = lam_vals[best_idx] * lam_dec;
Expand All @@ -7368,11 +7373,10 @@ bool EnsembleMethod::solve(bool use_mda, vector<double> inflation_factors, vecto
else
{
//message(0, "not updating parameter ensemble");
if (!use_mda)
if ((!use_mda) && (!pest_scenario.get_pestpp_options().get_ies_updatebyreals()))
{
message(0, "only updating realizations with reduced phi");
update_reals_by_phi(pe_lams[best_idx], oe_lam_best);

}
ph.update(oe, pe, weights);
//re-check phi
Expand Down
10 changes: 9 additions & 1 deletion src/libs/pestpp_common/pest_data_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,11 @@ bool PestppOptions::assign_ies_value_by_key(const string& key, const string& val
convert_ip(value,ies_n_iter_mean);
return true;
}
else if (key == "IES_UPDATE_BY_REALS")
{
ies_updatebyreals = pest_utils::parse_string_arg_to_bool(value);
return true;
}


return false;
Expand Down Expand Up @@ -1824,9 +1829,11 @@ void PestppOptions::summary(ostream& os) const
os << "ies_phi_factors_file: " << ies_phi_fractions_file << endl;
os << "ies_phi_factors_by_real: " << ies_phi_factors_by_real << endl;
os << "ies_n_iter_mean: " << ies_n_iter_mean << endl;
os << "ies_updatebyreals: " << ies_updatebyreals << endl;



os << endl << "pestpp-sen options: " << endl;
os << endl << "pestpp-sen options: " << endl;
os << "gsa_method: " << gsa_method << endl;
os << "gsa_morris_pooled_obs: " << gsa_morris_pooled_obs << endl;
os << "gsa_morris_obs_sen: " << gsa_morris_obs_sen << endl;
Expand Down Expand Up @@ -2010,6 +2017,7 @@ void PestppOptions::set_defaults()
set_ies_phi_fractions_files("");
set_ies_phi_factors_by_real(false);
set_ies_n_iter_mean(0);
set_ies_updatebyreals(true);


// DA parameters
Expand Down
3 changes: 3 additions & 0 deletions src/libs/pestpp_common/pest_data_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ class PestppOptions {
void set_ies_phi_fractions_files(string _file) {ies_phi_fractions_file = _file;}
bool get_ies_phi_factors_by_real() const {return ies_phi_factors_by_real;}
void set_ies_phi_factors_by_real(bool _flag) {ies_phi_factors_by_real = _flag;}
bool get_ies_updatebyreals() const {return ies_updatebyreals;}
void set_ies_updatebyreals(bool _flag) {ies_updatebyreals = _flag;}



Expand Down Expand Up @@ -823,6 +825,7 @@ class PestppOptions {
string ies_phi_fractions_file;
bool ies_phi_factors_by_real;
int ies_n_iter_mean;
bool ies_updatebyreals;


// Data Assimilation parameters
Expand Down

0 comments on commit bcdf40a

Please sign in to comment.