Skip to content

Commit

Permalink
added lambda and scale fac to rns metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
jtwhite79 committed Oct 31, 2023
1 parent ab3f6a8 commit f0476fd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
28 changes: 18 additions & 10 deletions src/libs/pestpp_common/Ensemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,8 @@ ParameterEnsemble ParameterEnsemble::zeros_like(int nrows)

}

map<int,int> ParameterEnsemble::add_runs(RunManagerAbstract *run_mgr_ptr,const vector<int> &real_idxs, int da_cycle)
map<int,int> ParameterEnsemble::add_runs(RunManagerAbstract *run_mgr_ptr,const vector<int> &real_idxs,
int da_cycle, string additional_tag)
{
//add runs to the run manager using int indices
map<int,int> real_run_ids;
Expand All @@ -2205,6 +2206,7 @@ map<int,int> ParameterEnsemble::add_runs(RunManagerAbstract *run_mgr_ptr,const v
run_real_names.push_back(real_names[i]);
else
run_real_names = real_names;

int idx;
map<string, int> rmap;

Expand All @@ -2219,8 +2221,15 @@ map<int,int> ParameterEnsemble::add_runs(RunManagerAbstract *run_mgr_ptr,const v
ss << " da_cycle:" << da_cycle << " ";
info_txt = ss.str();
}
for (auto &rname : run_real_names)
if (additional_tag.size() > 0)
{
info_txt = info_txt + " " + additional_tag;
}
string rname,rinfo_txt;
//for (auto &rname : run_real_names)
for (int i=0;i<run_real_names.size();i++)
{
rname = run_real_names[i];
//idx = find(real_names.begin(), real_names.end(), rname) - real_names.begin();
idx = rmap[rname];
//Eigen::VectorXd rvector = get_real_vector(idx);
Expand All @@ -2233,14 +2242,13 @@ map<int,int> ParameterEnsemble::add_runs(RunManagerAbstract *run_mgr_ptr,const v
par_transform.numeric2model_ip(pars_real);
replace_fixed(rname, pars_real);
nn = pars_real.get_notnormal_keys();
if (nn.size() > 0)
{
stringstream ss;
ss << "ParameterEnsemble:: add_runs() error: denormal values for realization " << rname << " : ";
for (auto n : nn)
ss << n << ",";
throw_ensemble_error(ss.str());
}
if (nn.size() > 0) {
stringstream ss;
ss << "ParameterEnsemble:: add_runs() error: denormal values for realization " << rname << " : ";
for (auto n : nn)
ss << n << ",";
throw_ensemble_error(ss.str());
}
run_id = run_mgr_ptr->add_run(pars_real,info_txt+" realization:"+rname);
real_run_ids[idx] = run_id;
}
Expand Down
3 changes: 2 additions & 1 deletion src/libs/pestpp_common/Ensemble.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ class ParameterEnsemble : public Ensemble
ParamTransformSeq get_par_transform() const { return par_transform; }
void transform_ip(transStatus to_tstat);
void set_pest_scenario(Pest *_pest_scenario);
map<int,int> add_runs(RunManagerAbstract *run_mgr_ptr,const vector<int> &real_idxs=vector<int>(),int da_cycle=NetPackage::NULL_DA_CYCLE);
map<int,int> add_runs(RunManagerAbstract *run_mgr_ptr,const vector<int> &real_idxs=vector<int>(),
int da_cycle=NetPackage::NULL_DA_CYCLE, string additional_tag="");
void set_fixed_names();
void draw_uniform(int num_reals, vector<string> par_names, PerformanceLog* plog, int level, ofstream& frec);
map<string,double> draw(int num_reals, Parameters par, Covariance &cov, PerformanceLog *plog, int level, ofstream& frec);
Expand Down
9 changes: 7 additions & 2 deletions src/libs/pestpp_common/EnsembleMethodUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5130,11 +5130,16 @@ vector<ObservationEnsemble> EnsembleMethod::run_lambda_ensembles(vector<Paramete
vector<map<int, int>> real_run_ids_vec;
//ParameterEnsemble pe_lam;
//for (int i=0;i<pe_lams.size();i++)
for (auto& pe_lam : pe_lams)
//for (auto& pe_lam : pe_lams)
string additional_tag;
for (int i=0;i<pe_lams.size();i++)
{
ss.str("");
ss << " lambda:" << lam_vals[i] << " scale_fac:" << scale_vals[i];
additional_tag = ss.str();
try
{
real_run_ids_vec.push_back(pe_lam.add_runs(run_mgr_ptr, pe_subset_idxs,cycle));
real_run_ids_vec.push_back(pe_lams[i].add_runs(run_mgr_ptr, pe_subset_idxs,cycle,additional_tag));
}
catch (const exception& e)
{
Expand Down

0 comments on commit f0476fd

Please sign in to comment.